rmwcc.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _TOOLS_LINUX_ASM_X86_RMWcc
  2. #define _TOOLS_LINUX_ASM_X86_RMWcc
  3. #ifdef CC_HAVE_ASM_GOTO
  4. #define __GEN_RMWcc(fullop, var, cc, ...) \
  5. do { \
  6. asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
  7. : : "m" (var), ## __VA_ARGS__ \
  8. : "memory" : cc_label); \
  9. return 0; \
  10. cc_label: \
  11. return 1; \
  12. } while (0)
  13. #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
  14. __GEN_RMWcc(op " " arg0, var, cc)
  15. #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
  16. __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
  17. #else /* !CC_HAVE_ASM_GOTO */
  18. #define __GEN_RMWcc(fullop, var, cc, ...) \
  19. do { \
  20. char c; \
  21. asm volatile (fullop "; set" cc " %1" \
  22. : "+m" (var), "=qm" (c) \
  23. : __VA_ARGS__ : "memory"); \
  24. return c != 0; \
  25. } while (0)
  26. #define GEN_UNARY_RMWcc(op, var, arg0, cc) \
  27. __GEN_RMWcc(op " " arg0, var, cc)
  28. #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
  29. __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
  30. #endif /* CC_HAVE_ASM_GOTO */
  31. #endif /* _TOOLS_LINUX_ASM_X86_RMWcc */