Mercurial > hg > nginx
diff src/os/unix/ngx_atomic.h @ 425:bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 14 Sep 2004 15:55:24 +0000 |
parents | 018569a8f09c |
children | 5e73d0ea4dab |
line wrap: on
line diff
--- a/src/os/unix/ngx_atomic.h Tue Sep 14 05:45:22 2004 +0000 +++ b/src/os/unix/ngx_atomic.h Tue Sep 14 15:55:24 2004 +0000 @@ -68,6 +68,57 @@ } +#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;