barrier.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copied from the kernel sources to tools/:
  3. *
  4. * Memory barrier definitions. This is based on information published
  5. * in the Processor Abstraction Layer and the System Abstraction Layer
  6. * manual.
  7. *
  8. * Copyright (C) 1998-2003 Hewlett-Packard Co
  9. * David Mosberger-Tang <davidm@hpl.hp.com>
  10. * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
  11. * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
  12. */
  13. #ifndef _TOOLS_LINUX_ASM_IA64_BARRIER_H
  14. #define _TOOLS_LINUX_ASM_IA64_BARRIER_H
  15. #include <linux/compiler.h>
  16. /*
  17. * Macros to force memory ordering. In these descriptions, "previous"
  18. * and "subsequent" refer to program order; "visible" means that all
  19. * architecturally visible effects of a memory access have occurred
  20. * (at a minimum, this means the memory has been read or written).
  21. *
  22. * wmb(): Guarantees that all preceding stores to memory-
  23. * like regions are visible before any subsequent
  24. * stores and that all following stores will be
  25. * visible only after all previous stores.
  26. * rmb(): Like wmb(), but for reads.
  27. * mb(): wmb()/rmb() combo, i.e., all previous memory
  28. * accesses are visible before all subsequent
  29. * accesses and vice versa. This is also known as
  30. * a "fence."
  31. *
  32. * Note: "mb()" and its variants cannot be used as a fence to order
  33. * accesses to memory mapped I/O registers. For that, mf.a needs to
  34. * be used. However, we don't want to always use mf.a because (a)
  35. * it's (presumably) much slower than mf and (b) mf.a is supported for
  36. * sequential memory pages only.
  37. */
  38. /* XXX From arch/ia64/include/uapi/asm/gcc_intrin.h */
  39. #define ia64_mf() asm volatile ("mf" ::: "memory")
  40. #define mb() ia64_mf()
  41. #define rmb() mb()
  42. #define wmb() mb()
  43. #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */