gh-136006: fix Py_NAN expansion on Solaris systems (#136575)
On Solaris, `Py_NAN` may expand as a function address instead of a floating-point number.
This amends commit 7a3b03509e.
This commit is contained in:
@@ -57,9 +57,24 @@
|
||||
|
||||
/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is
|
||||
* undefined and normally not relevant, but e.g. fixed for float("nan").
|
||||
*
|
||||
* Note: On Solaris, NAN is a function address, hence arithmetic is impossible.
|
||||
* For that reason, we instead use the built-in call if available or fallback
|
||||
* to a generic NaN computed from strtod() as a last resort.
|
||||
*
|
||||
* See https://github.com/python/cpython/issues/136006 for details.
|
||||
*/
|
||||
#if !defined(Py_NAN)
|
||||
# define Py_NAN ((double)NAN)
|
||||
# if defined(__sun)
|
||||
# if _Py__has_builtin(__builtin_nanf)
|
||||
# define Py_NAN ((double)__builtin_nanf(""))
|
||||
# else
|
||||
# include <stdlib.h>
|
||||
# define Py_NAN (strtod("NAN", NULL))
|
||||
# endif
|
||||
# else
|
||||
# define Py_NAN ((double)NAN)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* Py_PYMATH_H */
|
||||
|
||||
Reference in New Issue
Block a user