annotate src/os/unix/ngx_atomic.h @ 162:6be073125f2e NGINX_0_3_28

nginx 0.3.28 *) Feature: the "restrict_host_names" directive was canceled. *) Feature: the --with-cpu-opt=ppc64 configuration parameter. *) Bugfix: on some condition the proxied connection with a client was terminated prematurely. Thanks to Vladimir Shutoff. *) Bugfix: the "X-Accel-Limit-Rate" header line was not taken into account if the request was redirected using the "X-Accel-Redirect" header line. *) Bugfix: the "post_action" directive ran only after a successful completion of a request. *) Bugfix: the proxied response body generated by the "post_action" directive was transferred to a client.
author Igor Sysoev <http://sysoev.ru>
date Thu, 16 Feb 2006 00:00:00 +0300
parents 73e8476f9142
children 6eb1e38f0f1f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #ifndef _NGX_ATOMIC_H_INCLUDED_
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #define _NGX_ATOMIC_H_INCLUDED_
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11 #include <ngx_config.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 #include <ngx_core.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 74
diff changeset
15 #if ( __i386__ || __i386 )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
17 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
18 typedef uint32_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
19 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
20 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
21
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
22
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
23 #if ( __SUNPRO_C )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
24
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
25 #define NGX_HAVE_ATOMIC_OPS 1
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
26
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
27 ngx_atomic_uint_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
28 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
29 ngx_atomic_uint_t set);
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
30
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
31 ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
32 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
33
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
34 /* the code in src/os/unix/ngx_sunpro_x86.il */
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
35
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
36 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
37 #define ngx_cpu_pause() __asm ("pause")
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
38
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
39
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
40 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
41
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
42 #define NGX_HAVE_ATOMIC_OPS 1
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
43
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
44 #include "ngx_gcc_atomic_x86.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
45
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
46 #endif
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
47
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
48
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 74
diff changeset
49 #elif ( __amd64__ || __amd64 )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
50
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
51 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
52 typedef uint64_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
53 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
54 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
57 #if ( __SUNPRO_C )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
59 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
61 ngx_atomic_uint_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
62 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
63 ngx_atomic_uint_t set);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
64
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
65 ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
66 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
67
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
68 /* the code in src/os/unix/ngx_sunpro_amd64.il */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
69
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
70 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
71 #define ngx_cpu_pause() __asm ("pause")
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
72
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
74 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
75
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
76 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
77
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
78 #include "ngx_gcc_atomic_amd64.h"
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
79
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
80 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
82
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 74
diff changeset
83 #elif ( __sparc__ || __sparcv9 )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
85 #if (NGX_PTR_SIZE == 8)
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
86
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
87 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
88 typedef uint64_t ngx_atomic_uint_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
89 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
90
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
91 #else
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
92
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
93 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
94 typedef uint32_t ngx_atomic_uint_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
95 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
96
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
97 #endif
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
98
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
99 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
100
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
101
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
102 #if ( __SUNPRO_C )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
103
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
104 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
105
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
106 #include "ngx_sunpro_atomic_sparc64.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
107
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
108
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
109 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
110
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
111 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
112
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
113 #include "ngx_gcc_atomic_sparc64.h"
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
114
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
115 #endif
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
116
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
117
162
6be073125f2e nginx 0.3.28
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
118 #elif ( __powerpc__ || __POWERPC__ )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
119
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
120 #define NGX_HAVE_ATOMIC_OPS 1
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
121
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
122 #if (NGX_PTR_SIZE == 8)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
123
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
124 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
125 typedef uint64_t ngx_atomic_uint_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
126 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
127
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
128 #else
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
129
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
130 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
131 typedef uint32_t ngx_atomic_uint_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
132 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
133
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
134 #endif
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
135
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
136 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
137
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
138
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
139 #include "ngx_gcc_atomic_ppc.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
140
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
141
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
142 #endif
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
143
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
144
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
145 #if !(NGX_HAVE_ATOMIC_OPS)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
146
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
147 #define NGX_HAVE_ATOMIC_OPS 0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
148
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
149 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
150 typedef uint32_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
151 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
152 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
153
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
154
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
155 static ngx_inline ngx_atomic_uint_t
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
156 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
157 ngx_atomic_uint_t set)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
158 {
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
159 if (*lock == old) {
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
160 *lock = set;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
161 return 1;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
162 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
163
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
164 return 0;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
165 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
166
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
167
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
168 static ngx_inline ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
169 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
170 {
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
171 ngx_atomic_int_t old;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
172
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
173 old = *value;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
174 *value += add;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
175
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
176 return old;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
177 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
178
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
179 #define ngx_memory_barrier()
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
180 #define ngx_cpu_pause()
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
181
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
183
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
184 void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
185
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
186 #define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
187 #define ngx_unlock(lock) *(lock) = 0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
188
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
189
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
190 #endif /* _NGX_ATOMIC_H_INCLUDED_ */