Merged revisions 76300 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76300 | mark.dickinson | 2009-11-15 13:12:43 +0000 (Sun, 15 Nov 2009) | 3 lines

  Issue #5792:  Extend short float repr support to x86 platforms using suncc or icc.
  Many thanks Stefan Krah for help and OpenSolaris testing.
........
diff --git a/Misc/NEWS b/Misc/NEWS
index 96cc3ce..1577baf 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -358,6 +358,9 @@
 Build
 -----
 
+- Issue #5792: Extend the short float repr support to x86 systems using
+  icc or suncc.
+
 - Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it
   compiles correctly under gcc on x86-64.  This fixes a reported
   problem with the --with-tsc build on x86-64.
diff --git a/configure b/configure
index 08e39c9..188435b 100755
--- a/configure
+++ b/configure
@@ -22945,15 +22945,15 @@
 # correctly-rounded string <-> double conversion functions from
 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
 # rounding; this is a problem on x86, where the x87 FPU has a default
-# rounding precision of 64 bits.  For gcc/x86, we try to fix this by
+# rounding precision of 64 bits.  For gcc/x86, we can fix this by
 # using inline assembler to get and set the x87 FPU control word.
-if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
-then
-    # Check that it's okay to use gcc inline assembler to get and set
-    # x87 control word.  It should be, but you never know...
-    { echo "$as_me:$LINENO: checking whether we can use gcc inline assembler to get and set x87 control word" >&5
+
+# This inline assembler syntax may also work for suncc and icc,
+# so we try it on all platforms.
+
+{ 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
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -22964,9 +22964,9 @@
 main ()
 {
 
-      unsigned short cw;
-      __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
-      __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
+  unsigned short cw;
+  __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
+  __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
 
   ;
   return 0;
@@ -22998,16 +22998,15 @@
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    { echo "$as_me:$LINENO: result: $have_gcc_asm_for_x87" >&5
+{ 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
+if test "$have_gcc_asm_for_x87" = yes
+then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_GCC_ASM_FOR_X87 1
 _ACEOF
 
-    fi
 fi
 
 # Detect whether system arithmetic is subject to x87-style double
diff --git a/configure.in b/configure.in
index 2e8da64..4a0bf68 100644
--- a/configure.in
+++ b/configure.in
@@ -3191,25 +3191,24 @@
 # correctly-rounded string <-> double conversion functions from
 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
 # rounding; this is a problem on x86, where the x87 FPU has a default
-# rounding precision of 64 bits.  For gcc/x86, we try to fix this by
+# rounding precision of 64 bits.  For gcc/x86, we can fix this by
 # using inline assembler to get and set the x87 FPU control word.
-if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
+
+# This inline assembler syntax may also work for suncc and icc,
+# so we try it on all platforms.
+
+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
-    # Check that it's okay to use gcc inline assembler to get and set
-    # x87 control word.  It should be, but you never know...
-    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
+    AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
+    [Define if we can use gcc inline assembler to get and set x87 control word])
 fi
 
 # Detect whether system arithmetic is subject to x87-style double