summaryrefslogtreecommitdiff
path: root/Cython/Utility/ModuleSetupCode.c
diff options
context:
space:
mode:
authorRobert Bradshaw <robertwb@gmail.com>2013-04-09 14:34:23 -0700
committerRobert Bradshaw <robertwb@gmail.com>2013-04-09 14:34:23 -0700
commitef219fd6487ba2f93d1f4d02761f27e041af1ac9 (patch)
tree1d5e5b3d81577de33b49434295c690906b1a5644 /Cython/Utility/ModuleSetupCode.c
parent7e8fc267ef4cd4f0cad3a59cd9d3438564bee150 (diff)
downloadcython-ef219fd6487ba2f93d1f4d02761f27e041af1ac9.tar.gz
Ensure NAN is always initialized.
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r--Cython/Utility/ModuleSetupCode.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index e28844ccd..295307237 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -262,6 +262,19 @@
#define __Pyx_DOCSTR(n) (n)
#endif
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static inline float __PYX_NAN() {
+ /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
+ a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
+ a quiet NaN. */
+ float value;
+ memset(&value, 0xFF, sizeof(value));
+ return value;
+}
+#endif
+
/////////////// UtilityFunctionPredeclarations.proto ///////////////
/* inline attribute */