diff options
-rw-r--r-- | src/zix/ring.c | 24 | ||||
-rw-r--r-- | wscript | 3 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/zix/ring.c b/src/zix/ring.c index 3da4f7f..c5b41f5 100644 --- a/src/zix/ring.c +++ b/src/zix/ring.c @@ -1,5 +1,5 @@ /* - Copyright 2011 David Robillard <http://drobilla.net> + Copyright 2011-2017 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -29,23 +29,27 @@ # define ZIX_MLOCK(ptr, size) #endif -#if defined(__APPLE__) +#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) +# include <stdatomic.h> +# define ZIX_WRITE_BARRIER() atomic_thread_fence(memory_order_release) +# define ZIX_READ_BARRIER() atomic_thread_fence(memory_order_acquire) +#elif defined(__APPLE__) /* Pre 10.12 */ # include <libkern/OSAtomic.h> -# define ZIX_FULL_BARRIER() OSMemoryBarrier() +# define ZIX_WRITE_BARRIER() OSMemoryBarrier() +# define ZIX_READ_BARRIER() OSMemoryBarrier() #elif defined(_WIN32) # include <windows.h> -# define ZIX_FULL_BARRIER() MemoryBarrier() +# define ZIX_WRITE_BARRIER() MemoryBarrier() +# define ZIX_READ_BARRIER() MemoryBarrier() #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) -# define ZIX_FULL_BARRIER() __sync_synchronize() +# define ZIX_WRITE_BARRIER() __sync_synchronize() +# define ZIX_READ_BARRIER() __sync_synchronize() #else # pragma message("warning: No memory barriers, possible SMP bugs") -# define ZIX_FULL_BARRIER() +# define ZIX_WRITE_BARRIER() +# define ZIX_READ_BARRIER() #endif -/* No support for any systems with separate read and write barriers */ -#define ZIX_READ_BARRIER() ZIX_FULL_BARRIER() -#define ZIX_WRITE_BARRIER() ZIX_FULL_BARRIER() - #include "zix/ring.h" struct ZixRingImpl { @@ -51,6 +51,9 @@ def configure(conf): autowaf.set_c99_mode(conf) autowaf.set_cxx11_mode(conf) + if conf.check(cflags=["-std=c11"]): + conf.env.append_unique('CFLAGS', ['-std=c11']) + autowaf.check_pkg(conf, 'lv2', atleast_version='1.14.0', uselib_store='LV2') autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV', atleast_version='0.24.0', mandatory=True) |