Commit ef219fd6 authored by Robert Bradshaw's avatar Robert Bradshaw

Ensure NAN is always initialized.

parent 7e8fc267
...@@ -133,7 +133,7 @@ h_guard_prefix = "__PYX_HAVE__" ...@@ -133,7 +133,7 @@ h_guard_prefix = "__PYX_HAVE__"
api_guard_prefix = "__PYX_HAVE_API__" api_guard_prefix = "__PYX_HAVE_API__"
api_func_guard = "__PYX_HAVE_API_FUNC_" api_func_guard = "__PYX_HAVE_API_FUNC_"
PYX_NAN = "__PYX_NAN" PYX_NAN = "__PYX_NAN()"
def py_version_hex(major, minor=0, micro=0, release_level=0, release_serial=0): def py_version_hex(major, minor=0, micro=0, release_level=0, release_serial=0):
return (major << 24) | (minor << 16) | (micro << 8) | (release_level << 4) | (release_serial) return (major << 24) | (minor << 16) | (micro << 8) | (release_level << 4) | (release_serial)
...@@ -7082,8 +7082,6 @@ class ParallelStatNode(StatNode, ParallelNode): ...@@ -7082,8 +7082,6 @@ class ParallelStatNode(StatNode, ParallelNode):
if first: if first:
code.putln("/* Initialize private variables to " code.putln("/* Initialize private variables to "
"invalid values */") "invalid values */")
code.globalstate.use_utility_code(
invalid_values_utility_code)
first = False first = False
code.putln("%s = %s;" % (entry.cname, code.putln("%s = %s;" % (entry.cname,
entry.type.cast_code(invalid_value))) entry.type.cast_code(invalid_value)))
...@@ -8156,21 +8154,3 @@ bad: ...@@ -8156,21 +8154,3 @@ bad:
return NULL; return NULL;
} }
""") """)
################ Utility code for cython.parallel stuff ################
invalid_values_utility_code = UtilityCode(
proto="""\
#include <string.h>
void __pyx_init_nan(void);
static float %(PYX_NAN)s;
""" % vars(Naming),
init="""
/* 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. */
memset(&%(PYX_NAN)s, 0xFF, sizeof(%(PYX_NAN)s));
""" % vars(Naming))
...@@ -262,6 +262,19 @@ ...@@ -262,6 +262,19 @@
#define __Pyx_DOCSTR(n) (n) #define __Pyx_DOCSTR(n) (n)
#endif #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 /////////////// /////////////// UtilityFunctionPredeclarations.proto ///////////////
/* inline attribute */ /* inline attribute */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment