Mercurial > hg > nginx
comparison src/core/ngx_shmtx.h @ 1008:51d0884364fe
optimize inlined code for gcc
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 11 Jan 2007 16:07:03 +0000 |
parents | 201d017ea470 |
children | 2c7fed12fab7 |
comparison
equal
deleted
inserted
replaced
1007:f1ebccfd95f9 | 1008:51d0884364fe |
---|---|
28 #if (NGX_HAVE_ATOMIC_OPS) | 28 #if (NGX_HAVE_ATOMIC_OPS) |
29 | 29 |
30 static ngx_inline ngx_uint_t | 30 static ngx_inline ngx_uint_t |
31 ngx_shmtx_trylock(ngx_shmtx_t *mtx) | 31 ngx_shmtx_trylock(ngx_shmtx_t *mtx) |
32 { | 32 { |
33 if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) { | 33 return (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)); |
34 return 1; | |
35 } | |
36 | |
37 return 0; | |
38 } | 34 } |
39 | 35 |
40 #define ngx_shmtx_lock(mtx) ngx_spinlock((mtx)->lock, ngx_pid, 1024) | 36 #define ngx_shmtx_lock(mtx) ngx_spinlock((mtx)->lock, ngx_pid, 1024) |
41 | 37 |
42 #define ngx_shmtx_unlock(mtx) (void) ngx_atomic_cmp_set((mtx)->lock, ngx_pid, 0) | 38 #define ngx_shmtx_unlock(mtx) (void) ngx_atomic_cmp_set((mtx)->lock, ngx_pid, 0) |