mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
fixes #24772 The old implementation was said to copied from Windows SDK, but you can find the newer SDK's definition is updated and the sign is reversed compared to the old. Also, `__builtin_nanf("")` is used if available, which is more efficient than previous (In x86_64 gcc, latter produces 32B code but former just 8B).
This commit is contained in:
@@ -485,13 +485,22 @@ typedef char* NCSTRING;
|
||||
|
||||
#define paramCount() cmdCount
|
||||
|
||||
// NAN definition copied from math.h included in the Windows SDK version 10.0.14393.0
|
||||
#ifndef NAN
|
||||
#ifndef NAN /* use __builtin_nanf which is faster, if available */
|
||||
# if defined(__GNUC__)
|
||||
# define NAN (__builtin_nanf(""))
|
||||
# elif defined(__clang__) /* XXX: writing __has_builtin this line cause MSVC complains. */
|
||||
# if __has_builtin (__builtin_nanf)
|
||||
# define NAN (__builtin_nanf(""))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NAN /* modified from math.h included in the Windows SDK version 10.0.26100.0 */
|
||||
# ifndef _HUGE_ENUF
|
||||
# define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow
|
||||
# define _HUGE_ENUF 1e+300 /* _HUGE_ENUF*_HUGE_ENUF must overflow */
|
||||
# endif
|
||||
# define NAN_INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
# define NAN ((float)(NAN_INFINITY * 0.0F))
|
||||
# define NAN (-(float)(NAN_INFINITY * 0.0F))
|
||||
#endif
|
||||
|
||||
#ifndef INF
|
||||
|
||||
Reference in New Issue
Block a user