From 41e3105694644fa920c42ac2fe9f3a9a2f4395f5 Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sat, 24 Oct 2009 14:40:41 -0400 Subject: [PATCH] freeze: include FreeBSD fix from Python's main() Copy the fix for floating point exceptions on FreeBSD from Python's Module/python.c. --- bin/cython_freeze | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/cython_freeze b/bin/cython_freeze index 0709ee53..631c3924 100755 --- a/bin/cython_freeze +++ b/bin/cython_freeze @@ -41,6 +41,10 @@ print """\ #include #include +#ifdef __FreeBSD__ +#include +#endif + #if PY_MAJOR_VERSION < 3 # define MODINIT(name) init ## name #else @@ -77,6 +81,17 @@ if not options.pymain: int r = 0; """, print """\ + /* 754 requires that FP exceptions run in "no stop" mode by default, + * and until C vendors implement C99's ways to control FP exceptions, + * Python requires non-stop mode. Alas, some platforms enable FP + * exceptions by default. Here we disable them. + */ +#ifdef __FreeBSD__ + fp_except_t m; + + m = fpgetmask(); + fpsetmask(m & ~FP_X_OFL); +#endif if (PyImport_ExtendInittab(inittab)) { fprintf(stderr, "No memory\\n"); exit(1); -- 2.26.2