api_guard_prefix = "__PYX_HAVE_API__"
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):
return (major << 24) | (minor << 16) | (micro << 8) | (release_level << 4) | (release_serial)
if first:
code.putln("/* Initialize private variables to "
"invalid values */")
- code.globalstate.use_utility_code(
- invalid_values_utility_code)
first = False
code.putln("%s = %s;" % (entry.cname,
entry.type.cast_code(invalid_value)))
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))
#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 */