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/ldbl-128/s_lrintl.c | |
parent | 948652e4f82f5aedbe882178ae158990bde63c79 (diff) | |
download | glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.tar.gz glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.tar.xz glibc-2b23ab1feab5a59bcc1931666663b2a8eac3fdbc.zip |
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/ldbl-128/s_lrintl.c')
-rw-r--r-- | sysdeps/ieee754/ldbl-128/s_lrintl.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_lrintl.c b/sysdeps/ieee754/ldbl-128/s_lrintl.c index e8ec02dc6f..ecb604a650 100644 --- a/sysdeps/ieee754/ldbl-128/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-128/s_lrintl.c @@ -24,16 +24,22 @@ #include <math_private.h> #include <libm-alias-ldouble.h> #include <fix-fp-int-convert-overflow.h> +#include <math-use-builtins.h> -static const _Float128 two112[2] = -{ - L(5.19229685853482762853049632922009600E+33), /* 0x406F000000000000, 0 */ - L(-5.19229685853482762853049632922009600E+33) /* 0xC06F000000000000, 0 */ -}; long int __lrintl (_Float128 x) { +#if USE_LRINTL_BUILTIN + return __builtin_lrintl (x); +#else + /* Use generic implementation. */ + static const _Float128 two112[2] = + { + L(5.19229685853482762853049632922009600E+33), /* 0x406F000000000000, 0 */ + L(-5.19229685853482762853049632922009600E+33) /* 0xC06F000000000000, 0 */ + }; + int32_t j0; uint64_t i0,i1; _Float128 w; @@ -131,6 +137,7 @@ __lrintl (_Float128 x) } return sx ? -result : result; +#endif /* ! USE_LRINTL_BUILTIN */ } libm_alias_ldouble (__lrint, lrint) |