Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
834:fcee7e040ab4 | 835:1d439494604c |
---|---|
272 return -1; | 272 return -1; |
273 } | 273 } |
274 #endif | 274 #endif |
275 } | 275 } |
276 | 276 |
277 #ifdef _WIN32 | |
278 extern void SystemMemoryBarrier() | |
279 { | |
280 #ifdef __MSVC__ | |
281 MemoryBarrier(); | |
282 #else /* mingw */ | |
283 LONG Barrier = 0; | |
284 __asm__ __volatile__("xchgl %%eax,%0 " | |
285 : "=r" (Barrier)); | |
286 #endif | |
287 } | |
288 #else /* !_WIN32 */ | |
289 #if !defined(__APPLE__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)) | |
290 void | |
291 SystemMemoryBarrier() | |
292 { | |
293 pthread_mutex_t dummy = PTHREAD_MUTEX_INITIALIZER; | |
294 pthread_mutex_lock(&dummy); | |
295 pthread_mutex_unlock(&dummy); | |
296 } | |
297 #endif /* !defined(__APPLE__) etc */ | |
298 #endif /* !_WIN32 */ | |
299 | |
300 | |
277 static char *startupLocale = 0; | 301 static char *startupLocale = 0; |
278 | 302 |
279 void | 303 void |
280 StoreStartupLocale() | 304 StoreStartupLocale() |
281 { | 305 { |