diff options
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/unix/ngx_atomic.h | 28 | ||||
| -rw-r--r-- | src/os/win32/ngx_atomic.h | 8 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h index 7f740381b..c5197e56e 100644 --- a/src/os/unix/ngx_atomic.h +++ b/src/os/unix/ngx_atomic.h @@ -8,6 +8,8 @@ #if ( __i386__ || __amd64__ ) +#define NGX_HAVE_ATOMIC_OPS 1 + typedef volatile uint32_t ngx_atomic_t; #if (NGX_SMP) @@ -33,6 +35,8 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value) } +#if 0 + static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value) { uint32_t old; @@ -48,6 +52,8 @@ static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value) return old; } +#endif + static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_t old, @@ -70,6 +76,8 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, #elif ( __sparc__ ) +#define NGX_HAVE_ATOMIC_OPS 1 + typedef volatile uint32_t ngx_atomic_t; @@ -99,11 +107,6 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value) } -/* STUB */ -#define ngx_atomic_dec(x) (*(x))--; -/**/ - - static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_t old, ngx_atomic_t set) @@ -121,13 +124,18 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, #else +#define NGX_HAVE_ATOMIC_OPS 0 + typedef volatile uint32_t ngx_atomic_t; -/* STUB */ -#define ngx_atomic_inc(x) ++(*(x)); -#define ngx_atomic_dec(x) --(*(x)); -#define ngx_atomic_cmp_set(lock, old, set) 1 -/**/ +#define ngx_atomic_inc(x) ++(*(x)); + +static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, + ngx_atomic_t old, + ngx_atomic_t set) +{ + return 1; +} #endif diff --git a/src/os/win32/ngx_atomic.h b/src/os/win32/ngx_atomic.h index fcc3ff1ee..9d75fabd5 100644 --- a/src/os/win32/ngx_atomic.h +++ b/src/os/win32/ngx_atomic.h @@ -6,17 +6,23 @@ #include <ngx_core.h> +#define NGX_HAVE_ATOMIC_OPS 1 + + #define ngx_atomic_inc(p) InterlockedIncrement((long *) p) -#define ngx_atomic_dec(p) InterlockedDecrement((long *) p) #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) +/* the new SDK headers */ + #define ngx_atomic_cmp_set(lock, old, set) \ (InterlockedCompareExchange((long *) lock, set, old) == old) #else +/* the old MS VC6.0SP2 SDK headers */ + #define ngx_atomic_cmp_set(lock, old, set) \ (InterlockedCompareExchange((void **) lock, (void *) set, (void *) old) \ == (void *) old) |
