From ef219fd6487ba2f93d1f4d02761f27e041af1ac9 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 9 Apr 2013 14:34:23 -0700 Subject: Ensure NAN is always initialized. --- Cython/Utility/ModuleSetupCode.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Cython/Utility/ModuleSetupCode.c') 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 */ -- cgit v1.2.1