diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-11-25 17:55:25 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-11-25 17:55:25 +0000 |
commit | 213cad8e815a5a017a1fe2b254b5c041ea830d86 (patch) | |
tree | 789089844ff6e534781e658e6dbc2b4ffe2503e4 /src/os/unix/ngx_atomic.h | |
parent | 89d635fa5dd04cb857f00de98f34d7792ec3e1a5 (diff) | |
download | nginx-213cad8e815a5a017a1fe2b254b5c041ea830d86.tar.gz nginx-213cad8e815a5a017a1fe2b254b5c041ea830d86.zip |
libatomic_ops support
Diffstat (limited to 'src/os/unix/ngx_atomic.h')
-rw-r--r-- | src/os/unix/ngx_atomic.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h index b478cc8d4..39b3e6b7f 100644 --- a/src/os/unix/ngx_atomic.h +++ b/src/os/unix/ngx_atomic.h @@ -12,7 +12,31 @@ #include <ngx_core.h> -#if (NGX_DARWIN_ATOMIC) +#if (NGX_HAVE_LIBATOMIC) + +#include <atomic_ops.h> + +#define NGX_HAVE_ATOMIC_OPS 1 + +typedef long ngx_atomic_int_t; +typedef AO_t ngx_atomic_uint_t; +typedef volatile ngx_atomic_uint_t ngx_atomic_t; + +#if (NGX_PTR_SIZE == 8) +#define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) +#else +#define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) +#endif + +#define ngx_atomic_cmp_set(lock, old, new) \ + AO_compare_and_swap(lock, old, new) +#define ngx_atomic_fetch_add(value, add) \ + AO_fetch_and_add(value, add) +#define ngx_memory_barrier() AO_nop() +#define ngx_cpu_pause() + + +#elif (NGX_DARWIN_ATOMIC) /* * use Darwin 8 atomic(3) and barrier(3) operations |