summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_atomic.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-06-30 15:30:41 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-06-30 15:30:41 +0000
commit078d1b2c2263690f2f6b7217b567eeeb525910d0 (patch)
treedfb82cccd10c3dee8a500506f7692b0445200e5c /src/core/ngx_atomic.h
parent0a94cfd2ae9ca87b4d988b5066f739a3034f3bff (diff)
downloadnginx-078d1b2c2263690f2f6b7217b567eeeb525910d0.tar.gz
nginx-078d1b2c2263690f2f6b7217b567eeeb525910d0.tar.bz2
nginx-0.0.7-2004-06-30-19:30:41 import
Diffstat (limited to 'src/core/ngx_atomic.h')
-rw-r--r--src/core/ngx_atomic.h106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/core/ngx_atomic.h b/src/core/ngx_atomic.h
deleted file mode 100644
index a149ad28b..000000000
--- a/src/core/ngx_atomic.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef _NGX_ATOMIC_H_INCLUDED_
-#define _NGX_ATOMIC_H_INCLUDED_
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-
-
-#if ( __i386__ || __amd64__ )
-
-typedef volatile uint32_t ngx_atomic_t;
-
-#if (NGX_SMP)
-#define NGX_SMP_LOCK "lock;"
-#else
-#define NGX_SMP_LOCK
-#endif
-
-
-static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
-{
- uint32_t old;
-
- __asm__ volatile (
-
- NGX_SMP_LOCK
- " xaddl %0, %2; "
- " incl %0; "
-
- : "=q" (old) : "0" (1), "m" (*value));
-
- return old;
-}
-
-
-static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value)
-{
- uint32_t old;
-
- __asm__ volatile (
-
- NGX_SMP_LOCK
- " xaddl %0, %1; "
- " decl %0; "
-
- : "=q" (old) : "0" (-1), "m" (*value));
-
- return old;
-}
-
-
-static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
- ngx_atomic_t old,
- ngx_atomic_t set)
-{
- uint32_t res;
-
- __asm__ volatile (
-
- NGX_SMP_LOCK
- " cmpxchgl %3, %1; "
- " setz %%al; "
- " movzbl %%al, %0; "
-
- : "=a" (res) : "m" (*lock), "a" (old), "q" (set));
-
- return res;
-}
-
-
-#elif (WIN32)
-
-#define ngx_atomic_inc(p) InterlockedIncrement((long *) p)
-#define ngx_atomic_dec(p) InterlockedDecrement((long *) p)
-
-#if defined(__WATCOMC__) || defined(__BORLANDC__)
-
-#define ngx_atomic_cmp_set(lock, old, set) \
- (InterlockedCompareExchange((long *) lock, set, old) == old)
-
-#else
-
-#define ngx_atomic_cmp_set(lock, old, set) \
- (InterlockedCompareExchange((void **) lock, (void *) set, (void *) old) \
- == (void *) old)
-
-#endif
-
-#else
-
-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
-/**/
-
-#endif
-
-
-#define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))
-#define ngx_unlock(lock) *(lock) = 0
-
-
-#endif /* _NGX_ATOMIC_H_INCLUDED_ */