From: Wilco Dijkstra Date: Wed, 15 Oct 2025 16:39:54 +0000 (+0000) Subject: math: Add builtin support for (l)lround(f) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35807cc5cddf8de09f69f530d628a710121531b8;p=thirdparty%2Fglibc.git math: Add builtin support for (l)lround(f) Add builtin support for (l)lround(f) via the math-use-builtins header mechanism. Reviewed-by: Adhemerval Zanella  --- diff --git a/sysdeps/generic/math-use-builtins-llround.h b/sysdeps/generic/math-use-builtins-llround.h new file mode 100644 index 0000000000..aa0f8c705d --- /dev/null +++ b/sysdeps/generic/math-use-builtins-llround.h @@ -0,0 +1,4 @@ +#define USE_LLROUND_BUILTIN 0 +#define USE_LLROUNDF_BUILTIN 0 +#define USE_LLROUNDL_BUILTIN 0 +#define USE_LLROUNDF128_BUILTIN 0 diff --git a/sysdeps/generic/math-use-builtins-lround.h b/sysdeps/generic/math-use-builtins-lround.h new file mode 100644 index 0000000000..b93c86ed75 --- /dev/null +++ b/sysdeps/generic/math-use-builtins-lround.h @@ -0,0 +1,4 @@ +#define USE_LROUND_BUILTIN 0 +#define USE_LROUNDF_BUILTIN 0 +#define USE_LROUNDL_BUILTIN 0 +#define USE_LROUNDF128_BUILTIN 0 diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index b373bde439..e069b161b1 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -41,5 +41,7 @@ #include #include #include +#include +#include #endif /* MATH_USE_BUILTINS_H */ diff --git a/sysdeps/ieee754/dbl-64/s_llround.c b/sysdeps/ieee754/dbl-64/s_llround.c index 0a07722c23..e86d3dcb67 100644 --- a/sysdeps/ieee754/dbl-64/s_llround.c +++ b/sysdeps/ieee754/dbl-64/s_llround.c @@ -27,10 +27,14 @@ #include #include #include +#include long long int __llround (double x) { +#if USE_LLROUND_BUILTIN + return __builtin_llround (x); +#else int32_t j0; int64_t i0; long long int result; @@ -71,6 +75,7 @@ __llround (double x) } return sign * result; +#endif /* ! USE_LLROUND_BUILTIN */ } libm_alias_double (__llround, llround) diff --git a/sysdeps/ieee754/dbl-64/s_lround.c b/sysdeps/ieee754/dbl-64/s_lround.c index ba98b35b7c..e92fa5ceed 100644 --- a/sysdeps/ieee754/dbl-64/s_lround.c +++ b/sysdeps/ieee754/dbl-64/s_lround.c @@ -23,6 +23,7 @@ #include #include #include +#include /* For LP64, lround is an alias for llround. */ #ifndef _LP64 @@ -30,6 +31,9 @@ long int __lround (double x) { +#if USE_LROUND_BUILTIN + return __builtin_lround (x); +#else int32_t j0; int64_t i0; long int result; @@ -90,6 +94,7 @@ __lround (double x) } return sign * result; +#endif /* ! USE_LROUND_BUILTIN */ } libm_alias_double (__lround, lround) diff --git a/sysdeps/ieee754/flt-32/s_llroundf.c b/sysdeps/ieee754/flt-32/s_llroundf.c index e19b3072fc..bb92acbc49 100644 --- a/sysdeps/ieee754/flt-32/s_llroundf.c +++ b/sysdeps/ieee754/flt-32/s_llroundf.c @@ -23,11 +23,14 @@ #include #include #include - +#include long long int __llroundf (float x) { +#if USE_LLROUNDF_BUILTIN + return __builtin_llroundf (x); +#else int32_t j0; uint32_t i; long long int result; @@ -68,6 +71,7 @@ __llroundf (float x) } return sign * result; +#endif /* ! USE_LLROUNDF_BUILTIN */ } libm_alias_float (__llround, llround) diff --git a/sysdeps/ieee754/flt-32/s_lroundf.c b/sysdeps/ieee754/flt-32/s_lroundf.c index 117e98d6c9..f31c53136a 100644 --- a/sysdeps/ieee754/flt-32/s_lroundf.c +++ b/sysdeps/ieee754/flt-32/s_lroundf.c @@ -23,11 +23,14 @@ #include #include #include - +#include long int __lroundf (float x) { +#if USE_LROUNDF_BUILTIN + return __builtin_lroundf (x); +#else int32_t j0; uint32_t i; long int result; @@ -68,6 +71,7 @@ __lroundf (float x) } return sign * result; +#endif /* ! USE_LROUNDF_BUILTIN */ } libm_alias_float (__lround, lround)