Update mingw32 MemoryBarrier from HarfBuzz

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=81228
This commit is contained in:
Behdad Esfahbod 2014-07-11 12:19:39 -04:00
parent dca5d0feee
commit 6781c6baef
1 changed files with 9 additions and 9 deletions

View File

@ -48,22 +48,22 @@
#include "fcwindows.h" #include "fcwindows.h"
/* mingw32 does not have MemoryBarrier. /* MinGW has a convoluted history of supporting MemoryBarrier
* MemoryBarrier may be defined as a macro or a function. * properly. As such, define a function to wrap the whole
* Just make a failsafe version for ourselves. */ * thing. */
#ifdef MemoryBarrier static inline void _FCMemoryBarrier (void) {
#define HBMemoryBarrier MemoryBarrier #if !defined(MemoryBarrier)
#else
static inline void HBMemoryBarrier (void) {
long dummy = 0; long dummy = 0;
InterlockedExchange (&dummy, 1); InterlockedExchange (&dummy, 1);
} #else
MemoryBarrier ();
#endif #endif
}
typedef LONG fc_atomic_int_t; typedef LONG fc_atomic_int_t;
#define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) #define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
#define fc_atomic_ptr_get(P) (HBMemoryBarrier (), (void *) *(P)) #define fc_atomic_ptr_get(P) (_FCMemoryBarrier (), (void *) *(P))
#define fc_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) #define fc_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))