# HG changeset patch # User Samuel Iseli # Date 1328275087 -3600 # Branch 2.7 # Node ID 0bd59b0fb1065931f248760dd06ffa81e7d4ee87 # Parent 41cabdff268624c91f084ca2203668db58df0460 Issue #13889: Add _Py_SET_53BIT_PRECISION_* macros for win32 diff -r 41cabdff2686 -r 0bd59b0fb106 Include/pyport.h --- a/Include/pyport.h Fri Feb 03 02:39:49 2012 +0100 +++ b/Include/pyport.h Fri Feb 03 14:18:07 2012 +0100 @@ -549,6 +549,29 @@ _Py_set_387controlword(old_387controlword) #endif +/* get and set x87 control word for MS VC /x86 */ +#ifdef _WIN32 +/* x87 not supported in 64bit applications */ +#ifndef _WIN64 +#define HAVE_PY_SET_53BIT_PRECISION 1 +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_387controlword, new_387controlword +/* we are using the __control87_2 function to set only the x87 controlword. + SSE controlword is unaffected */ +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __control87_2(0, 0, &old_387controlword, NULL); \ + new_387controlword = old_387controlword; \ + if ( !(old_387controlword & _PC_53) ) \ + __control87_2(_PC_53, _MCW_PC, &new_387controlword, NULL) \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + __control87_2(old_387controlword, _MCW_PC, &new_387controlword, NULL) +#endif +#endif + + /* default definitions are empty */ #ifndef HAVE_PY_SET_53BIT_PRECISION #define _Py_SET_53BIT_PRECISION_HEADER