diff options
author | Xiaolin Tang <tangxiaolin@loongson.cn> | 2022-11-23 11:44:56 +0800 |
---|---|---|
committer | caiyinyu <caiyinyu@loongson.cn> | 2022-11-29 16:00:28 +0800 |
commit | 2b23ab1feab5a59bcc1931666663b2a8eac3fdbc (patch) | |
tree | 037d70b1f7a836854162a9f86c2ed62a834130c7 /sysdeps/ieee754/flt-32/s_lrintf.c | |
parent | 948652e4f82f5aedbe882178ae158990bde63c79 (diff) | |
download | glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.zip glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.tar.gz glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.tar.bz2 |
Use GCC builtins for lrint functions if desired.
This patch is using the corresponding GCC builtin for lrintf, lrint,
lrintl and lrintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins-function.h.
Co-Authored-By: Xi Ruoyao <xry111@xry111.site>
Diffstat (limited to 'sysdeps/ieee754/flt-32/s_lrintf.c')
-rw-r--r-- | sysdeps/ieee754/flt-32/s_lrintf.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c index 7438b27..50d044d 100644 --- a/sysdeps/ieee754/flt-32/s_lrintf.c +++ b/sysdeps/ieee754/flt-32/s_lrintf.c @@ -25,17 +25,22 @@ #include <math_private.h> #include <libm-alias-float.h> #include <fix-fp-int-convert-overflow.h> - -static const float two23[2] = -{ - 8.3886080000e+06, /* 0x4B000000 */ - -8.3886080000e+06, /* 0xCB000000 */ -}; +#include <math-use-builtins.h> long int __lrintf (float x) { +#if USE_LRINTF_BUILTIN + return __builtin_lrintf (x); +#else + /* Use generic implementation. */ + static const float two23[2] = + { + 8.3886080000e+06, /* 0x4B000000 */ + -8.3886080000e+06, /* 0xCB000000 */ + }; + int32_t j0; uint32_t i0; float w; @@ -82,6 +87,7 @@ __lrintf (float x) } return sx ? -result : result; +#endif /* ! USE_LRINTF_BUILTIN */ } libm_alias_float (__lrint, lrint) |