[Python-checkins] r71577 - in python/branches/py3k-short-float-repr: Include/pymath.h Python/pymath.c

mark.dickinson python-checkins at python.org
Mon Apr 13 18:25:29 CEST 2009


Author: mark.dickinson
Date: Mon Apr 13 18:25:29 2009
New Revision: 71577
Log:
Add functions to get and set the x87 FPU control word, where applicable
Modified:
 python/branches/py3k-short-float-repr/Include/pymath.h
 python/branches/py3k-short-float-repr/Python/pymath.c
Modified: python/branches/py3k-short-float-repr/Include/pymath.h
==============================================================================
--- python/branches/py3k-short-float-repr/Include/pymath.h	(original)
+++ python/branches/py3k-short-float-repr/Include/pymath.h	Mon Apr 13 18:25:29 2009
@@ -92,6 +92,11 @@
 # endif
 #endif
 
+#ifdef HAVE_GCC_ASM_FOR_X87
+PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
+PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
+#endif
+
 /* Py_IS_NAN(X)
 * Return 1 if float or double arg is a NaN, else 0.
 * Caution:
Modified: python/branches/py3k-short-float-repr/Python/pymath.c
==============================================================================
--- python/branches/py3k-short-float-repr/Python/pymath.c	(original)
+++ python/branches/py3k-short-float-repr/Python/pymath.c	Mon Apr 13 18:25:29 2009
@@ -13,6 +13,28 @@
 }
 #endif
 
+#ifdef USING_X87_FPU
+# ifdef HAVE_GCC_ASM_FOR_X87
+
+/* inline assembly for getting and setting the 387 FPU control word on
+ gcc/x86 */
+
+unsigned short _Py_get_387controlword(void) {
+ unsigned short cw;
+ __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
+ return cw;
+}
+
+void _Py_set_387controlword(unsigned short cw) {
+ __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
+}
+
+# else
+# error "Unable to get and set x87 control word"
+# endif
+#endif
+
+
 #ifndef HAVE_HYPOT
 double hypot(double x, double y)
 {


More information about the Python-checkins mailing list

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