aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/dbl-64/s_lrint.c
diff options
context:
space:
mode:
authorXiaolin Tang <tangxiaolin@loongson.cn>2022-11-23 11:44:56 +0800
committercaiyinyu <caiyinyu@loongson.cn>2022-11-29 16:00:28 +0800
commit2b23ab1feab5a59bcc1931666663b2a8eac3fdbc (patch)
tree037d70b1f7a836854162a9f86c2ed62a834130c7 /sysdeps/ieee754/dbl-64/s_lrint.c
parent948652e4f82f5aedbe882178ae158990bde63c79 (diff)
downloadglibc-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/dbl-64/s_lrint.c')
-rw-r--r--sysdeps/ieee754/dbl-64/s_lrint.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c
index d427291..2438503 100644
--- a/sysdeps/ieee754/dbl-64/s_lrint.c
+++ b/sysdeps/ieee754/dbl-64/s_lrint.c
@@ -25,17 +25,22 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-fp-int-convert-overflow.h>
-
-static const double two52[2] =
-{
- 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
-};
+#include <math-use-builtins.h>
long int
__lrint (double x)
{
+#if USE_LRINT_BUILTIN
+ return __builtin_lrint (x);
+#else
+ /* Use generic implementation. */
+ static const double two52[2] =
+ {
+ 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+ -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
+ };
+
int32_t j0;
uint32_t i0, i1;
double w;
@@ -119,6 +124,7 @@ __lrint (double x)
}
return sx ? -result : result;
+#endif /* ! USE_LRINT_BUILTIN */
}
libm_alias_double (__lrint, lrint)