annotate src/os/unix/ngx_atomic.h @ 660:d0f7a625f27c NGINX_1_1_14

nginx 1.1.14 *) Feature: multiple "limit_req" limits may be used simultaneously. *) Bugfix: in error handling while connecting to a backend. Thanks to Piotr Sikora. *) Bugfix: in AIO error handling on FreeBSD. *) Bugfix: in the OpenSSL library initialization. *) Bugfix: the "proxy_redirect" directives might not be correctly inherited. *) Bugfix: memory leak during reconfiguration if the "pcre_jit" directive was used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Jan 2012 00:00:00 +0400
parents 25255878df91
children 5cb5db9975ba
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
660
d0f7a625f27c nginx 1.1.14
Igor Sysoev <http://sysoev.ru>
parents: 556
diff changeset
4 * Copyright (C) Nginx, Inc.
0
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
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_ATOMIC_H_INCLUDED_
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #define _NGX_ATOMIC_H_INCLUDED_
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
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 #include <ngx_config.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 #include <ngx_core.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
15
554
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
16 #if (NGX_HAVE_LIBATOMIC)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
17
556
25255878df91 nginx 0.8.30
Igor Sysoev <http://sysoev.ru>
parents: 554
diff changeset
18 #define AO_REQUIRE_CAS
554
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
19 #include <atomic_ops.h>
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
20
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
21 #define NGX_HAVE_ATOMIC_OPS 1
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
22
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
23 typedef long ngx_atomic_int_t;
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
24 typedef AO_t ngx_atomic_uint_t;
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
25 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
26
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
27 #if (NGX_PTR_SIZE == 8)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
28 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
29 #else
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
30 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
31 #endif
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
32
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
33 #define ngx_atomic_cmp_set(lock, old, new) \
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
34 AO_compare_and_swap(lock, old, new)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
35 #define ngx_atomic_fetch_add(value, add) \
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
36 AO_fetch_and_add(value, add)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
37 #define ngx_memory_barrier() AO_nop()
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
38 #define ngx_cpu_pause()
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
39
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
40
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
41 #elif (NGX_DARWIN_ATOMIC)
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
42
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
43 /*
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
44 * use Darwin 8 atomic(3) and barrier(3) operations
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
45 * optimized at run-time for UP and SMP
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
46 */
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
47
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
48 #include <libkern/OSAtomic.h>
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
49
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
50 /* "bool" conflicts with perl's CORE/handy.h */
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
51 #undef bool
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
52
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
53
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
54 #define NGX_HAVE_ATOMIC_OPS 1
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
55
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
56 #if (NGX_PTR_SIZE == 8)
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
57
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
58 typedef int64_t ngx_atomic_int_t;
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
59 typedef uint64_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
60 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
61
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
62 #define ngx_atomic_cmp_set(lock, old, new) \
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
63 OSAtomicCompareAndSwap64Barrier(old, new, (int64_t *) lock)
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
64
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
65 #define ngx_atomic_fetch_add(value, add) \
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
66 (OSAtomicAdd64(add, (int64_t *) value) - add)
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
67
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
68 #else
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
69
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
70 typedef int32_t ngx_atomic_int_t;
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
71 typedef uint32_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
72 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
73
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
74 #define ngx_atomic_cmp_set(lock, old, new) \
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
75 OSAtomicCompareAndSwap32Barrier(old, new, (int32_t *) lock)
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
76
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
77 #define ngx_atomic_fetch_add(value, add) \
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
78 (OSAtomicAdd32(add, (int32_t *) value) - add)
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
79
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
80 #endif
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
81
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
82 #define ngx_memory_barrier() OSMemoryBarrier()
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
83
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
84 #define ngx_cpu_pause()
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
85
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
86 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
87
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
88
554
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
89 #elif (NGX_HAVE_GCC_ATOMIC)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
90
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
91 /* GCC 4.1 builtin atomic operations */
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
92
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
93 #define NGX_HAVE_ATOMIC_OPS 1
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
94
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
95 typedef long ngx_atomic_int_t;
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
96 typedef unsigned long ngx_atomic_uint_t;
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
97
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
98 #if (NGX_PTR_SIZE == 8)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
99 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
100 #else
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
101 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
102 #endif
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
103
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
104 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
105
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
106
554
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
107 #define ngx_atomic_cmp_set(lock, old, set) \
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
108 __sync_bool_compare_and_swap(lock, old, set)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
109
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
110 #define ngx_atomic_fetch_add(value, add) \
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
111 __sync_fetch_and_add(value, add)
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
112
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
113 #define ngx_memory_barrier() __sync_synchronize()
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
114
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
115 #if ( __i386__ || __i386 || __amd64__ || __amd64 )
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
116 #define ngx_cpu_pause() __asm__ ("pause")
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
117 #else
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
118 #define ngx_cpu_pause()
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
119 #endif
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
120
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
121
5c576ea5dbd9 nginx 0.8.29
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
122 #elif ( __i386__ || __i386 )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
123
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
124 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
125 typedef uint32_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
126 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
127 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
128
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
129
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
130 #if ( __SUNPRO_C )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
131
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
132 #define NGX_HAVE_ATOMIC_OPS 1
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
133
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
134 ngx_atomic_uint_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
135 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
136 ngx_atomic_uint_t set);
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
137
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
138 ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
139 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
140
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
141 /*
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
142 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")',
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
143 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
144 */
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
145
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
146 void
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
147 ngx_cpu_pause(void);
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
148
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
149 /* 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
150
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
151 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
152
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
153
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
154 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
155
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
156 #define NGX_HAVE_ATOMIC_OPS 1
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
157
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
158 #include "ngx_gcc_atomic_x86.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
159
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
160 #endif
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
161
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
162
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 74
diff changeset
163 #elif ( __amd64__ || __amd64 )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
164
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
165 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
166 typedef uint64_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
167 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
168 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
169
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
170
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
171 #if ( __SUNPRO_C )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
172
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
173 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
174
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
175 ngx_atomic_uint_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
176 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
177 ngx_atomic_uint_t set);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
178
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
179 ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
180 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
181
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
182 /*
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
183 * Sun Studio 12 exits with segmentation fault on '__asm ("pause")',
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
184 * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
185 */
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
186
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
187 void
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
188 ngx_cpu_pause(void);
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
189
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
190 /* the code in src/os/unix/ngx_sunpro_amd64.il */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
191
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
192 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
193
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
194
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
195 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
196
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
197 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
198
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
199 #include "ngx_gcc_atomic_amd64.h"
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
200
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
201 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
202
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
203
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
204 #elif ( __sparc__ || __sparc || __sparcv9 )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
205
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
206 #if (NGX_PTR_SIZE == 8)
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
207
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
208 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
209 typedef uint64_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
210 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
211
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
212 #else
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
213
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
214 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
215 typedef uint32_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
216 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
217
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
218 #endif
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
219
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
220 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
221
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
222
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
223 #if ( __SUNPRO_C )
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
224
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
225 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
226
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
227 #include "ngx_sunpro_atomic_sparc64.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
228
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
229
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
230 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
231
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
232 #define NGX_HAVE_ATOMIC_OPS 1
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
233
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
234 #include "ngx_gcc_atomic_sparc64.h"
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
235
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
236 #endif
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
237
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
238
162
6be073125f2e nginx 0.3.28
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
239 #elif ( __powerpc__ || __POWERPC__ )
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
240
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
241 #define NGX_HAVE_ATOMIC_OPS 1
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
242
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
243 #if (NGX_PTR_SIZE == 8)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
244
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
245 typedef int64_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
246 typedef uint64_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
247 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
248
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
249 #else
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
250
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
251 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
252 typedef uint32_t ngx_atomic_uint_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
253 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
254
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
255 #endif
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
256
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
257 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
258
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
259
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
260 #include "ngx_gcc_atomic_ppc.h"
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
261
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
262 #endif
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
263
42
41ccba1aba45 nginx 0.1.21
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
264
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
265 #if !(NGX_HAVE_ATOMIC_OPS)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
266
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
267 #define NGX_HAVE_ATOMIC_OPS 0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
268
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
269 typedef int32_t ngx_atomic_int_t;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
270 typedef uint32_t ngx_atomic_uint_t;
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
271 typedef volatile ngx_atomic_uint_t ngx_atomic_t;
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
272 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
273
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
274
44
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
275 static ngx_inline ngx_atomic_uint_t
4989c3d25945 nginx 0.1.22
Igor Sysoev <http://sysoev.ru>
parents: 42
diff changeset
276 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
277 ngx_atomic_uint_t set)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
278 {
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
279 if (*lock == old) {
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
280 *lock = set;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
281 return 1;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
282 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
283
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
284 return 0;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
285 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
286
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
287
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
288 static ngx_inline ngx_atomic_int_t
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
289 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
290 {
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
291 ngx_atomic_int_t old;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
292
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
293 old = *value;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
294 *value += add;
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
295
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 100
diff changeset
296 return old;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
297 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
298
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
299 #define ngx_memory_barrier()
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
300 #define ngx_cpu_pause()
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
301
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
302 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
303
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
304
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
305 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
306
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
307 #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
308 #define ngx_unlock(lock) *(lock) = 0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
309
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
310
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
311 #endif /* _NGX_ATOMIC_H_INCLUDED_ */