Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_atomic.h @ 4016:b044d6553d52
Move SO_ACCEPTFILTER and TCP_DEFER_ACCEPT checks into configure.
NetBSD 5.0+ has SO_ACCEPTFILTER support merged from FreeBSD, and having
accept filter check in FreeBSD-specific ngx_freebsd_config.h prevents it
from being used on NetBSD. Therefore move the check into configure (and
do the same for Linux-specific TCP_DEFER_ACCEPT, just to be in line).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 21 Aug 2011 11:37:37 +0000 |
parents | 5d17022a1e88 |
children | d620f497c50f |
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 |
3363 | 15 #if (NGX_HAVE_LIBATOMIC) |
16 | |
3378
5d17022a1e88
fix libatomic usage on arm, cris, hppa, m68k, and sparc platforms
Igor Sysoev <igor@sysoev.ru>
parents:
3363
diff
changeset
|
17 #define AO_REQUIRE_CAS |
3363 | 18 #include <atomic_ops.h> |
19 | |
20 #define NGX_HAVE_ATOMIC_OPS 1 | |
21 | |
22 typedef long ngx_atomic_int_t; | |
23 typedef AO_t ngx_atomic_uint_t; | |
24 typedef volatile ngx_atomic_uint_t ngx_atomic_t; | |
25 | |
26 #if (NGX_PTR_SIZE == 8) | |
27 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) | |
28 #else | |
29 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) | |
30 #endif | |
31 | |
32 #define ngx_atomic_cmp_set(lock, old, new) \ | |
33 AO_compare_and_swap(lock, old, new) | |
34 #define ngx_atomic_fetch_add(value, add) \ | |
35 AO_fetch_and_add(value, add) | |
36 #define ngx_memory_barrier() AO_nop() | |
37 #define ngx_cpu_pause() | |
38 | |
39 | |
40 #elif (NGX_DARWIN_ATOMIC) | |
939
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 /* |
940 | 43 * use Darwin 8 atomic(3) and barrier(3) operations |
44 * 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
|
45 */ |
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 #include <libkern/OSAtomic.h> |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
48 |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
1309
diff
changeset
|
49 /* "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
|
50 #undef bool |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
51 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
52 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
53 #define NGX_HAVE_ATOMIC_OPS 1 |
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 #if (NGX_PTR_SIZE == 8) |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
56 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
57 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
|
58 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
|
59 #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
|
60 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
61 #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
|
62 OSAtomicCompareAndSwap64Barrier(old, new, (int64_t *) lock) |
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_fetch_add(value, add) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
65 (OSAtomicAdd64(add, (int64_t *) value) - add) |
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 #else |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
68 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
69 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
|
70 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
|
71 #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
|
72 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
73 #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
|
74 OSAtomicCompareAndSwap32Barrier(old, new, (int32_t *) lock) |
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_fetch_add(value, add) \ |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
77 (OSAtomicAdd32(add, (int32_t *) value) - add) |
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 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
80 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
81 #define ngx_memory_barrier() OSMemoryBarrier() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
82 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
83 #define ngx_cpu_pause() |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
84 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
85 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
|
86 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
87 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
88 #elif (NGX_HAVE_GCC_ATOMIC) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
89 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
90 /* GCC 4.1 builtin atomic operations */ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
91 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
92 #define NGX_HAVE_ATOMIC_OPS 1 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
93 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
94 typedef long ngx_atomic_int_t; |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
95 typedef unsigned long ngx_atomic_uint_t; |
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 #if (NGX_PTR_SIZE == 8) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
98 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
99 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
100 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
101 #endif |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
102 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
103 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
|
104 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
105 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
106 #define ngx_atomic_cmp_set(lock, old, set) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
107 __sync_bool_compare_and_swap(lock, old, set) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
108 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
109 #define ngx_atomic_fetch_add(value, add) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
110 __sync_fetch_and_add(value, add) |
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_memory_barrier() __sync_synchronize() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
113 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
114 #if ( __i386__ || __i386 || __amd64__ || __amd64 ) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
115 #define ngx_cpu_pause() __asm__ ("pause") |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
116 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
117 #define ngx_cpu_pause() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
118 #endif |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
119 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
120 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
121 #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
|
122 |
561 | 123 typedef int32_t ngx_atomic_int_t; |
124 typedef uint32_t ngx_atomic_uint_t; | |
495 | 125 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
|
126 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
493 | 127 |
128 | |
561 | 129 #if ( __SUNPRO_C ) |
493 | 130 |
561 | 131 #define NGX_HAVE_ATOMIC_OPS 1 |
493 | 132 |
561 | 133 ngx_atomic_uint_t |
134 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
135 ngx_atomic_uint_t set); | |
493 | 136 |
561 | 137 ngx_atomic_int_t |
138 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
493 | 139 |
1309 | 140 /* |
141 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
142 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il | |
143 */ | |
144 | |
145 void | |
146 ngx_cpu_pause(void); | |
147 | |
561 | 148 /* the code in src/os/unix/ngx_sunpro_x86.il */ |
493 | 149 |
563 | 150 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
151 | |
493 | 152 |
561 | 153 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
154 | |
155 #define NGX_HAVE_ATOMIC_OPS 1 | |
493 | 156 |
561 | 157 #include "ngx_gcc_atomic_x86.h" |
493 | 158 |
561 | 159 #endif |
493 | 160 |
161 | |
547 | 162 #elif ( __amd64__ || __amd64 ) |
493 | 163 |
561 | 164 typedef int64_t ngx_atomic_int_t; |
165 typedef uint64_t ngx_atomic_uint_t; | |
495 | 166 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
|
167 #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
|
168 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
169 |
561 | 170 #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
|
171 |
561 | 172 #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
|
173 |
561 | 174 ngx_atomic_uint_t |
175 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
176 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
|
177 |
561 | 178 ngx_atomic_int_t |
179 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
|
180 |
1309 | 181 /* |
182 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
183 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il | |
184 */ | |
185 | |
186 void | |
187 ngx_cpu_pause(void); | |
188 | |
561 | 189 /* 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
|
190 |
563 | 191 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
192 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
193 |
561 | 194 #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
|
195 |
561 | 196 #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
|
197 |
561 | 198 #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
|
199 |
561 | 200 #endif |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
201 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
300
diff
changeset
|
202 |
1308
63fa39cf8bd0
--with-cpu-opt=sparc32 and --with-cpu-opt=sparc64
Igor Sysoev <igor@sysoev.ru>
parents:
940
diff
changeset
|
203 #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
|
204 |
561 | 205 #if (NGX_PTR_SIZE == 8) |
206 | |
207 typedef int64_t ngx_atomic_int_t; | |
208 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
|
209 #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
|
210 |
493 | 211 #else |
561 | 212 |
213 typedef int32_t ngx_atomic_int_t; | |
214 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
|
215 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 216 |
493 | 217 #endif |
218 | |
495 | 219 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
|
220 |
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
221 |
561 | 222 #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
|
223 |
561 | 224 #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
|
225 |
561 | 226 #include "ngx_sunpro_atomic_sparc64.h" |
493 | 227 |
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 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
493 | 230 |
561 | 231 #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
|
232 |
561 | 233 #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
|
234 |
561 | 235 #endif |
493 | 236 |
237 | |
613 | 238 #elif ( __powerpc__ || __POWERPC__ ) |
493 | 239 |
240 #define NGX_HAVE_ATOMIC_OPS 1 | |
241 | |
242 #if (NGX_PTR_SIZE == 8) | |
561 | 243 |
244 typedef int64_t ngx_atomic_int_t; | |
245 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
|
246 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
561 | 247 |
493 | 248 #else |
561 | 249 |
250 typedef int32_t ngx_atomic_int_t; | |
251 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
|
252 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 253 |
493 | 254 #endif |
255 | |
495 | 256 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
493 | 257 |
258 | |
561 | 259 #include "ngx_gcc_atomic_ppc.h" |
493 | 260 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
261 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
262 |
493 | 263 |
561 | 264 #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
|
265 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
266 #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
|
267 |
561 | 268 typedef int32_t ngx_atomic_int_t; |
269 typedef uint32_t ngx_atomic_uint_t; | |
495 | 270 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
|
271 #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
|
272 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
273 |
495 | 274 static ngx_inline ngx_atomic_uint_t |
275 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
276 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
|
277 { |
571 | 278 if (*lock == old) { |
561 | 279 *lock = set; |
280 return 1; | |
281 } | |
282 | |
283 return 0; | |
284 } | |
285 | |
286 | |
287 static ngx_inline ngx_atomic_int_t | |
288 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) | |
289 { | |
290 ngx_atomic_int_t old; | |
291 | |
292 old = *value; | |
293 *value += add; | |
294 | |
295 return old; | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
296 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
297 |
571 | 298 #define ngx_memory_barrier() |
611 | 299 #define ngx_cpu_pause() |
571 | 300 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
301 #endif |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
303 |
611 | 304 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
|
305 |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
306 #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
|
307 #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
|
308 |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
309 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |