Go to the documentation of this file.
63 #if defined(__APPLE__)
64 # include <libkern/OSAtomic.h>
68 # define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
69 # define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
70 # define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
71 #elif defined(__GNUC__)
73 # if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
74 # define PaUtil_FullMemoryBarrier() __sync_synchronize()
75 # define PaUtil_ReadMemoryBarrier() __sync_synchronize()
76 # define PaUtil_WriteMemoryBarrier() __sync_synchronize()
81 # elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ )
82 # define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
83 # define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
84 # define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
85 # elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || \
86 defined( __i686__ ) || defined( __x86_64__ )
87 # define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
88 # define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
89 # define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
91 # ifdef ALLOW_SMP_DANGERS
92 # warning Memory barriers not defined on this system or system unknown
93 # warning For SMP safety, you should fix this.
94 # define PaUtil_FullMemoryBarrier()
95 # define PaUtil_ReadMemoryBarrier()
96 # define PaUtil_WriteMemoryBarrier()
98 # error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
101 #elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
103 # pragma intrinsic(_ReadWriteBarrier)
104 # pragma intrinsic(_ReadBarrier)
105 # pragma intrinsic(_WriteBarrier)
107 # define PaUtil_FullMemoryBarrier() _ReadWriteBarrier()
108 # define PaUtil_ReadMemoryBarrier() _ReadBarrier()
109 # define PaUtil_WriteMemoryBarrier() _WriteBarrier()
110 #elif defined(_WIN32_WCE)
111 # define PaUtil_FullMemoryBarrier()
112 # define PaUtil_ReadMemoryBarrier()
113 # define PaUtil_WriteMemoryBarrier()
114 #elif defined(_MSC_VER) || defined(__BORLANDC__)
115 # define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0 }
116 # define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0 }
117 # define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0 }
119 # ifdef ALLOW_SMP_DANGERS
120 # warning Memory barriers not defined on this system or system unknown
121 # warning For SMP safety, you should fix this.
122 # define PaUtil_FullMemoryBarrier()
123 # define PaUtil_ReadMemoryBarrier()
124 # define PaUtil_WriteMemoryBarrier()
126 # error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.