0
// Gcc on x86
inline void MemoryBarrier() {
  // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
  // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
  __asm__ __volatile__("" : : : "memory");
}

asm volatile("" : : : "memory")’ can only resolve compile-time memory ordering, I cann't understand how to resolve runtime memory ordering.

Pengcheng
  • 439
  • 1
  • 4
  • 14
  • See [this question](https://stackoverflow.com/questions/19965076/gcc-memory-barrier-sync-synchronize-vs-asm-volatile-memory) – LWimsey Aug 09 '17 at 01:41
  • What makes you think you have a problem with runtime memory ordering? Gcc has builtins for hw fencing (`__builtin_ia32_mfence` et al), but you shouldn't use them unless you actually need them. – David Wohlferd Aug 09 '17 at 04:00

0 Answers0