diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-09-14 19:55:24 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-09-14 19:55:24 +0400 |
commit | e2ff3ea920ba6bc3690a333abdaa2e40656f933a (patch) | |
tree | 5e9d8e784f041e7fb29cda6c87b7119ccd6d2817 /src/os/unix | |
parent | 562626ae6cda8c90121bec3362232e87899d6ce6 (diff) |
nginx-0.0.10-2004-09-14-19:55:24 import
Diffstat (limited to 'src/os/unix')
-rw-r--r-- | src/os/unix/ngx_atomic.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h index 18d5edac5..552edd5e8 100644 --- a/src/os/unix/ngx_atomic.h +++ b/src/os/unix/ngx_atomic.h @@ -68,6 +68,57 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock, } +#elif ( __sparc__ ) + +typedef volatile uint32_t ngx_atomic_t; + + +static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value) +{ + uint32_t old, new, res; + + old = *value; + + for ( ;; ) { + + new = old + 1; + res = new; + + __asm__ volatile ( + + "casa [%1]ASI_P, %2, %0" + + : "+r" (res) : "r" (value), "r" (old)); + + if (res == old) { + return new; + } + + old = res; + } +} + + +/* 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) +{ + uint32_t res = (u_int32_t) set; + + __asm__ volatile ( + + "casa [%1]ASI_P, %2, %0" + + : "+r" (res) : "r" (lock), "r" (old)); + + return (res == old); +} + #else typedef volatile uint32_t ngx_atomic_t; |