summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-04-15 14:12:37 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-04-15 14:12:37 (GMT)
commitb0f00476a0f8c97f3bb835d24fed82e98cb9cd72 (patch)
tree2bae2eeeadac56ae621bc72718c393fec19a61e4
parent69c635266ec20945142d6fb3beb2555769fed1ad (diff)
parent18e3d81f96a592a0307fa41645017483eabcfc51 (diff)
downloadcpython-b0f00476a0f8c97f3bb835d24fed82e98cb9cd72.zip
cpython-b0f00476a0f8c97f3bb835d24fed82e98cb9cd72.tar.gz
cpython-b0f00476a0f8c97f3bb835d24fed82e98cb9cd72.tar.bz2
Issue #13889: Merge fix from 3.2.
-rw-r--r--Include/pyport.h24
-rw-r--r--Misc/NEWS4
2 files changed, 28 insertions, 0 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index 1fd4dcc..eba34f9 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -557,6 +557,30 @@ extern "C" {
_Py_set_387controlword(old_387controlword)
#endif
+/* get and set x87 control word for VisualStudio/x86 */
+#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
+#define HAVE_PY_SET_53BIT_PRECISION 1
+#define _Py_SET_53BIT_PRECISION_HEADER \
+ unsigned int old_387controlword, new_387controlword, out_387controlword
+/* We use the __control87_2 function to set only the x87 control word.
+ The SSE control word is unaffected. */
+#define _Py_SET_53BIT_PRECISION_START \
+ do { \
+ __control87_2(0, 0, &old_387controlword, NULL); \
+ new_387controlword = \
+ (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \
+ if (new_387controlword != old_387controlword) \
+ __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \
+ &out_387controlword, NULL); \
+ } while (0)
+#define _Py_SET_53BIT_PRECISION_END \
+ do { \
+ if (new_387controlword != old_387controlword) \
+ __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \
+ &out_387controlword, NULL); \
+ } 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
index b8202c4..a476b41 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.3.0 Alpha 3?
Core and Builtins
-----------------
+- Issue #13889: Check and (if necessary) set FPU control word before calling
+ any of the dtoa.c string <-> float conversion functions, on MSVC builds of
+ Python. This fixes issues when embedding Python in a Delphi app.
+
- Issue #2377: Make importlib the implementation of __import__().
- Issue #1559549: ImportError now has 'name' and 'path' attributes that are set