From: Robert Bradshaw Date: Tue, 9 Apr 2013 21:34:23 +0000 (-0700) Subject: Ensure NAN is always initialized. X-Git-Tag: 0.19b2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef219fd6487ba2f93d1f4d02761f27e041af1ac9;p=platform%2Fupstream%2Fpython-cython.git Ensure NAN is always initialized. --- diff --git a/Cython/Compiler/Naming.py b/Cython/Compiler/Naming.py index 7a103d8..b7432b2 100644 --- a/Cython/Compiler/Naming.py +++ b/Cython/Compiler/Naming.py @@ -133,7 +133,7 @@ h_guard_prefix = "__PYX_HAVE__" 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) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 6e75a3e..e1ce05e 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -7082,8 +7082,6 @@ class ParallelStatNode(StatNode, ParallelNode): 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))) @@ -8156,21 +8154,3 @@ bad: return NULL; } """) - -################ Utility code for cython.parallel stuff ################ - -invalid_values_utility_code = UtilityCode( -proto="""\ -#include - -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)) diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index e28844c..2953072 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 */