Merge tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / arch / x86 / include / asm / rmwcc.h
blobfee7983a90b4f4ced4632e1a48a0164605bc7334
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TOOLS_LINUX_ASM_X86_RMWcc
3 #define _TOOLS_LINUX_ASM_X86_RMWcc
5 #ifdef CONFIG_CC_HAS_ASM_GOTO
7 #define __GEN_RMWcc(fullop, var, cc, ...) \
8 do { \
9 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
10 : : "m" (var), ## __VA_ARGS__ \
11 : "memory" : cc_label); \
12 return 0; \
13 cc_label: \
14 return 1; \
15 } while (0)
17 #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
18 __GEN_RMWcc(op " " arg0, var, cc)
20 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21 __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
23 #else /* !CONFIG_CC_HAS_ASM_GOTO */
25 #define __GEN_RMWcc(fullop, var, cc, ...) \
26 do { \
27 char c; \
28 asm volatile (fullop "; set" cc " %1" \
29 : "+m" (var), "=qm" (c) \
30 : __VA_ARGS__ : "memory"); \
31 return c != 0; \
32 } while (0)
34 #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
35 __GEN_RMWcc(op " " arg0, var, cc)
37 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
38 __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
40 #endif /* CONFIG_CC_HAS_ASM_GOTO */
42 #endif /* _TOOLS_LINUX_ASM_X86_RMWcc */