aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-128
diff options
context:
space:
mode:
authorXiaolin Tang <tangxiaolin@loongson.cn>2022-11-23 11:44:58 +0800
committercaiyinyu <caiyinyu@loongson.cn>2022-11-29 16:00:28 +0800
commita1981ecbfd4aec84dea26936d91c8ed9164f8b13 (patch)
treed78cf6c9ba6e1b931c8ad01c9844c9665651175c /sysdeps/ieee754/ldbl-128
parente1697a540c49d5bd35e84b22fcd537c14f71a4e9 (diff)
downloadglibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.zip
glibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.tar.gz
glibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.tar.bz2
Use GCC builtins for llrint functions if desired.
This patch is using the corresponding GCC builtin for llrintf, llrint, llrintl and llrintf128 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')
-rw-r--r--sysdeps/ieee754/ldbl-128/s_llrintl.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_llrintl.c b/sysdeps/ieee754/ldbl-128/s_llrintl.c
index 79d3937..3a5635d 100644
--- a/sysdeps/ieee754/ldbl-128/s_llrintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_llrintl.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 long int
__llrintl (_Float128 x)
{
+#if USE_LLRINTL_BUILTIN
+ return __builtin_round (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;
@@ -102,6 +108,7 @@ __llrintl (_Float128 x)
}
return sx ? -result : result;
+#endif /* ! USE_LLRINTL_BUILTIN */
}
libm_alias_ldouble (__llrint, llrint)