summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMark Lodato <lodatom@gmail.com>2009-10-24 14:40:41 -0400
committerMark Lodato <lodatom@gmail.com>2009-10-24 14:40:41 -0400
commit41e3105694644fa920c42ac2fe9f3a9a2f4395f5 (patch)
treef43f80934eb2403b2372e5b5d94f8f1efe4fc667 /bin
parentc3edacbf380e9e8763dbbfcd2b9f28d37d049f70 (diff)
downloadcython-41e3105694644fa920c42ac2fe9f3a9a2f4395f5.tar.gz
freeze: include FreeBSD fix from Python's main()
Copy the fix for floating point exceptions on FreeBSD from Python's Module/python.c.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cython_freeze15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/cython_freeze b/bin/cython_freeze
index 0709ee53d..631c39249 100755
--- a/bin/cython_freeze
+++ b/bin/cython_freeze
@@ -41,6 +41,10 @@ print """\
#include <stdio.h>
#include <stdlib.h>
+#ifdef __FreeBSD__
+#include <floatingpoint.h>
+#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);