Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_atomic.h @ 599:869b6444d234 release-0.3.21
nginx-0.3.21-RELEASE import
*) Feature: the ngx_http_perl_module.
*) Change: the "valid_referers" directive allows the referreres without
URI part.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 16 Jan 2006 14:56:53 +0000 |
parents | 458b6c3fea65 |
children | 3f8a2132b93d |
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 |
547 | 15 #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
|
16 |
561 | 17 typedef int32_t ngx_atomic_int_t; |
18 typedef uint32_t ngx_atomic_uint_t; | |
495 | 19 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 20 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 |
493 | 21 |
22 | |
561 | 23 #if ( __SUNPRO_C ) |
493 | 24 |
561 | 25 #define NGX_HAVE_ATOMIC_OPS 1 |
493 | 26 |
561 | 27 ngx_atomic_uint_t |
28 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
29 ngx_atomic_uint_t set); | |
493 | 30 |
561 | 31 ngx_atomic_int_t |
32 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
493 | 33 |
561 | 34 /* the code in src/os/unix/ngx_sunpro_x86.il */ |
493 | 35 |
563 | 36 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
37 | |
493 | 38 |
561 | 39 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
40 | |
41 #define NGX_HAVE_ATOMIC_OPS 1 | |
493 | 42 |
561 | 43 #include "ngx_gcc_atomic_x86.h" |
493 | 44 |
561 | 45 #endif |
493 | 46 |
47 | |
547 | 48 #elif ( __amd64__ || __amd64 ) |
493 | 49 |
561 | 50 typedef int64_t ngx_atomic_int_t; |
51 typedef uint64_t ngx_atomic_uint_t; | |
495 | 52 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 53 #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
|
54 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
55 |
561 | 56 #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
|
57 |
561 | 58 #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
|
59 |
561 | 60 ngx_atomic_uint_t |
61 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
62 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
|
63 |
561 | 64 ngx_atomic_int_t |
65 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
|
66 |
561 | 67 /* 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
|
68 |
563 | 69 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
70 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
71 |
561 | 72 #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
|
73 |
561 | 74 #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
|
75 |
561 | 76 #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
|
77 |
561 | 78 #endif |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
79 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
300
diff
changeset
|
80 |
547 | 81 #elif ( __sparc__ || __sparcv9 ) |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
82 |
561 | 83 #if (NGX_PTR_SIZE == 8) |
84 | |
85 typedef int64_t ngx_atomic_int_t; | |
86 typedef uint64_t ngx_atomic_uint_t; | |
87 #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
|
88 |
493 | 89 #else |
561 | 90 |
91 typedef int32_t ngx_atomic_int_t; | |
92 typedef uint32_t ngx_atomic_uint_t; | |
93 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 | |
94 | |
493 | 95 #endif |
96 | |
495 | 97 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
|
98 |
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
99 |
561 | 100 #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
|
101 |
561 | 102 #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
|
103 |
561 | 104 #include "ngx_sunpro_atomic_sparc64.h" |
493 | 105 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
106 |
561 | 107 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
493 | 108 |
561 | 109 #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
|
110 |
561 | 111 #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
|
112 |
561 | 113 #endif |
493 | 114 |
115 | |
525 | 116 #elif ( __ppc__ || __powerpc__ ) |
493 | 117 |
118 #define NGX_HAVE_ATOMIC_OPS 1 | |
119 | |
120 #if (NGX_PTR_SIZE == 8) | |
561 | 121 |
122 typedef int64_t ngx_atomic_int_t; | |
123 typedef uint64_t ngx_atomic_uint_t; | |
124 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1 | |
125 | |
493 | 126 #else |
561 | 127 |
128 typedef int32_t ngx_atomic_int_t; | |
129 typedef uint32_t ngx_atomic_uint_t; | |
130 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 | |
131 | |
493 | 132 #endif |
133 | |
495 | 134 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
493 | 135 |
136 | |
561 | 137 #include "ngx_gcc_atomic_ppc.h" |
493 | 138 |
139 | |
561 | 140 #endif |
493 | 141 |
142 | |
561 | 143 #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
|
144 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
145 #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
|
146 |
561 | 147 typedef int32_t ngx_atomic_int_t; |
148 typedef uint32_t ngx_atomic_uint_t; | |
495 | 149 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
561 | 150 #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
|
151 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
152 |
495 | 153 static ngx_inline ngx_atomic_uint_t |
154 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
155 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
|
156 { |
571 | 157 if (*lock == old) { |
561 | 158 *lock = set; |
159 return 1; | |
160 } | |
161 | |
162 return 0; | |
163 } | |
164 | |
165 | |
166 static ngx_inline ngx_atomic_int_t | |
167 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) | |
168 { | |
169 ngx_atomic_int_t old; | |
170 | |
171 old = *value; | |
172 *value += add; | |
173 | |
174 return old; | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
175 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
176 |
571 | 177 #define ngx_memory_barrier() |
178 | |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
179 #endif |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
181 void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin); |
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
182 |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
183 #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
|
184 #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
|
185 |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
186 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |