[Python-checkins] r71576 - in python/branches/py3k-short-float-repr: configure configure.in pyconfig.h.in
mark.dickinson
python-checkins at python.org
Mon Apr 13 18:08:49 CEST 2009
Author: mark.dickinson
Date: Mon Apr 13 18:08:48 2009
New Revision: 71576
Log:
Some configure script fixes:
- on gcc/x86, if SSE2 instruction set doesn't appear to be
available then check that we can use inline assembler
to get and set the x87 control word
- the double rounding check should use BASECFLAGS, since that
might affect the result
- don't cache result of double rounding check
- move all the floating-point stuff into one place in
configure.in
Modified:
python/branches/py3k-short-float-repr/configure
python/branches/py3k-short-float-repr/configure.in
python/branches/py3k-short-float-repr/pyconfig.h.in
Modified: python/branches/py3k-short-float-repr/configure
==============================================================================
--- python/branches/py3k-short-float-repr/configure (original)
+++ python/branches/py3k-short-float-repr/configure Mon Apr 13 18:08:48 2009
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 71287 .
+# From configure.in Revision: 71321 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.1.
#
@@ -4588,76 +4588,6 @@
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi
- # On x86/x86-64, use the SSE2 instruction set when available.
- { echo "$as_me:$LINENO: checking whether $CC accepts -msse2 -mfpmath=sse" >&5
-echo $ECHO_N "checking whether $CC accepts -msse2 -mfpmath=sse... $ECHO_C" >&6; }
- ac_save_cc="$CC"
- CC="$CC -msse2 -mfpmath=sse"
- if test "$cross_compiling" = yes; then
- ac_cv_msse2_ok=no
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-int main() { return 0; }
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_msse2_ok=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_msse2_ok=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
- CC="$ac_save_cc"
- { echo "$as_me:$LINENO: result: $ac_cv_msse2_ok" >&5
-echo "${ECHO_T}$ac_cv_msse2_ok" >&6; }
- { echo "$as_me:$LINENO: checking whether SSE2 instructions are already enabled for math" >&5
-echo $ECHO_N "checking whether SSE2 instructions are already enabled for math... $ECHO_C" >&6; }
- if [ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]
- then
- ac_sse2_enabled=no
- else
- ac_sse2_enabled=yes
- fi
- { echo "$as_me:$LINENO: result: $ac_sse2_enabled" >&5
-echo "${ECHO_T}$ac_sse2_enabled" >&6; }
- if test $ac_sse2_enabled = no
- then
- if test $ac_cv_msse2_ok = yes
- then
- BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
- fi
- fi
-
# if using gcc on alpha, use -mieee to get (near) full IEEE 754
# support. Without this, treatment of subnormals doesn't follow
# the standard.
@@ -21673,12 +21603,9 @@
fi
-# ************************************
-# * Check for mathematical functions *
-# ************************************
-
-LIBS_SAVE=$LIBS
-LIBS="$LIBS $LIBM"
+# **************************************************
+# * Check for various properties of floating point *
+# **************************************************
{ echo "$as_me:$LINENO: checking whether C doubles are little-endian IEEE 754 binary64" >&5
echo $ECHO_N "checking whether C doubles are little-endian IEEE 754 binary64... $ECHO_C" >&6; }
@@ -21696,7 +21623,6 @@
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <stdlib.h>
#include <string.h>
int main() {
double x = 9006104071832581.0;
@@ -21769,7 +21695,6 @@
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <stdlib.h>
#include <string.h>
int main() {
double x = 9006104071832581.0;
@@ -21826,6 +21751,157 @@
fi
+# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
+# rounding; this is a particular problem on x86, where the x87 FPU has
+# a default rounding precision of 64 bits. For gcc/x86, we try to fix
+# this by:
+#
+# (1) using the SSE2 instruction set when available (it usually is
+# on modern machines)
+# (2) using inline assembler to get and set the x87 FPU control word
+# otherwise.
+
+if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
+then
+ # determine whether we're already using the SSE2 instruction set for math
+ { echo "$as_me:$LINENO: checking whether SSE2 instructions are already enabled for math" >&5
+echo $ECHO_N "checking whether SSE2 instructions are already enabled for math... $ECHO_C" >&6; }
+ if [ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]
+ then
+ ac_sse2_enabled=no
+ else
+ ac_sse2_enabled=yes
+ fi
+ { echo "$as_me:$LINENO: result: $ac_sse2_enabled" >&5
+echo "${ECHO_T}$ac_sse2_enabled" >&6; }
+
+ # if not, try using gcc options to enable it
+ if test $ac_sse2_enabled = no
+ then
+ { echo "$as_me:$LINENO: checking whether $CC accepts -msse2 -mfpmath=sse" >&5
+echo $ECHO_N "checking whether $CC accepts -msse2 -mfpmath=sse... $ECHO_C" >&6; }
+ ac_save_cc="$CC"
+ CC="$CC -msse2 -mfpmath=sse"
+ if test "$cross_compiling" = yes; then
+ ac_cv_msse2_ok=no
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+int main() { return 0; }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_msse2_ok=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_msse2_ok=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+ CC="$ac_save_cc"
+ { echo "$as_me:$LINENO: result: $ac_cv_msse2_ok" >&5
+echo "${ECHO_T}$ac_cv_msse2_ok" >&6; }
+
+ if test $ac_cv_msse2_ok = yes
+ then
+ BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
+ else
+
+cat >>confdefs.h <<\_ACEOF
+#define USING_X87_FPU 1
+_ACEOF
+
+ # SSE2 doesn't appear to be available. Check that it's okay
+ # to use gcc inline assembler to get and set x87 control word
+ { echo "$as_me:$LINENO: checking whether we can use gcc inline assembler to get and set x87 control word" >&5
+echo $ECHO_N "checking whether we can use gcc inline assembler to get and set x87 control word... $ECHO_C" >&6; }
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ unsigned short cw;
+ __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
+ __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ have_gcc_asm_for_x87=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ have_gcc_asm_for_x87=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { echo "$as_me:$LINENO: result: $have_gcc_asm_for_x87" >&5
+echo "${ECHO_T}$have_gcc_asm_for_x87" >&6; }
+ if test "$have_gcc_asm_for_x87" = yes
+ then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_GCC_ASM_FOR_X87 1
+_ACEOF
+
+ fi
+ fi
+ fi
+fi
+
# Detect whether system arithmetic is subject to x87-style double
# rounding issues. The result of this test has little meaning on non
# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
@@ -21833,10 +21909,9 @@
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
{ echo "$as_me:$LINENO: checking for x87-style double rounding" >&5
echo $ECHO_N "checking for x87-style double rounding... $ECHO_C" >&6; }
-if test "${ac_cv_x87_double_rounding+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
+# $BASECFLAGS may affect the result
+ac_save_cc="$CC"
+CC="$CC $BASECFLAGS"
if test "$cross_compiling" = yes; then
ac_cv_x87_double_rounding=no
else
@@ -21900,8 +21975,7 @@
fi
-fi
-
+CC="$ac_save_cc"
{ echo "$as_me:$LINENO: result: $ac_cv_x87_double_rounding" >&5
echo "${ECHO_T}$ac_cv_x87_double_rounding" >&6; }
if test "$ac_cv_x87_double_rounding" = yes
@@ -21913,6 +21987,13 @@
fi
+# ************************************
+# * Check for mathematical functions *
+# ************************************
+
+LIBS_SAVE=$LIBS
+LIBS="$LIBS $LIBM"
+
# Multiprocessing check for broken sem_getvalue
{ echo "$as_me:$LINENO: checking for broken sem_getvalue" >&5
echo $ECHO_N "checking for broken sem_getvalue... $ECHO_C" >&6; }
Modified: python/branches/py3k-short-float-repr/configure.in
==============================================================================
--- python/branches/py3k-short-float-repr/configure.in (original)
+++ python/branches/py3k-short-float-repr/configure.in Mon Apr 13 18:08:48 2009
@@ -858,32 +858,6 @@
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi
- # On x86/x86-64, use the SSE2 instruction set when available.
- AC_MSG_CHECKING(whether $CC accepts -msse2 -mfpmath=sse)
- ac_save_cc="$CC"
- CC="$CC -msse2 -mfpmath=sse"
- AC_TRY_RUN([int main() { return 0; }],
- ac_cv_msse2_ok=yes,
- ac_cv_msse2_ok=no,
- ac_cv_msse2_ok=no)
- CC="$ac_save_cc"
- AC_MSG_RESULT($ac_cv_msse2_ok)
- AC_MSG_CHECKING(whether SSE2 instructions are already enabled for math)
- if [[ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]]
- then
- ac_sse2_enabled=no
- else
- ac_sse2_enabled=yes
- fi
- AC_MSG_RESULT($ac_sse2_enabled)
- if test $ac_sse2_enabled = no
- then
- if test $ac_cv_msse2_ok = yes
- then
- BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
- fi
- fi
-
# if using gcc on alpha, use -mieee to get (near) full IEEE 754
# support. Without this, treatment of subnormals doesn't follow
# the standard.
@@ -3091,17 +3065,13 @@
fi],
[AC_MSG_RESULT(default LIBC="$LIBC")])
-# ************************************
-# * Check for mathematical functions *
-# ************************************
-
-LIBS_SAVE=$LIBS
-LIBS="$LIBS $LIBM"
+# **************************************************
+# * Check for various properties of floating point *
+# **************************************************
AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
AC_CACHE_VAL(ac_cv_little_endian_double, [
AC_TRY_RUN([
-#include <stdlib.h>
#include <string.h>
int main() {
double x = 9006104071832581.0;
@@ -3125,7 +3095,6 @@
AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
AC_CACHE_VAL(ac_cv_big_endian_double, [
AC_TRY_RUN([
-#include <stdlib.h>
#include <string.h>
int main() {
double x = 9006104071832581.0;
@@ -3146,13 +3115,76 @@
with the most significant byte first])
fi
+# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
+# rounding; this is a particular problem on x86, where the x87 FPU has
+# a default rounding precision of 64 bits. For gcc/x86, we try to fix
+# this by:
+#
+# (1) using the SSE2 instruction set when available (it usually is
+# on modern machines)
+# (2) using inline assembler to get and set the x87 FPU control word
+# otherwise.
+
+if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
+then
+ # determine whether we're already using the SSE2 instruction set for math
+ AC_MSG_CHECKING(whether SSE2 instructions are already enabled for math)
+ if [[ "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`" == "" ]]
+ then
+ ac_sse2_enabled=no
+ else
+ ac_sse2_enabled=yes
+ fi
+ AC_MSG_RESULT($ac_sse2_enabled)
+
+ # if not, try using gcc options to enable it
+ if test $ac_sse2_enabled = no
+ then
+ AC_MSG_CHECKING(whether $CC accepts -msse2 -mfpmath=sse)
+ ac_save_cc="$CC"
+ CC="$CC -msse2 -mfpmath=sse"
+ AC_TRY_RUN([int main() { return 0; }],
+ ac_cv_msse2_ok=yes,
+ ac_cv_msse2_ok=no,
+ ac_cv_msse2_ok=no)
+ CC="$ac_save_cc"
+ AC_MSG_RESULT($ac_cv_msse2_ok)
+
+ if test $ac_cv_msse2_ok = yes
+ then
+ BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
+ else
+ AC_DEFINE(USING_X87_FPU, 1,
+ [Define on x86 hardware if the x87 FPU is being used
+ for floating-point arithmetic])
+ # SSE2 doesn't appear to be available. Check that it's okay
+ # to use gcc inline assembler to get and set x87 control word
+ AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
+ AC_TRY_COMPILE([], [
+ unsigned short cw;
+ __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
+ __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
+ ],
+ [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
+ AC_MSG_RESULT($have_gcc_asm_for_x87)
+ if test "$have_gcc_asm_for_x87" = yes
+ then
+ AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
+ [Define if we can use gcc inline assembler to get and set x87 control word])
+ fi
+ fi
+ fi
+fi
+
# Detect whether system arithmetic is subject to x87-style double
# rounding issues. The result of this test has little meaning on non
# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
# mode is round-to-nearest and double rounding issues are present, and
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
AC_MSG_CHECKING(for x87-style double rounding)
-AC_CACHE_VAL(ac_cv_x87_double_rounding, [
+# $BASECFLAGS may affect the result
+ac_save_cc="$CC"
+CC="$CC $BASECFLAGS"
AC_TRY_RUN([
#include <stdlib.h>
#include <math.h>
@@ -3175,7 +3207,8 @@
],
ac_cv_x87_double_rounding=no,
ac_cv_x87_double_rounding=yes,
-ac_cv_x87_double_rounding=no)])
+ac_cv_x87_double_rounding=no)
+CC="$ac_save_cc"
AC_MSG_RESULT($ac_cv_x87_double_rounding)
if test "$ac_cv_x87_double_rounding" = yes
then
@@ -3183,6 +3216,13 @@
[Define if arithmetic is subject to x87-style double rounding issue])
fi
+# ************************************
+# * Check for mathematical functions *
+# ************************************
+
+LIBS_SAVE=$LIBS
+LIBS="$LIBS $LIBM"
+
# Multiprocessing check for broken sem_getvalue
AC_MSG_CHECKING(for broken sem_getvalue)
AC_TRY_RUN([
Modified: python/branches/py3k-short-float-repr/pyconfig.h.in
==============================================================================
--- python/branches/py3k-short-float-repr/pyconfig.h.in (original)
+++ python/branches/py3k-short-float-repr/pyconfig.h.in Mon Apr 13 18:08:48 2009
@@ -240,6 +240,10 @@
/* Define to 1 if you have the `gai_strerror' function. */
#undef HAVE_GAI_STRERROR
+/* Define if we can use gcc inline assembler to get and set x87 control word
+ */
+#undef HAVE_GCC_ASM_FOR_X87
+
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
@@ -978,6 +982,10 @@
/* Define if you want to use computed gotos in ceval.c. */
#undef USE_COMPUTED_GOTOS
+/* Define on x86 hardware if the x87 FPU is being used for floating-point
+ arithmetic */
+#undef USING_X87_FPU
+
/* Define if a va_list is an array of some kind */
#undef VA_LIST_IS_ARRAY
More information about the Python-checkins
mailing list