]> granicus.if.org Git - python/commitdiff
support setting fpu precision on m68k (closes #20904)
authorBenjamin Peterson <benjamin@python.org>
Thu, 17 Apr 2014 04:00:31 +0000 (00:00 -0400)
committerBenjamin Peterson <benjamin@python.org>
Thu, 17 Apr 2014 04:00:31 +0000 (00:00 -0400)
Patch from Andreas Schwab.

Include/pyport.h
Misc/NEWS
configure
configure.ac
pyconfig.h.in

index c706213c87c58996cf6883e8f3243dc5a3ed2db0..69deb9f8bf70f5925aab6ed1b73b133b37dd87df 100644 (file)
@@ -588,6 +588,25 @@ extern "C" {
     } while (0)
 #endif
 
+#ifdef HAVE_GCC_ASM_FOR_MC68881
+#define HAVE_PY_SET_53BIT_PRECISION 1
+#define _Py_SET_53BIT_PRECISION_HEADER \
+  unsigned int old_fpcr, new_fpcr
+#define _Py_SET_53BIT_PRECISION_START                                  \
+  do {                                                                 \
+    __asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr));                   \
+    /* Set double precision / round to nearest.  */                    \
+    new_fpcr = (old_fpcr & ~0xf0) | 0x80;                              \
+    if (new_fpcr != old_fpcr)                                          \
+      __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr));       \
+  } while (0)
+#define _Py_SET_53BIT_PRECISION_END                                    \
+  do {                                                                 \
+    if (new_fpcr != old_fpcr)                                          \
+      __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr));       \
+  } while (0)
+#endif
+
 /* default definitions are empty */
 #ifndef HAVE_PY_SET_53BIT_PRECISION
 #define _Py_SET_53BIT_PRECISION_HEADER
index 4bef2992c1587a4a696cf2f1e9f3e5f981479012..5c6a5be4903c31d11ba909573d9fd8e87f503792 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ Release date: TBA
 Core and Builtins
 -----------------
 
+- Issue #20904: Support setting FPU precision on m68k.
+
 - Issue #21209: Fix sending tuples to custom generator objects with the yield
   from syntax.
 
index 7b0c6a92948bef89e42bd42da6714df006c36396..31a3c67d304db32081a759881be16428c61e0803 100755 (executable)
--- a/configure
+++ b/configure
@@ -13244,6 +13244,38 @@ $as_echo "#define HAVE_GCC_ASM_FOR_X87 1" >>confdefs.h
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use gcc inline assembler to get and set mc68881 fpcr" >&5
+$as_echo_n "checking whether we can use gcc inline assembler to get and set mc68881 fpcr... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  unsigned int fpcr;
+  __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
+  __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  have_gcc_asm_for_mc68881=yes
+else
+  have_gcc_asm_for_mc68881=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_asm_for_mc68881" >&5
+$as_echo "$have_gcc_asm_for_mc68881" >&6; }
+if test "$have_gcc_asm_for_mc68881" = yes
+then
+
+$as_echo "#define HAVE_GCC_ASM_FOR_MC68881 1" >>confdefs.h
+
+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
index 457819b0a398decb76f017f853b9a4a1bccb018e..f2e4b1ce1bfa0884e396db73ec43cf175f29a62e 100644 (file)
@@ -3810,6 +3810,19 @@ then
     [Define if we can use gcc inline assembler to get and set x87 control word])
 fi
 
+AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set mc68881 fpcr)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  unsigned int fpcr;
+  __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
+  __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
+]])],[have_gcc_asm_for_mc68881=yes],[have_gcc_asm_for_mc68881=no])
+AC_MSG_RESULT($have_gcc_asm_for_mc68881)
+if test "$have_gcc_asm_for_mc68881" = yes
+then
+    AC_DEFINE(HAVE_GCC_ASM_FOR_MC68881, 1,
+    [Define if we can use gcc inline assembler to get and set mc68881 fpcr])
+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
index 3574f67322d9f8c5e02e12e694198620cd725130..e469f6abe91256d8f7149fe425d1beffa5b7db9f 100644 (file)
 /* Define to 1 if you have the `gamma' function. */
 #undef HAVE_GAMMA
 
+/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */
+#undef HAVE_GCC_ASM_FOR_MC68881
+
 /* Define if we can use x64 gcc inline assembler */
 #undef HAVE_GCC_ASM_FOR_X64