From 92862fdf399481998a490cf9cba175b9b41415ff Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 8 Nov 2024 02:49:21 +0200 Subject: [PATCH] LibC: Implement nan{,f,l} as functions One port was using function pointers to these functions so macros don't work. --- userspace/libraries/LibC/include/math.h | 6 +++--- userspace/libraries/LibC/math.cpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/userspace/libraries/LibC/include/math.h b/userspace/libraries/LibC/include/math.h index 9b62cbc3..df8d8a12 100644 --- a/userspace/libraries/LibC/include/math.h +++ b/userspace/libraries/LibC/include/math.h @@ -191,9 +191,9 @@ long lroundl(long double); double modf(double, double*); float modff(float, float*); long double modfl(long double, long double*); -#define nan(tagp) __builtin_nan(tagp) -#define nanf(tagp) __builtin_nanf(tagp) -#define nanl(tagp) __builtin_nanl(tagp) +double nan(const char*); +float nanf(const char*); +long double nanl(const char*); double nearbyint(double); float nearbyintf(float); long double nearbyintl(long double); diff --git a/userspace/libraries/LibC/math.cpp b/userspace/libraries/LibC/math.cpp index 67b7537c..355039df 100644 --- a/userspace/libraries/LibC/math.cpp +++ b/userspace/libraries/LibC/math.cpp @@ -249,6 +249,9 @@ BAN_FUNC1(logb) FUNC_EXPR1_RET(lrint, long, BAN::Math::rint(a)) FUNC_EXPR1_RET(lround, long, BAN::Math::round(a)) BAN_FUNC2_PTR(modf) +double nan(const char* tagp) { return __builtin_nan(tagp); } +float nanf(const char* tagp) { return __builtin_nanf(tagp); } +long double nanl(const char* tagp) { return __builtin_nanl(tagp); } FUNC_EXPR1(nearbyint, BAN::Math::rint(a)) FUNC_EXPR2(nextafter, nextafter_impl(a, b)) FUNC_EXPR2_TYPE(nexttoward, long double, nextafter_impl(a, b))