Sun Studio 12 compatibility

This commit is contained in:
Igor Sysoev 2007-07-16 08:54:04 +00:00
parent de27bce24e
commit d3cdbc85e8
4 changed files with 76 additions and 16 deletions

View File

@ -2,8 +2,10 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
# Sun C 5.7 Patch 117837-04 2005/05/11 # Sun C 5.7 Patch 117837-04 2005/05/11 Sun Studio 10
# Sun C 5.8 2005/10/13 # Sun C 5.8 2005/10/13 Sun Studio 11
# Sun C 5.9 SunOS_i386 2007/05/03 Sun Studio 12
# Sun C 5.9 SunOS_sparc 2007/05/03
NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \ NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \
| sed -e 's/^.* Sun C \(.*\)/\1/'` | sed -e 's/^.* Sun C \(.*\)/\1/'`
@ -13,6 +15,33 @@ echo " + Sun C version: $NGX_SUNC_VER"
have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
cat << END > $NGX_AUTOTEST.c
int main() { printf("%d", __SUNPRO_C); }
END
eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
ngx_sunc_ver=`$NGX_AUTOTEST`
fi
rm $NGX_AUTOTEST*
# 1424 == 0x590, Sun Studio 12
if [ "$ngx_sunc_ver" -ge 1424 ]; then
ngx_sparc32="-m32"
ngx_sparc64="-m64"
ngx_amd64="-m64"
else
ngx_sparc32="-xarch=v8plus"
ngx_sparc64="-xarch=v9"
ngx_amd64="-amd64"
fi
case "$NGX_MACHINE" in case "$NGX_MACHINE" in
i86pc) i86pc)
@ -43,7 +72,8 @@ esac
# optimizations # optimizations
CFLAGS="$CFLAGS -fast" IPO=-xipo
CFLAGS="$CFLAGS -fast $IPO"
case $CPU in case $CPU in
@ -80,25 +110,27 @@ case $CPU in
sparc32) sparc32)
# build 32-bit UltraSparc binary # build 32-bit UltraSparc binary
CPU_OPT="-m32" CPU_OPT="$ngx_sparc32"
CORE_LINK="$CORE_LINK -m32" CORE_LINK="$CORE_LINK $ngx_sparc32"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m32" CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc32"
NGX_CPU_CACHE_LINE=64 NGX_CPU_CACHE_LINE=64
;; ;;
sparc64) sparc64)
# build 64-bit UltraSparc binary # build 64-bit UltraSparc binary
CPU_OPT="-m64" CPU_OPT="$ngx_sparc64"
CORE_LINK="$CORE_LINK -m64" CORE_LINK="$CORE_LINK $ngx_sparc64"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64" CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc64"
NGX_CPU_CACHE_LINE=64 NGX_CPU_CACHE_LINE=64
;; ;;
amd64) amd64)
# build 64-bit amd64 binary # build 64-bit amd64 binary
CPU_OPT="-xarch=amd64" CPU_OPT="$ngx_amd64"
CORE_LINK="$CORE_LINK -xarch=amd64" CORE_LINK="$CORE_LINK $ngx_amd64"
CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_amd4"
NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il" NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
NGX_CPU_CACHE_LINE=64
;; ;;
esac esac
@ -108,15 +140,15 @@ CFLAGS="$CFLAGS $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-fast $CPU_OPT" PCRE_OPT="-fast $IPO $CPU_OPT"
fi fi
if [ ".$MD5_OPT" = "." ]; then if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-fast $CPU_OPT" MD5_OPT="-fast $IPO $CPU_OPT"
fi fi
if [ ".$ZLIB_OPT" = "." ]; then if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-fast $CPU_OPT" ZLIB_OPT="-fast $IPO $CPU_OPT"
fi fi

View File

@ -87,10 +87,17 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t ngx_atomic_int_t
ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
/*
* Sun Studio 12 exits with segmentation fault on '__asm ("pause")',
* so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il
*/
void
ngx_cpu_pause(void);
/* the code in src/os/unix/ngx_sunpro_x86.il */ /* the code in src/os/unix/ngx_sunpro_x86.il */
#define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
#define ngx_cpu_pause() __asm ("pause")
#else /* ( __GNUC__ || __INTEL_COMPILER ) */ #else /* ( __GNUC__ || __INTEL_COMPILER ) */
@ -121,10 +128,17 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t ngx_atomic_int_t
ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
/*
* Sun Studio 12 exits with segmentation fault on '__asm ("pause")',
* so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il
*/
void
ngx_cpu_pause(void);
/* the code in src/os/unix/ngx_sunpro_amd64.il */ /* the code in src/os/unix/ngx_sunpro_amd64.il */
#define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
#define ngx_cpu_pause() __asm ("pause")
#else /* ( __GNUC__ || __INTEL_COMPILER ) */ #else /* ( __GNUC__ || __INTEL_COMPILER ) */

View File

@ -28,3 +28,10 @@
lock lock
xaddq %rax, (%rdi) xaddq %rax, (%rdi)
.end .end
/ ngx_cpu_pause()
.inline ngx_cpu_pause,0
pause
.end

View File

@ -29,3 +29,10 @@
lock lock
xaddl %eax, (%ecx) xaddl %eax, (%ecx)
.end .end
/ ngx_cpu_pause()
.inline ngx_cpu_pause,0
pause
.end