From e2ff3ea920ba6bc3690a333abdaa2e40656f933a Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 14 Sep 2004 15:55:24 +0000 Subject: nginx-0.0.10-2004-09-14-19:55:24 import --- src/os/unix/ngx_atomic.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/os/unix/ngx_atomic.h') 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; -- cgit v1.2.3