[Python-checkins] cpython: support setting fpu precision on m68k (closes #20904)

benjamin.peterson python-checkins at python.org
Thu Apr 17 06:00:55 CEST 2014


http://hg.python.org/cpython/rev/c2f6551c9eaf
changeset: 90378:c2f6551c9eaf
user: Benjamin Peterson <benjamin at python.org>
date: Thu Apr 17 00:00:31 2014 -0400
summary:
 support setting fpu precision on m68k (closes #20904)
Patch from Andreas Schwab.
files:
 Include/pyport.h | 19 +++++++++++++++++++
 Misc/NEWS | 2 ++
 configure | 32 ++++++++++++++++++++++++++++++++
 configure.ac | 13 +++++++++++++
 pyconfig.h.in | 3 +++
 5 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/Include/pyport.h b/Include/pyport.h
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -588,6 +588,25 @@
 } 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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@
 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.
 
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -13244,6 +13244,38 @@
 
 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
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -3810,6 +3810,19 @@
 [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
diff --git a/pyconfig.h.in b/pyconfig.h.in
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -313,6 +313,9 @@
 /* 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
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /