diff options
author | Nathan Hjelm <hjelmn@google.com> | 2020-12-16 20:57:57 -0700 |
---|---|---|
committer | Nathan Hjelm <hjelmn@google.com> | 2020-12-16 20:57:57 -0700 |
commit | eed8a371ea53939096ba94d44001e0637d042572 (patch) | |
tree | b0b1e12e618d89214ee8d7e519eebe7673930b75 /libusb | |
parent | 1a08aa84d96397a3840a75abe66051f5360c2c84 (diff) | |
download | libusb-eed8a371ea53939096ba94d44001e0637d042572.tar.gz |
Use stdatomic instead of gcc-internal atomics
The __atomic operations are internal to gcc and not necessarily supported
by all c11 compilers. Use the atomics in stdatomic instead.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/libusbi.h | 11 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libusb/libusbi.h b/libusb/libusbi.h index aea1bac..7656660 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -103,11 +103,12 @@ typedef volatile LONG usbi_atomic_t; #define usbi_atomic_inc(a) InterlockedIncrement((a)) #define usbi_atomic_dec(a) InterlockedDecrement((a)) #else -typedef long usbi_atomic_t; -#define usbi_atomic_load(a) __atomic_load_n((a), __ATOMIC_SEQ_CST) -#define usbi_atomic_store(a, v) __atomic_store_n((a), (v), __ATOMIC_SEQ_CST) -#define usbi_atomic_inc(a) __atomic_add_fetch((a), 1, __ATOMIC_SEQ_CST) -#define usbi_atomic_dec(a) __atomic_sub_fetch((a), 1, __ATOMIC_SEQ_CST) +#include <stdatomic.h> +typedef atomic_long usbi_atomic_t; +#define usbi_atomic_load(a) atomic_load((a)) +#define usbi_atomic_store(a, v) atomic_store((a), (v)) +#define usbi_atomic_inc(a) (atomic_fetch_add((a), 1) + 1) +#define usbi_atomic_dec(a) (atomic_fetch_add((a), -1) - 1) #endif /* Internal abstractions for event handling and thread synchronization */ diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 6926971..40532d3 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11587 +#define LIBUSB_NANO 11588 |