Mercurial > cpython-lru_cache-weakref
comparison Modules/python.c @ 26815:8eccfae04bb4 legacy-trunk
Apparently FreeBSD enables some HW floating-point exceptions by default.
This can cause core dumps when Python runs. Python relies on the 754-
(and C99-) mandated default "non-stop" mode for FP exceptions. This
patch from Ben Laurie disables at least one FP exception on FreeBSD at
Python startup time.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Sat, 28 Dec 2002 21:56:08 +0000 |
| parents | f66b3a3509c7 |
| children | 22a74eaf6b22 |
comparison
equal
deleted
inserted
replaced
| 26814:7c8af1979e78 | 26815:8eccfae04bb4 |
|---|---|
| 1 /* Minimal main program -- everything is loaded from the library */ | 1 /* Minimal main program -- everything is loaded from the library */ |
| 2 | 2 |
| 3 #include "Python.h" | 3 #include "Python.h" |
| 4 | 4 |
| 5 #ifdef __FreeBSD__ | |
| 6 #include <floatingpoint.h> | |
| 7 #endif | |
| 8 | |
| 5 int | 9 int |
| 6 main(int argc, char **argv) | 10 main(int argc, char **argv) |
| 7 { | 11 { |
| 12 /* 754 requires that FP exceptions run in "no stop" mode by default, | |
| 13 * and until C vendors implement C99's ways to control FP exceptions, | |
| 14 * Python requires non-stop mode. Alas, some platforms enable FP | |
| 15 * exceptions by default. Here we disable them. | |
| 16 */ | |
| 17 #ifdef __FreeBSD__ | |
| 18 fp_except_t m; | |
| 19 | |
| 20 m = fpgetmask(); | |
| 21 fpsetmask(m & ~FP_X_OFL); | |
| 22 #endif | |
| 8 return Py_Main(argc, argv); | 23 return Py_Main(argc, argv); |
| 9 } | 24 } |
