From a952453888fb5df3c70edf357820bc924b4f3e7f Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 18 Jan 2021 21:55:03 -0600 Subject: [PATCH] include: Add MemoryBarrier(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- include/winnt.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/include/winnt.h b/include/winnt.h index 61368d43d3c..8834ced73e6 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -6983,7 +6983,50 @@ static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *des return (void *)_InterlockedExchange( (long volatile*)dest, (long)val ); } -#endif +#endif /* __i386__ */ + +#ifdef __i386__ + +static FORCEINLINE void MemoryBarrier(void) +{ + LONG dummy; + InterlockedOr(&dummy, 0); +} + +#elif defined(__x86_64__) + +#pragma intrinsic(__faststorefence) + +void __faststorefence(void); + +static FORCEINLINE void MemoryBarrier(void) +{ + __faststorefence(); +} + +#elif defined(__arm__) + +#pragma intrinsic(__dmb) + +void __dmb(void); + +static FORCEINLINE void MemoryBarrier(void) +{ + __dmb(_ARM_BARRIER_SY); +} + +#elif defined(__aarch64__) + +#pragma intrinsic(__dmb) + +void __dmb(void); + +static FORCEINLINE void MemoryBarrier(void) +{ + __dmb(_ARM64_BARRIER_SY); +} + +#endif /* __i386__ */ #elif defined(__GNUC__) @@ -7068,6 +7111,11 @@ static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val ) return __sync_fetch_and_or( dest, val ); } +static FORCEINLINE void MemoryBarrier(void) +{ + __sync_synchronize(); +} + #endif /* __GNUC__ */ #ifdef __cplusplus