comparison src/os/unix/ngx_atomic.h @ 566:5c576ea5dbd9 NGINX_0_8_29

nginx 0.8.29 *) Change: now the "009" status code is written to an access log for proxied HTTP/0.9 responses. *) Feature: the "addition_types", "charset_types", "gzip_types", "ssi_types", "sub_filter_types", and "xslt_types" directives support an "*" parameter. *) Feature: GCC 4.1+ built-in atomic operations usage. Thanks to W-Mark Kubacki. *) Feature: the --with-libatomic[=DIR] option in the configure. Thanks to W-Mark Kubacki. *) Bugfix: listen unix domain socket had limited access rights. *) Bugfix: cached HTTP/0.9 responses were handled incorrectly. *) Bugfix: regular expression named captures given by "?P<...>" did not work in a "server_name" directive. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Nov 2009 00:00:00 +0300
parents 4c5d2c627a6c
children 25255878df91
comparison
equal deleted inserted replaced
565:63dde5a94756 566:5c576ea5dbd9
10 10
11 #include <ngx_config.h> 11 #include <ngx_config.h>
12 #include <ngx_core.h> 12 #include <ngx_core.h>
13 13
14 14
15 #if (NGX_DARWIN_ATOMIC) 15 #if (NGX_HAVE_LIBATOMIC)
16
17 #include <atomic_ops.h>
18
19 #define NGX_HAVE_ATOMIC_OPS 1
20
21 typedef long ngx_atomic_int_t;
22 typedef AO_t ngx_atomic_uint_t;
23 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
24
25 #if (NGX_PTR_SIZE == 8)
26 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
27 #else
28 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
29 #endif
30
31 #define ngx_atomic_cmp_set(lock, old, new) \
32 AO_compare_and_swap(lock, old, new)
33 #define ngx_atomic_fetch_add(value, add) \
34 AO_fetch_and_add(value, add)
35 #define ngx_memory_barrier() AO_nop()
36 #define ngx_cpu_pause()
37
38
39 #elif (NGX_DARWIN_ATOMIC)
16 40
17 /* 41 /*
18 * use Darwin 8 atomic(3) and barrier(3) operations 42 * use Darwin 8 atomic(3) and barrier(3) operations
19 * optimized at run-time for UP and SMP 43 * optimized at run-time for UP and SMP
20 */ 44 */
58 #define ngx_cpu_pause() 82 #define ngx_cpu_pause()
59 83
60 typedef volatile ngx_atomic_uint_t ngx_atomic_t; 84 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
61 85
62 86
63 #else /* !(NGX_DARWIN) */ 87 #elif (NGX_HAVE_GCC_ATOMIC)
64 88
65 89 /* GCC 4.1 builtin atomic operations */
66 #if ( __i386__ || __i386 ) 90
91 #define NGX_HAVE_ATOMIC_OPS 1
92
93 typedef long ngx_atomic_int_t;
94 typedef unsigned long ngx_atomic_uint_t;
95
96 #if (NGX_PTR_SIZE == 8)
97 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
98 #else
99 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
100 #endif
101
102 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
103
104
105 #define ngx_atomic_cmp_set(lock, old, set) \
106 __sync_bool_compare_and_swap(lock, old, set)
107
108 #define ngx_atomic_fetch_add(value, add) \
109 __sync_fetch_and_add(value, add)
110
111 #define ngx_memory_barrier() __sync_synchronize()
112
113 #if ( __i386__ || __i386 || __amd64__ || __amd64 )
114 #define ngx_cpu_pause() __asm__ ("pause")
115 #else
116 #define ngx_cpu_pause()
117 #endif
118
119
120 #elif ( __i386__ || __i386 )
67 121
68 typedef int32_t ngx_atomic_int_t; 122 typedef int32_t ngx_atomic_int_t;
69 typedef uint32_t ngx_atomic_uint_t; 123 typedef uint32_t ngx_atomic_uint_t;
70 typedef volatile ngx_atomic_uint_t ngx_atomic_t; 124 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
71 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) 125 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
200 254
201 typedef volatile ngx_atomic_uint_t ngx_atomic_t; 255 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
202 256
203 257
204 #include "ngx_gcc_atomic_ppc.h" 258 #include "ngx_gcc_atomic_ppc.h"
205
206
207 #endif
208 259
209 #endif 260 #endif
210 261
211 262
212 #if !(NGX_HAVE_ATOMIC_OPS) 263 #if !(NGX_HAVE_ATOMIC_OPS)