Mercurial > hg > svcore
diff system/System.cpp @ 835:1d439494604c
Memory barriers in ringbuffer
author | Chris Cannam |
---|---|
date | Mon, 16 Sep 2013 15:47:27 +0100 |
parents | 001d77a720ce |
children | e802e550a1f2 |
line wrap: on
line diff
--- a/system/System.cpp Tue Jul 30 18:15:30 2013 +0100 +++ b/system/System.cpp Mon Sep 16 15:47:27 2013 +0100 @@ -274,6 +274,30 @@ #endif } +#ifdef _WIN32 +extern void SystemMemoryBarrier() +{ +#ifdef __MSVC__ + MemoryBarrier(); +#else /* mingw */ + LONG Barrier = 0; + __asm__ __volatile__("xchgl %%eax,%0 " + : "=r" (Barrier)); +#endif +} +#else /* !_WIN32 */ +#if !defined(__APPLE__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)) +void +SystemMemoryBarrier() +{ + pthread_mutex_t dummy = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock(&dummy); + pthread_mutex_unlock(&dummy); +} +#endif /* !defined(__APPLE__) etc */ +#endif /* !_WIN32 */ + + static char *startupLocale = 0; void