Mercurial > hg > nginx
annotate src/os/unix/ngx_atomic.h @ 2213:8cc552c91cd2
bump version
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 26 Aug 2008 17:23:27 +0000 |
parents | c505e2712e13 |
children | 7658e9c7e814 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
5 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
6 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #ifndef _NGX_ATOMIC_H_INCLUDED_ |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #define _NGX_ATOMIC_H_INCLUDED_ |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
940 | 15 #if (NGX_DARWIN_ATOMIC) |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
16 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
17 /* |
940 | 18 * use Darwin 8 atomic(3) and barrier(3) operations |
19 * optimized at run-time for UP and SMP | |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
20 */ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
21 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
22 #include <libkern/OSAtomic.h> |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
23 |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
24 /* "bool" conflicts with perl's CORE/handy.h */ |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
25 #undef bool |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
26 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
27 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
28 #define NGX_HAVE_ATOMIC_OPS 1 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
29 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
30 #if (NGX_PTR_SIZE == 8) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
31 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
32 typedef int64_t ngx_atomic_int_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
33 typedef uint64_t ngx_atomic_uint_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
34 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
35 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
36 #define ngx_atomic_cmp_set(lock, old, new) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
37 OSAtomicCompareAndSwap64Barrier(old, new, (int64_t *) lock) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
38 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
39 #define ngx_atomic_fetch_add(value, add) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
40 (OSAtomicAdd64(add, (int64_t *) value) - add) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
41 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
42 #else |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
43 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
44 typedef int32_t ngx_atomic_int_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
45 typedef uint32_t ngx_atomic_uint_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
46 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
47 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
48 #define ngx_atomic_cmp_set(lock, old, new) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
49 OSAtomicCompareAndSwap32Barrier(old, new, (int32_t *) lock) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
50 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
51 #define ngx_atomic_fetch_add(value, add) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
52 (OSAtomicAdd32(add, (int32_t *) value) - add) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
53 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
54 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
55 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
56 #define ngx_memory_barrier() OSMemoryBarrier() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
57 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
58 #define ngx_cpu_pause() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
59 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
60 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
61 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
62 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
63 #else /* !(NGX_DARWIN) */ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
64 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
65 |
547 | 66 #if ( __i386__ || __i386 ) |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
67 |
561 | 68 typedef int32_t ngx_atomic_int_t; |
69 typedef uint32_t ngx_atomic_uint_t; | |
495 | 70 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 71 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 |
493 | 72 |
73 | |
561 | 74 #if ( __SUNPRO_C ) |
493 | 75 |
561 | 76 #define NGX_HAVE_ATOMIC_OPS 1 |
493 | 77 |
561 | 78 ngx_atomic_uint_t |
79 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
80 ngx_atomic_uint_t set); | |
493 | 81 |
561 | 82 ngx_atomic_int_t |
83 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
493 | 84 |
1309 | 85 /* |
86 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
87 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il | |
88 */ | |
89 | |
90 void | |
91 ngx_cpu_pause(void); | |
92 | |
561 | 93 /* the code in src/os/unix/ngx_sunpro_x86.il */ |
493 | 94 |
563 | 95 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
96 | |
493 | 97 |
561 | 98 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
99 | |
100 #define NGX_HAVE_ATOMIC_OPS 1 | |
493 | 101 |
561 | 102 #include "ngx_gcc_atomic_x86.h" |
493 | 103 |
561 | 104 #endif |
493 | 105 |
106 | |
547 | 107 #elif ( __amd64__ || __amd64 ) |
493 | 108 |
561 | 109 typedef int64_t ngx_atomic_int_t; |
110 typedef uint64_t ngx_atomic_uint_t; | |
495 | 111 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 112 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
113 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
114 |
561 | 115 #if ( __SUNPRO_C ) |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
116 |
561 | 117 #define NGX_HAVE_ATOMIC_OPS 1 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
118 |
561 | 119 ngx_atomic_uint_t |
120 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
121 ngx_atomic_uint_t set); | |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
122 |
561 | 123 ngx_atomic_int_t |
124 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
125 |
1309 | 126 /* |
127 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
128 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il | |
129 */ | |
130 | |
131 void | |
132 ngx_cpu_pause(void); | |
133 | |
561 | 134 /* the code in src/os/unix/ngx_sunpro_amd64.il */ |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
135 |
563 | 136 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
137 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
138 |
561 | 139 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
140 |
561 | 141 #define NGX_HAVE_ATOMIC_OPS 1 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
142 |
561 | 143 #include "ngx_gcc_atomic_amd64.h" |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
144 |
561 | 145 #endif |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
146 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
300
diff
changeset
|
147 |
1308
63fa39cf8bd0
--with-cpu-opt=sparc32 and --with-cpu-opt=sparc64
Igor Sysoev <igor@sysoev.ru>
parents:
940
diff
changeset
|
148 #elif ( __sparc__ || __sparc || __sparcv9 ) |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
149 |
561 | 150 #if (NGX_PTR_SIZE == 8) |
151 | |
152 typedef int64_t ngx_atomic_int_t; | |
153 typedef uint64_t ngx_atomic_uint_t; | |
154 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
155 |
493 | 156 #else |
561 | 157 |
158 typedef int32_t ngx_atomic_int_t; | |
159 typedef uint32_t ngx_atomic_uint_t; | |
160 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 | |
161 | |
493 | 162 #endif |
163 | |
495 | 164 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
165 |
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
166 |
561 | 167 #if ( __SUNPRO_C ) |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
168 |
561 | 169 #define NGX_HAVE_ATOMIC_OPS 1 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
170 |
561 | 171 #include "ngx_sunpro_atomic_sparc64.h" |
493 | 172 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
173 |
561 | 174 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
493 | 175 |
561 | 176 #define NGX_HAVE_ATOMIC_OPS 1 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
177 |
561 | 178 #include "ngx_gcc_atomic_sparc64.h" |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
179 |
561 | 180 #endif |
493 | 181 |
182 | |
613 | 183 #elif ( __powerpc__ || __POWERPC__ ) |
493 | 184 |
185 #define NGX_HAVE_ATOMIC_OPS 1 | |
186 | |
187 #if (NGX_PTR_SIZE == 8) | |
561 | 188 |
189 typedef int64_t ngx_atomic_int_t; | |
190 typedef uint64_t ngx_atomic_uint_t; | |
191 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1 | |
192 | |
493 | 193 #else |
561 | 194 |
195 typedef int32_t ngx_atomic_int_t; | |
196 typedef uint32_t ngx_atomic_uint_t; | |
197 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 | |
198 | |
493 | 199 #endif |
200 | |
495 | 201 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
493 | 202 |
203 | |
561 | 204 #include "ngx_gcc_atomic_ppc.h" |
493 | 205 |
206 | |
561 | 207 #endif |
493 | 208 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
209 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
210 |
493 | 211 |
561 | 212 #if !(NGX_HAVE_ATOMIC_OPS) |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
213 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
214 #define NGX_HAVE_ATOMIC_OPS 0 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
215 |
561 | 216 typedef int32_t ngx_atomic_int_t; |
217 typedef uint32_t ngx_atomic_uint_t; | |
495 | 218 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 219 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
220 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
221 |
495 | 222 static ngx_inline ngx_atomic_uint_t |
223 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
224 ngx_atomic_uint_t set) | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
225 { |
571 | 226 if (*lock == old) { |
561 | 227 *lock = set; |
228 return 1; | |
229 } | |
230 | |
231 return 0; | |
232 } | |
233 | |
234 | |
235 static ngx_inline ngx_atomic_int_t | |
236 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) | |
237 { | |
238 ngx_atomic_int_t old; | |
239 | |
240 old = *value; | |
241 *value += add; | |
242 | |
243 return old; | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
244 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
245 |
571 | 246 #define ngx_memory_barrier() |
611 | 247 #define ngx_cpu_pause() |
571 | 248 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
249 #endif |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
251 |
611 | 252 void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin); |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
253 |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
254 #define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1)) |
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
255 #define ngx_unlock(lock) *(lock) = 0 |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
256 |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
257 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |