Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_atomic.h @ 5860:c9787372f16d
Limit conn: use complex value in limit_conn_zone (ticket #121).
One intentional side effect of this change is that key is allowed only
in the first position. Previously, it was possible to specify the key
variable at any position, but that was never documented, and is contrary
to nginx configuration practice for positional parameters.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 24 Sep 2014 21:55:19 +0400 |
parents | 4c36e15651f7 |
children | 2cd019520210 |
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 |
4412 | 4 * Copyright (C) Nginx, Inc. |
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
|
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 |
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
|
7 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #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
|
9 #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
|
10 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_config.h> |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 #include <ngx_core.h> |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
3363 | 16 #if (NGX_HAVE_LIBATOMIC) |
17 | |
3378
5d17022a1e88
fix libatomic usage on arm, cris, hppa, m68k, and sparc platforms
Igor Sysoev <igor@sysoev.ru>
parents:
3363
diff
changeset
|
18 #define AO_REQUIRE_CAS |
3363 | 19 #include <atomic_ops.h> |
20 | |
21 #define NGX_HAVE_ATOMIC_OPS 1 | |
22 | |
23 typedef long ngx_atomic_int_t; | |
24 typedef AO_t ngx_atomic_uint_t; | |
25 typedef volatile ngx_atomic_uint_t ngx_atomic_t; | |
26 | |
27 #if (NGX_PTR_SIZE == 8) | |
28 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) | |
29 #else | |
30 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) | |
31 #endif | |
32 | |
33 #define ngx_atomic_cmp_set(lock, old, new) \ | |
34 AO_compare_and_swap(lock, old, new) | |
35 #define ngx_atomic_fetch_add(value, add) \ | |
36 AO_fetch_and_add(value, add) | |
37 #define ngx_memory_barrier() AO_nop() | |
38 #define ngx_cpu_pause() | |
39 | |
40 | |
41 #elif (NGX_DARWIN_ATOMIC) | |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
42 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
43 /* |
940 | 44 * use Darwin 8 atomic(3) and barrier(3) operations |
45 * 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
|
46 */ |
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 #include <libkern/OSAtomic.h> |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
49 |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
50 /* "bool" conflicts with perl's CORE/handy.h */ |
4759
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
51 #if 0 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
52 #undef bool |
4759
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
53 #endif |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
54 |
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_HAVE_ATOMIC_OPS 1 |
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 #if (NGX_PTR_SIZE == 8) |
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 int64_t ngx_atomic_int_t; |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
61 typedef uint64_t ngx_atomic_uint_t; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
62 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
63 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
64 #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
|
65 OSAtomicCompareAndSwap64Barrier(old, new, (int64_t *) lock) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
66 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
67 #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
|
68 (OSAtomicAdd64(add, (int64_t *) value) - add) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
69 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
70 #else |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
71 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
72 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
|
73 typedef uint32_t ngx_atomic_uint_t; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
74 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
75 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
76 #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
|
77 OSAtomicCompareAndSwap32Barrier(old, new, (int32_t *) lock) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
78 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
79 #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
|
80 (OSAtomicAdd32(add, (int32_t *) value) - add) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
81 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
82 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
83 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
84 #define ngx_memory_barrier() OSMemoryBarrier() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
85 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
86 #define ngx_cpu_pause() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
87 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
88 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
|
89 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
90 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
91 #elif (NGX_HAVE_GCC_ATOMIC) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
92 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
93 /* GCC 4.1 builtin atomic operations */ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
94 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
95 #define NGX_HAVE_ATOMIC_OPS 1 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
96 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
97 typedef long ngx_atomic_int_t; |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
98 typedef unsigned long ngx_atomic_uint_t; |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
99 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
100 #if (NGX_PTR_SIZE == 8) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
101 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
102 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
103 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
104 #endif |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
105 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
106 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
107 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
108 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
109 #define ngx_atomic_cmp_set(lock, old, set) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
110 __sync_bool_compare_and_swap(lock, old, set) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
111 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
112 #define ngx_atomic_fetch_add(value, add) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
113 __sync_fetch_and_add(value, add) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
114 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
115 #define ngx_memory_barrier() __sync_synchronize() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
116 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
117 #if ( __i386__ || __i386 || __amd64__ || __amd64 ) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
118 #define ngx_cpu_pause() __asm__ ("pause") |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
119 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
120 #define ngx_cpu_pause() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
121 #endif |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
122 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
123 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
124 #elif ( __i386__ || __i386 ) |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
125 |
561 | 126 typedef int32_t ngx_atomic_int_t; |
127 typedef uint32_t ngx_atomic_uint_t; | |
495 | 128 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
129 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
493 | 130 |
131 | |
561 | 132 #if ( __SUNPRO_C ) |
493 | 133 |
561 | 134 #define NGX_HAVE_ATOMIC_OPS 1 |
493 | 135 |
561 | 136 ngx_atomic_uint_t |
137 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
138 ngx_atomic_uint_t set); | |
493 | 139 |
561 | 140 ngx_atomic_int_t |
141 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
493 | 142 |
1309 | 143 /* |
144 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
145 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il | |
146 */ | |
147 | |
148 void | |
149 ngx_cpu_pause(void); | |
150 | |
561 | 151 /* the code in src/os/unix/ngx_sunpro_x86.il */ |
493 | 152 |
563 | 153 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
154 | |
493 | 155 |
561 | 156 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
157 | |
158 #define NGX_HAVE_ATOMIC_OPS 1 | |
493 | 159 |
561 | 160 #include "ngx_gcc_atomic_x86.h" |
493 | 161 |
561 | 162 #endif |
493 | 163 |
164 | |
547 | 165 #elif ( __amd64__ || __amd64 ) |
493 | 166 |
561 | 167 typedef int64_t ngx_atomic_int_t; |
168 typedef uint64_t ngx_atomic_uint_t; | |
495 | 169 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
170 #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
|
171 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
172 |
561 | 173 #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
|
174 |
561 | 175 #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
|
176 |
561 | 177 ngx_atomic_uint_t |
178 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
179 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
|
180 |
561 | 181 ngx_atomic_int_t |
182 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
|
183 |
1309 | 184 /* |
185 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
186 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il | |
187 */ | |
188 | |
189 void | |
190 ngx_cpu_pause(void); | |
191 | |
561 | 192 /* 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
|
193 |
563 | 194 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
195 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
196 |
561 | 197 #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
|
198 |
561 | 199 #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
|
200 |
561 | 201 #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
|
202 |
561 | 203 #endif |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
204 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
300
diff
changeset
|
205 |
1308
63fa39cf8bd0
--with-cpu-opt=sparc32 and --with-cpu-opt=sparc64
Igor Sysoev <igor@sysoev.ru>
parents:
940
diff
changeset
|
206 #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
|
207 |
561 | 208 #if (NGX_PTR_SIZE == 8) |
209 | |
210 typedef int64_t ngx_atomic_int_t; | |
211 typedef uint64_t ngx_atomic_uint_t; | |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
212 #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
|
213 |
493 | 214 #else |
561 | 215 |
216 typedef int32_t ngx_atomic_int_t; | |
217 typedef uint32_t ngx_atomic_uint_t; | |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
218 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 219 |
493 | 220 #endif |
221 | |
495 | 222 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
|
223 |
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
224 |
561 | 225 #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
|
226 |
561 | 227 #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
|
228 |
561 | 229 #include "ngx_sunpro_atomic_sparc64.h" |
493 | 230 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
231 |
561 | 232 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
493 | 233 |
561 | 234 #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
|
235 |
561 | 236 #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
|
237 |
561 | 238 #endif |
493 | 239 |
240 | |
613 | 241 #elif ( __powerpc__ || __POWERPC__ ) |
493 | 242 |
243 #define NGX_HAVE_ATOMIC_OPS 1 | |
244 | |
245 #if (NGX_PTR_SIZE == 8) | |
561 | 246 |
247 typedef int64_t ngx_atomic_int_t; | |
248 typedef uint64_t ngx_atomic_uint_t; | |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
249 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
561 | 250 |
493 | 251 #else |
561 | 252 |
253 typedef int32_t ngx_atomic_int_t; | |
254 typedef uint32_t ngx_atomic_uint_t; | |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
255 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 256 |
493 | 257 #endif |
258 | |
495 | 259 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
493 | 260 |
261 | |
561 | 262 #include "ngx_gcc_atomic_ppc.h" |
493 | 263 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
264 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
265 |
493 | 266 |
561 | 267 #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
|
268 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
269 #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
|
270 |
561 | 271 typedef int32_t ngx_atomic_int_t; |
272 typedef uint32_t ngx_atomic_uint_t; | |
495 | 273 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
274 #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
|
275 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
276 |
495 | 277 static ngx_inline ngx_atomic_uint_t |
278 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
279 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
|
280 { |
571 | 281 if (*lock == old) { |
561 | 282 *lock = set; |
283 return 1; | |
284 } | |
285 | |
286 return 0; | |
287 } | |
288 | |
289 | |
290 static ngx_inline ngx_atomic_int_t | |
291 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) | |
292 { | |
293 ngx_atomic_int_t old; | |
294 | |
295 old = *value; | |
296 *value += add; | |
297 | |
298 return old; | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
299 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
300 |
571 | 301 #define ngx_memory_barrier() |
611 | 302 #define ngx_cpu_pause() |
571 | 303 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
304 #endif |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
306 |
611 | 307 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
|
308 |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
309 #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
|
310 #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
|
311 |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
312 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
313 #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |