Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_atomic.h @ 3362:b57a4a704f3c
GCC 4.1 builtin atomic operations
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 25 Nov 2009 17:34:35 +0000 |
parents | 7658e9c7e814 |
children | b4aa418af6ef |
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; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
34 #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
|
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; |
3165
7658e9c7e814
use parents around NGX_ATOMIC_T_LEN value
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
46 #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
|
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 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
63 #elif (NGX_HAVE_GCC_ATOMIC) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
64 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
65 /* GCC 4.1 builtin atomic operations */ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
66 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
67 #define NGX_HAVE_ATOMIC_OPS 1 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
68 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
69 typedef long ngx_atomic_int_t; |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
70 typedef unsigned long ngx_atomic_uint_t; |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
71 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
72 #if (NGX_PTR_SIZE == 8) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
73 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
74 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
75 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
76 #endif |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
77 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
78 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
|
79 |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
80 |
3362
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
81 #define ngx_atomic_cmp_set(lock, old, set) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
82 __sync_bool_compare_and_swap(lock, old, set) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
83 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
84 #define ngx_atomic_fetch_add(value, add) \ |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
85 __sync_fetch_and_add(value, add) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
86 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
87 #define ngx_memory_barrier() __sync_synchronize() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
88 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
89 #if ( __i386__ || __i386 || __amd64__ || __amd64 ) |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
90 #define ngx_cpu_pause() __asm__ ("pause") |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
91 #else |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
92 #define ngx_cpu_pause() |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
93 #endif |
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 |
b57a4a704f3c
GCC 4.1 builtin atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
3165
diff
changeset
|
96 #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
|
97 |
561 | 98 typedef int32_t ngx_atomic_int_t; |
99 typedef uint32_t ngx_atomic_uint_t; | |
495 | 100 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
|
101 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
493 | 102 |
103 | |
561 | 104 #if ( __SUNPRO_C ) |
493 | 105 |
561 | 106 #define NGX_HAVE_ATOMIC_OPS 1 |
493 | 107 |
561 | 108 ngx_atomic_uint_t |
109 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
110 ngx_atomic_uint_t set); | |
493 | 111 |
561 | 112 ngx_atomic_int_t |
113 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); | |
493 | 114 |
1309 | 115 /* |
116 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
117 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il | |
118 */ | |
119 | |
120 void | |
121 ngx_cpu_pause(void); | |
122 | |
561 | 123 /* the code in src/os/unix/ngx_sunpro_x86.il */ |
493 | 124 |
563 | 125 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
126 | |
493 | 127 |
561 | 128 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
129 | |
130 #define NGX_HAVE_ATOMIC_OPS 1 | |
493 | 131 |
561 | 132 #include "ngx_gcc_atomic_x86.h" |
493 | 133 |
561 | 134 #endif |
493 | 135 |
136 | |
547 | 137 #elif ( __amd64__ || __amd64 ) |
493 | 138 |
561 | 139 typedef int64_t ngx_atomic_int_t; |
140 typedef uint64_t ngx_atomic_uint_t; | |
495 | 141 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
|
142 #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
|
143 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
144 |
561 | 145 #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
|
146 |
561 | 147 #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
|
148 |
561 | 149 ngx_atomic_uint_t |
150 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
151 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
|
152 |
561 | 153 ngx_atomic_int_t |
154 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
|
155 |
1309 | 156 /* |
157 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
158 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il | |
159 */ | |
160 | |
161 void | |
162 ngx_cpu_pause(void); | |
163 | |
561 | 164 /* 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
|
165 |
563 | 166 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
167 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
168 |
561 | 169 #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
|
170 |
561 | 171 #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
|
172 |
561 | 173 #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
|
174 |
561 | 175 #endif |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
176 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
300
diff
changeset
|
177 |
1308
63fa39cf8bd0
--with-cpu-opt=sparc32 and --with-cpu-opt=sparc64
Igor Sysoev <igor@sysoev.ru>
parents:
940
diff
changeset
|
178 #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
|
179 |
561 | 180 #if (NGX_PTR_SIZE == 8) |
181 | |
182 typedef int64_t ngx_atomic_int_t; | |
183 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
|
184 #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
|
185 |
493 | 186 #else |
561 | 187 |
188 typedef int32_t ngx_atomic_int_t; | |
189 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
|
190 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 191 |
493 | 192 #endif |
193 | |
495 | 194 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
|
195 |
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
196 |
561 | 197 #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
|
198 |
561 | 199 #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
|
200 |
561 | 201 #include "ngx_sunpro_atomic_sparc64.h" |
493 | 202 |
425
bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
203 |
561 | 204 #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
493 | 205 |
561 | 206 #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
|
207 |
561 | 208 #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
|
209 |
561 | 210 #endif |
493 | 211 |
212 | |
613 | 213 #elif ( __powerpc__ || __POWERPC__ ) |
493 | 214 |
215 #define NGX_HAVE_ATOMIC_OPS 1 | |
216 | |
217 #if (NGX_PTR_SIZE == 8) | |
561 | 218 |
219 typedef int64_t ngx_atomic_int_t; | |
220 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
|
221 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) |
561 | 222 |
493 | 223 #else |
561 | 224 |
225 typedef int32_t ngx_atomic_int_t; | |
226 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
|
227 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) |
561 | 228 |
493 | 229 #endif |
230 | |
495 | 231 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
493 | 232 |
233 | |
561 | 234 #include "ngx_gcc_atomic_ppc.h" |
493 | 235 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
236 #endif |
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
237 |
493 | 238 |
561 | 239 #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
|
240 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
241 #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
|
242 |
561 | 243 typedef int32_t ngx_atomic_int_t; |
244 typedef uint32_t ngx_atomic_uint_t; | |
495 | 245 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
|
246 #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
|
247 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
248 |
495 | 249 static ngx_inline ngx_atomic_uint_t |
250 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, | |
251 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
|
252 { |
571 | 253 if (*lock == old) { |
561 | 254 *lock = set; |
255 return 1; | |
256 } | |
257 | |
258 return 0; | |
259 } | |
260 | |
261 | |
262 static ngx_inline ngx_atomic_int_t | |
263 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) | |
264 { | |
265 ngx_atomic_int_t old; | |
266 | |
267 old = *value; | |
268 *value += add; | |
269 | |
270 return old; | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
271 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
272 |
571 | 273 #define ngx_memory_barrier() |
611 | 274 #define ngx_cpu_pause() |
571 | 275 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
276 #endif |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 |
939
782cf4c13b8d
use MacOSX atomic(3) and barrier(3) operations
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
278 |
611 | 279 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
|
280 |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
281 #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
|
282 #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
|
283 |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
302
diff
changeset
|
284 |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |