https://git.reactos.org/?p=reactos.git;a=commitdiff;h=736fea6c44cad243fcb8f19b70acc803b5e20b30
commit 736fea6c44cad243fcb8f19b70acc803b5e20b30 Author: Timo Kreuzer <timo.kreu...@reactos.org> AuthorDate: Thu Jan 30 19:27:53 2025 +0200 Commit: Timo Kreuzer <timo.kreu...@reactos.org> CommitDate: Wed Feb 12 16:54:45 2025 +0200 [CRT] math.h: fix definition of NAN - Use positive NAN by default - add support for _UCRT_NEGATIVE_NAN to legacy CRT headers - Use __builtin_nanf() on GCC/Clang --- sdk/include/crt/math.h | 16 +++++++++++++++- sdk/include/ucrt/corecrt_math.h | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sdk/include/crt/math.h b/sdk/include/crt/math.h index 33f460db5f6..09113acef86 100644 --- a/sdk/include/crt/math.h +++ b/sdk/include/crt/math.h @@ -57,7 +57,21 @@ typedef double double_t; #define HUGE_VALD ((double)INFINITY) #define HUGE_VALF ((float)INFINITY) #define HUGE_VALL ((long double)INFINITY) -#define NAN ((float)(INFINITY * 0.0F)) +#ifndef _UCRT_NEGATIVE_NAN +// This operation creates a negative NAN adding a - to make it positive +#ifdef _MSC_VER +#define NAN (-(float)(INFINITY * 0.0F)) +#else +#define NAN (__builtin_nanf("")) +#endif +#else +// Keep this for backwards compatibility +#ifdef _MSC_VER +#define NAN ((float)(INFINITY * 0.0F)) +#else +#define NAN (-__builtin_nanf("")) +#endif +#endif #define _DENORM (-2) #define _FINITE (-1) diff --git a/sdk/include/ucrt/corecrt_math.h b/sdk/include/ucrt/corecrt_math.h index fdfe1f02e66..215a0b96422 100644 --- a/sdk/include/ucrt/corecrt_math.h +++ b/sdk/include/ucrt/corecrt_math.h @@ -91,10 +91,18 @@ _CRT_BEGIN_C_HEADER #define HUGE_VALL ((long double)INFINITY) #ifndef _UCRT_NEGATIVE_NAN // This operation creates a negative NAN adding a - to make it positive +#ifdef _MSC_VER #define NAN (-(float)(INFINITY * 0.0F)) #else +#define NAN (__builtin_nanf("")) +#endif +#else // Keep this for backwards compatibility +#ifdef _MSC_VER #define NAN ((float)(INFINITY * 0.0F)) +#else +#define NAN (-__builtin_nanf("")) +#endif #endif #define _DENORM (-2)