Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_atomic.h @ 8589:09d15a2dbc6b
Give GCC atomics precedence over deprecated Darwin atomic(3).
This allows to build nginx on macOS with -Wdeprecated-declarations.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 30 Aug 2021 14:45:21 +0300 |
parents | 2cd019520210 |
children |
comparison
equal
deleted
inserted
replaced
8588:9cf043a5d9ca | 8589:09d15a2dbc6b |
---|---|
36 AO_fetch_and_add(value, add) | 36 AO_fetch_and_add(value, add) |
37 #define ngx_memory_barrier() AO_nop() | 37 #define ngx_memory_barrier() AO_nop() |
38 #define ngx_cpu_pause() | 38 #define ngx_cpu_pause() |
39 | 39 |
40 | 40 |
41 #elif (NGX_HAVE_GCC_ATOMIC) | |
42 | |
43 /* GCC 4.1 builtin atomic operations */ | |
44 | |
45 #define NGX_HAVE_ATOMIC_OPS 1 | |
46 | |
47 typedef long ngx_atomic_int_t; | |
48 typedef unsigned long ngx_atomic_uint_t; | |
49 | |
50 #if (NGX_PTR_SIZE == 8) | |
51 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) | |
52 #else | |
53 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) | |
54 #endif | |
55 | |
56 typedef volatile ngx_atomic_uint_t ngx_atomic_t; | |
57 | |
58 | |
59 #define ngx_atomic_cmp_set(lock, old, set) \ | |
60 __sync_bool_compare_and_swap(lock, old, set) | |
61 | |
62 #define ngx_atomic_fetch_add(value, add) \ | |
63 __sync_fetch_and_add(value, add) | |
64 | |
65 #define ngx_memory_barrier() __sync_synchronize() | |
66 | |
67 #if ( __i386__ || __i386 || __amd64__ || __amd64 ) | |
68 #define ngx_cpu_pause() __asm__ ("pause") | |
69 #else | |
70 #define ngx_cpu_pause() | |
71 #endif | |
72 | |
73 | |
41 #elif (NGX_DARWIN_ATOMIC) | 74 #elif (NGX_DARWIN_ATOMIC) |
42 | 75 |
43 /* | 76 /* |
44 * use Darwin 8 atomic(3) and barrier(3) operations | 77 * use Darwin 8 atomic(3) and barrier(3) operations |
45 * optimized at run-time for UP and SMP | 78 * optimized at run-time for UP and SMP |
84 #define ngx_memory_barrier() OSMemoryBarrier() | 117 #define ngx_memory_barrier() OSMemoryBarrier() |
85 | 118 |
86 #define ngx_cpu_pause() | 119 #define ngx_cpu_pause() |
87 | 120 |
88 typedef volatile ngx_atomic_uint_t ngx_atomic_t; | 121 typedef volatile ngx_atomic_uint_t ngx_atomic_t; |
89 | |
90 | |
91 #elif (NGX_HAVE_GCC_ATOMIC) | |
92 | |
93 /* GCC 4.1 builtin atomic operations */ | |
94 | |
95 #define NGX_HAVE_ATOMIC_OPS 1 | |
96 | |
97 typedef long ngx_atomic_int_t; | |
98 typedef unsigned long ngx_atomic_uint_t; | |
99 | |
100 #if (NGX_PTR_SIZE == 8) | |
101 #define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1) | |
102 #else | |
103 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) | |
104 #endif | |
105 | |
106 typedef volatile ngx_atomic_uint_t ngx_atomic_t; | |
107 | |
108 | |
109 #define ngx_atomic_cmp_set(lock, old, set) \ | |
110 __sync_bool_compare_and_swap(lock, old, set) | |
111 | |
112 #define ngx_atomic_fetch_add(value, add) \ | |
113 __sync_fetch_and_add(value, add) | |
114 | |
115 #define ngx_memory_barrier() __sync_synchronize() | |
116 | |
117 #if ( __i386__ || __i386 || __amd64__ || __amd64 ) | |
118 #define ngx_cpu_pause() __asm__ ("pause") | |
119 #else | |
120 #define ngx_cpu_pause() | |
121 #endif | |
122 | 122 |
123 | 123 |
124 #elif ( __i386__ || __i386 ) | 124 #elif ( __i386__ || __i386 ) |
125 | 125 |
126 typedef int32_t ngx_atomic_int_t; | 126 typedef int32_t ngx_atomic_int_t; |