diff --git a/dll/win32/ucrtbase/ucrtbase.spec b/dll/win32/ucrtbase/ucrtbase.spec index 6a9c022622f..cb2d341f209 100644 --- a/dll/win32/ucrtbase/ucrtbase.spec +++ b/dll/win32/ucrtbase/ucrtbase.spec @@ -371,7 +371,7 @@ @ cdecl _findnext64(long ptr) @ cdecl _findnext64i32(long ptr) @ cdecl _finite(double) -@ cdecl -stub -arch=!i386 _finitef(float) +@ cdecl -arch=!i386 _finitef(float) @ cdecl _flushall() @ cdecl _fpclass(double) @ cdecl -stub -arch=!i386 _fpclassf(float) diff --git a/sdk/lib/crt/float/isnan.c b/sdk/lib/crt/float/isnan.c index 9eb904f7133..580639f3e76 100644 --- a/sdk/lib/crt/float/isnan.c +++ b/sdk/lib/crt/float/isnan.c @@ -36,19 +36,3 @@ int CDECL _isnan(double __x) x.__x = &__x; return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 )); } - -/* - * @implemented - */ -int CDECL _finite(double __x) -{ - union - { - double* __x; - double_s* x; - } x; - - x.__x = &__x; - - return ((x.x->exponent & 0x7ff) != 0x7ff); -} diff --git a/sdk/lib/crt/math/_finite.c b/sdk/lib/crt/math/_finite.c new file mode 100644 index 00000000000..a6cda90b59c --- /dev/null +++ b/sdk/lib/crt/math/_finite.c @@ -0,0 +1,19 @@ +/* + * PROJECT: ReactOS CRT + * LICENSE: MIT (https://spdx.org/licenses/MIT) + * PURPOSE: Implementation of _finite. + * COPYRIGHT: Copyright 2025 Timo Kreuzer + */ + +#include +#include + +_Check_return_ +int +__cdecl +_finite(_In_ double _X) +{ + union { double f; uint64_t ui64; } u = { _X }; + uint64_t exp = u.ui64 & 0x7FF0000000000000; + return (exp != 0x7FF0000000000000); +} diff --git a/sdk/lib/crt/math/_finitef.c b/sdk/lib/crt/math/_finitef.c new file mode 100644 index 00000000000..c4209471636 --- /dev/null +++ b/sdk/lib/crt/math/_finitef.c @@ -0,0 +1,19 @@ +/* + * PROJECT: ReactOS CRT + * LICENSE: MIT (https://spdx.org/licenses/MIT) + * PURPOSE: Implementation of _finitef. + * COPYRIGHT: Copyright 2025 Timo Kreuzer + */ + +#include +#include + +_Check_return_ +int +__cdecl +_finitef(_In_ float _X) +{ + union { float f; uint32_t ui32; } u = { _X }; + uint32_t exp = u.ui32 & 0x7F800000; + return (exp != 0x7F800000); +} diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake index 54acb6845b4..d1f8a1fa4a6 100644 --- a/sdk/lib/crt/math/math.cmake +++ b/sdk/lib/crt/math/math.cmake @@ -5,6 +5,8 @@ list(APPEND LIBCNTPR_MATH_SOURCE math/_chgsignf.c math/_dsign.c math/_fdsign.c + math/_finite.c + math/_finitef.c math/_invoke_matherr.c math/abs.c math/div.c