2
0

qemu-barrier.h 978 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __QEMU_BARRIER_H
  2. #define __QEMU_BARRIER_H 1
  3. /* Compiler barrier */
  4. #define barrier() asm volatile("" ::: "memory")
  5. #if defined(__i386__) || defined(__x86_64__)
  6. /*
  7. * Because of the strongly ordered x86 storage model, wmb() is a nop
  8. * on x86(well, a compiler barrier only). Well, at least as long as
  9. * qemu doesn't do accesses to write-combining memory or non-temporal
  10. * load/stores from C code.
  11. */
  12. #define smp_wmb() barrier()
  13. #elif defined(_ARCH_PPC)
  14. /*
  15. * We use an eieio() for a wmb() on powerpc. This assumes we don't
  16. * need to order cacheable and non-cacheable stores with respect to
  17. * each other
  18. */
  19. #define smp_wmb() asm volatile("eieio" ::: "memory")
  20. #else
  21. /*
  22. * For (host) platforms we don't have explicit barrier definitions
  23. * for, we use the gcc __sync_synchronize() primitive to generate a
  24. * full barrier. This should be safe on all platforms, though it may
  25. * be overkill.
  26. */
  27. #define smp_wmb() __sync_synchronize()
  28. #endif
  29. #endif