barrier.h 907 B

12345678910111213141516171819202122232425262728
  1. #ifndef _TOOLS_LINUX_ASM_X86_BARRIER_H
  2. #define _TOOLS_LINUX_ASM_X86_BARRIER_H
  3. /*
  4. * Copied from the Linux kernel sources, and also moving code
  5. * out from tools/perf/perf-sys.h so as to make it be located
  6. * in a place similar as in the kernel sources.
  7. *
  8. * Force strict CPU ordering.
  9. * And yes, this is required on UP too when we're talking
  10. * to devices.
  11. */
  12. #if defined(__i386__)
  13. /*
  14. * Some non-Intel clones support out of order store. wmb() ceases to be a
  15. * nop for these.
  16. */
  17. #define mb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
  18. #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
  19. #define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
  20. #elif defined(__x86_64__)
  21. #define mb() asm volatile("mfence":::"memory")
  22. #define rmb() asm volatile("lfence":::"memory")
  23. #define wmb() asm volatile("sfence" ::: "memory")
  24. #endif
  25. #endif /* _TOOLS_LINUX_ASM_X86_BARRIER_H */