|
17 | 17 | #ifndef _KQUEUE_SOLARIS_PLATFORM_H |
18 | 18 | #define _KQUEUE_SOLARIS_PLATFORM_H |
19 | 19 |
|
20 | | -#include <atomic.h> |
21 | 20 | #include <errno.h> |
22 | 21 | #include <pthread.h> |
| 22 | +#include <stdatomic.h> |
23 | 23 | #include <string.h> |
24 | 24 | #include <sys/queue.h> |
25 | 25 | #include <sys/resource.h> |
26 | 26 | #include <sys/time.h> |
27 | 27 |
|
28 | 28 | #include "../posix/eventfd.h" |
29 | 29 |
|
30 | | -#define atomic_uintptr_t uintptr_t |
31 | | -#define atomic_uint unsigned int |
32 | | -#define atomic_inc atomic_inc_32_nv |
33 | | -#define atomic_dec atomic_dec_32_nv |
34 | | -#define atomic_cas(p, oval, nval) (atomic_cas(p, oval, nval) == oval) |
35 | | -#define atomic_ptr_cas(p, oval, nval) (atomic_cas_ptr(p, oval, nval) == oval) |
36 | | -#define atomic_ptr_swap(p, nval) (atomic_swap_ptr(p, nval) |
37 | | -#define atomic_ptr_load(p) (*p) |
| 30 | +/* |
| 31 | + * C11 atomic operations |
| 32 | + */ |
| 33 | +#define atomic_inc(p) (atomic_fetch_add((p), 1) + 1) |
| 34 | +#define atomic_dec(p) (atomic_fetch_sub((p), 1) - 1) |
| 35 | + |
| 36 | +/* We use compound literals here to stop the 'expected' values from being overwritten */ |
| 37 | +#define atomic_cas(p, oval, nval) atomic_compare_exchange_strong(p, &(__typeof__(oval)){ oval }, nval) |
| 38 | +#define atomic_ptr_cas(p, oval, nval) atomic_compare_exchange_strong(p, (&(uintptr_t){ (uintptr_t)oval }), (uintptr_t)nval) |
| 39 | +#define atomic_ptr_swap(p, nval) atomic_exchange(p, (uintptr_t)nval) |
| 40 | +#define atomic_ptr_load(p) atomic_load(p) |
38 | 41 |
|
39 | 42 | /* |
40 | 43 | * Event ports |
|
0 commit comments