mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
GCC 4.1 builtin atomic operations
This commit is contained in:
parent
f215028477
commit
89d635fa5d
14
auto/cc/conf
14
auto/cc/conf
@ -105,7 +105,6 @@ fi
|
|||||||
|
|
||||||
CFLAGS="$CFLAGS $NGX_CC_OPT"
|
CFLAGS="$CFLAGS $NGX_CC_OPT"
|
||||||
|
|
||||||
|
|
||||||
if [ "$NGX_PLATFORM" != win32 ]; then
|
if [ "$NGX_PLATFORM" != win32 ]; then
|
||||||
|
|
||||||
if test -n "$NGX_LD_OPT"; then
|
if test -n "$NGX_LD_OPT"; then
|
||||||
@ -125,6 +124,19 @@ if [ "$NGX_PLATFORM" != win32 ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
ngx_feature="gcc builtin atomic operations"
|
||||||
|
ngx_feature_name=NGX_HAVE_GCC_ATOMIC
|
||||||
|
ngx_feature_run=no
|
||||||
|
ngx_feature_incs=
|
||||||
|
ngx_feature_path=
|
||||||
|
ngx_feature_libs=
|
||||||
|
ngx_feature_test="long n;
|
||||||
|
__sync_bool_compare_and_swap(&n, 0, 1);
|
||||||
|
__sync_fetch_and_add(&n, 1);"
|
||||||
|
. auto/feature
|
||||||
|
|
||||||
|
|
||||||
ngx_feature="gcc variadic macros"
|
ngx_feature="gcc variadic macros"
|
||||||
ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
|
ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
|
||||||
ngx_feature_run=yes
|
ngx_feature_run=yes
|
||||||
|
@ -90,7 +90,6 @@ case $CPU in
|
|||||||
# build 32-bit UltraSparc binary
|
# build 32-bit UltraSparc binary
|
||||||
CPU_OPT="-m32"
|
CPU_OPT="-m32"
|
||||||
CORE_LINK="$CORE_LINK -m32"
|
CORE_LINK="$CORE_LINK -m32"
|
||||||
CC_AUX_FLAGS="$CC_AUX_FLAGS -m32"
|
|
||||||
NGX_CPU_CACHE_LINE=64
|
NGX_CPU_CACHE_LINE=64
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -98,7 +97,6 @@ case $CPU in
|
|||||||
# build 64-bit UltraSparc binary
|
# build 64-bit UltraSparc binary
|
||||||
CPU_OPT="-m64"
|
CPU_OPT="-m64"
|
||||||
CORE_LINK="$CORE_LINK -m64"
|
CORE_LINK="$CORE_LINK -m64"
|
||||||
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
|
|
||||||
NGX_CPU_CACHE_LINE=64
|
NGX_CPU_CACHE_LINE=64
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -108,12 +106,12 @@ case $CPU in
|
|||||||
CPU_OPT="$CPU_OPT -falign-functions=32 -falign-labels=32"
|
CPU_OPT="$CPU_OPT -falign-functions=32 -falign-labels=32"
|
||||||
CPU_OPT="$CPU_OPT -falign-loops=32 -falign-jumps=32"
|
CPU_OPT="$CPU_OPT -falign-loops=32 -falign-jumps=32"
|
||||||
CORE_LINK="$CORE_LINK -m64"
|
CORE_LINK="$CORE_LINK -m64"
|
||||||
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
|
|
||||||
NGX_CPU_CACHE_LINE=128
|
NGX_CPU_CACHE_LINE=128
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
|
||||||
|
|
||||||
case "$NGX_GCC_VER" in
|
case "$NGX_GCC_VER" in
|
||||||
2.7*)
|
2.7*)
|
||||||
|
@ -60,10 +60,40 @@ typedef uint32_t ngx_atomic_uint_t;
|
|||||||
typedef volatile ngx_atomic_uint_t ngx_atomic_t;
|
typedef volatile ngx_atomic_uint_t ngx_atomic_t;
|
||||||
|
|
||||||
|
|
||||||
#else /* !(NGX_DARWIN) */
|
#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;
|
||||||
|
|
||||||
|
|
||||||
#if ( __i386__ || __i386 )
|
#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;
|
typedef int32_t ngx_atomic_int_t;
|
||||||
typedef uint32_t ngx_atomic_uint_t;
|
typedef uint32_t ngx_atomic_uint_t;
|
||||||
@ -203,9 +233,6 @@ typedef volatile ngx_atomic_uint_t ngx_atomic_t;
|
|||||||
|
|
||||||
#include "ngx_gcc_atomic_ppc.h"
|
#include "ngx_gcc_atomic_ppc.h"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user