Skip to content

Commit

Permalink
Give GCC atomics precedence over deprecated Darwin atomic(3).
Browse files Browse the repository at this point in the history
This allows to build nginx on macOS with -Wdeprecated-declarations.
  • Loading branch information
pluknet committed Aug 30, 2021
1 parent 67d160b commit 1e8c0d4
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/os/unix/ngx_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,39 @@ typedef volatile ngx_atomic_uint_t ngx_atomic_t;
#define ngx_cpu_pause()


#elif (NGX_HAVE_GCC_ATOMIC)

/* GCC 4.1 builtin atomic operations */

#define NGX_HAVE_ATOMIC_OPS 1

typedef long ngx_atomic_int_t;
typedef unsigned long ngx_atomic_uint_t;

#if (NGX_PTR_SIZE == 8)
#define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
#else
#define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
#endif

typedef volatile ngx_atomic_uint_t ngx_atomic_t;


#define ngx_atomic_cmp_set(lock, old, set) \
__sync_bool_compare_and_swap(lock, old, set)

#define ngx_atomic_fetch_add(value, add) \
__sync_fetch_and_add(value, add)

#define ngx_memory_barrier() __sync_synchronize()

#if ( __i386__ || __i386 || __amd64__ || __amd64 )
#define ngx_cpu_pause() __asm__ ("pause")
#else
#define ngx_cpu_pause()
#endif


#elif (NGX_DARWIN_ATOMIC)

/*
Expand Down Expand Up @@ -88,39 +121,6 @@ typedef uint32_t ngx_atomic_uint_t;
typedef volatile ngx_atomic_uint_t ngx_atomic_t;


#elif (NGX_HAVE_GCC_ATOMIC)

/* GCC 4.1 builtin atomic operations */

#define NGX_HAVE_ATOMIC_OPS 1

typedef long ngx_atomic_int_t;
typedef unsigned long ngx_atomic_uint_t;

#if (NGX_PTR_SIZE == 8)
#define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
#else
#define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
#endif

typedef volatile ngx_atomic_uint_t ngx_atomic_t;


#define ngx_atomic_cmp_set(lock, old, set) \
__sync_bool_compare_and_swap(lock, old, set)

#define ngx_atomic_fetch_add(value, add) \
__sync_fetch_and_add(value, add)

#define ngx_memory_barrier() __sync_synchronize()

#if ( __i386__ || __i386 || __amd64__ || __amd64 )
#define ngx_cpu_pause() __asm__ ("pause")
#else
#define ngx_cpu_pause()
#endif


#elif ( __i386__ || __i386 )

typedef int32_t ngx_atomic_int_t;
Expand Down

0 comments on commit 1e8c0d4

Please sign in to comment.