diff -r 41cabdff2686 -r c6d3b5af7d74 Include/pyport.h --- a/Include/pyport.h Fri Feb 03 02:39:49 2012 +0100 +++ b/Include/pyport.h Mon Feb 06 23:51:58 2012 +0100 @@ -549,6 +549,30 @@ _Py_set_387controlword(old_387controlword) #endif +/* get and set x87 control word for MS VC /x86 */ +#ifdef _MSC_VER +#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); \ + if ((old_387controlword & (_MCW_PC | _MCW_RC)) != _PC_53) \ + __control87_2(_PC_53, _MCW_PC | _MCW_RC, &new_387controlword, NULL); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ + &new_387controlword, NULL) +#endif +#endif +#endif + /* default definitions are empty */ #ifndef HAVE_PY_SET_53BIT_PRECISION #define _Py_SET_53BIT_PRECISION_HEADER