2013-09-11 13:19:24 +00:00
|
|
|
#ifndef _ASM_X86_RMWcc
|
|
|
|
#define _ASM_X86_RMWcc
|
|
|
|
|
2016-06-08 19:38:41 +00:00
|
|
|
#if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
|
|
|
|
|
|
|
|
/* Use asm goto */
|
2013-09-11 13:19:24 +00:00
|
|
|
|
|
|
|
#define __GEN_RMWcc(fullop, var, cc, ...) \
|
|
|
|
do { \
|
2016-06-08 19:38:39 +00:00
|
|
|
asm_volatile_goto (fullop "; j" #cc " %l[cc_label]" \
|
2013-09-11 13:19:24 +00:00
|
|
|
: : "m" (var), ## __VA_ARGS__ \
|
|
|
|
: "memory" : cc_label); \
|
|
|
|
return 0; \
|
|
|
|
cc_label: \
|
|
|
|
return 1; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
|
|
|
|
__GEN_RMWcc(op " " arg0, var, cc)
|
|
|
|
|
2013-12-04 22:31:28 +00:00
|
|
|
#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
|
|
|
|
__GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
|
2013-09-11 13:19:24 +00:00
|
|
|
|
2016-06-08 19:38:41 +00:00
|
|
|
#else /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
|
|
|
|
|
|
|
|
/* Use flags output or a set instruction */
|
2013-09-11 13:19:24 +00:00
|
|
|
|
|
|
|
#define __GEN_RMWcc(fullop, var, cc, ...) \
|
|
|
|
do { \
|
2016-06-08 19:38:38 +00:00
|
|
|
bool c; \
|
2016-06-08 19:38:41 +00:00
|
|
|
asm volatile (fullop ";" CC_SET(cc) \
|
|
|
|
: "+m" (var), CC_OUT(cc) (c) \
|
2013-09-11 13:19:24 +00:00
|
|
|
: __VA_ARGS__ : "memory"); \
|
2016-06-08 19:38:38 +00:00
|
|
|
return c; \
|
2013-09-11 13:19:24 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
|
|
|
|
__GEN_RMWcc(op " " arg0, var, cc)
|
|
|
|
|
2013-12-04 22:31:28 +00:00
|
|
|
#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
|
|
|
|
__GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
|
2013-09-11 13:19:24 +00:00
|
|
|
|
2016-06-08 19:38:41 +00:00
|
|
|
#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
|
2013-09-11 13:19:24 +00:00
|
|
|
|
|
|
|
#endif /* _ASM_X86_RMWcc */
|