~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/include/asm/cmpxchg.h

Version: ~ [ linux-5.11 ] ~ [ linux-5.10.17 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.99 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.176 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.221 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.257 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.257 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright IBM Corp. 1999, 2011
  4  *
  5  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
  6  */
  7 
  8 #ifndef __ASM_CMPXCHG_H
  9 #define __ASM_CMPXCHG_H
 10 
 11 #include <linux/mmdebug.h>
 12 #include <linux/types.h>
 13 #include <linux/bug.h>
 14 
 15 #define cmpxchg(ptr, o, n)                                              \
 16 ({                                                                      \
 17         __typeof__(*(ptr)) __o = (o);                                   \
 18         __typeof__(*(ptr)) __n = (n);                                   \
 19         (__typeof__(*(ptr))) __sync_val_compare_and_swap((ptr),__o,__n);\
 20 })
 21 
 22 #define cmpxchg64       cmpxchg
 23 #define cmpxchg_local   cmpxchg
 24 #define cmpxchg64_local cmpxchg
 25 
 26 #define xchg(ptr, x)                                                    \
 27 ({                                                                      \
 28         __typeof__(ptr) __ptr = (ptr);                                  \
 29         __typeof__(*(ptr)) __old;                                       \
 30         do {                                                            \
 31                 __old = *__ptr;                                         \
 32         } while (!__sync_bool_compare_and_swap(__ptr, __old, x));       \
 33         __old;                                                          \
 34 })
 35 
 36 #define __cmpxchg_double(p1, p2, o1, o2, n1, n2)                        \
 37 ({                                                                      \
 38         register __typeof__(*(p1)) __old1 asm("2") = (o1);              \
 39         register __typeof__(*(p2)) __old2 asm("3") = (o2);              \
 40         register __typeof__(*(p1)) __new1 asm("4") = (n1);              \
 41         register __typeof__(*(p2)) __new2 asm("5") = (n2);              \
 42         int cc;                                                         \
 43         asm volatile(                                                   \
 44                 "       cdsg    %[old],%[new],%[ptr]\n"                 \
 45                 "       ipm     %[cc]\n"                                \
 46                 "       srl     %[cc],28"                               \
 47                 : [cc] "=d" (cc), [old] "+d" (__old1), "+d" (__old2)    \
 48                 : [new] "d" (__new1), "d" (__new2),                     \
 49                   [ptr] "Q" (*(p1)), "Q" (*(p2))                        \
 50                 : "memory", "cc");                                      \
 51         !cc;                                                            \
 52 })
 53 
 54 #define cmpxchg_double(p1, p2, o1, o2, n1, n2)                          \
 55 ({                                                                      \
 56         __typeof__(p1) __p1 = (p1);                                     \
 57         __typeof__(p2) __p2 = (p2);                                     \
 58         BUILD_BUG_ON(sizeof(*(p1)) != sizeof(long));                    \
 59         BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long));                    \
 60         VM_BUG_ON((unsigned long)((__p1) + 1) != (unsigned long)(__p2));\
 61         __cmpxchg_double(__p1, __p2, o1, o2, n1, n2);                   \
 62 })
 63 
 64 #define system_has_cmpxchg_double()     1
 65 
 66 #endif /* __ASM_CMPXCHG_H */
 67 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp