mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
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>
This commit is contained in:
parent
e1697a540c
commit
a1981ecbfd
4
sysdeps/generic/math-use-builtins-llrint.h
Normal file
4
sysdeps/generic/math-use-builtins-llrint.h
Normal file
@ -0,0 +1,4 @@
|
||||
#define USE_LLRINT_BUILTIN 0
|
||||
#define USE_LLRINTF_BUILTIN 0
|
||||
#define USE_LLRINTL_BUILTIN 0
|
||||
#define USE_LLRINTF128_BUILTIN 0
|
@ -38,5 +38,6 @@
|
||||
#include <math-use-builtins-fmin.h>
|
||||
#include <math-use-builtins-fabs.h>
|
||||
#include <math-use-builtins-lrint.h>
|
||||
#include <math-use-builtins-llrint.h>
|
||||
|
||||
#endif /* MATH_USE_BUILTINS_H */
|
||||
|
@ -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 long int
|
||||
__llrint (double x)
|
||||
{
|
||||
#if USE_LLRINT_BUILTIN
|
||||
return __builtin_llrint (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 i1, i0;
|
||||
long long int result;
|
||||
@ -95,6 +100,7 @@ __llrint (double x)
|
||||
}
|
||||
|
||||
return sx ? -result : result;
|
||||
#endif /* ! USE_LLRINT_BUILTIN */
|
||||
}
|
||||
|
||||
libm_alias_double (__llrint, llrint)
|
||||
|
@ -163,6 +163,8 @@
|
||||
#define USE_FMAL_BUILTIN USE_FMAF128_BUILTIN
|
||||
#undef USE_LRINTL_BUILTIN
|
||||
#define USE_LRINTL_BUILTIN USE_LRINTF128_BUILTIN
|
||||
#undef USE_LLRINTL_BUILTIN
|
||||
#define USE_LLRINTL_BUILTIN USE_LLRINTF128_BUILTIN
|
||||
|
||||
/* IEEE function renames. */
|
||||
#define __ieee754_acoshl __ieee754_acoshf128
|
||||
|
@ -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 long int
|
||||
__llrintf (float x)
|
||||
{
|
||||
#if USE_LLRINTF_BUILTIN
|
||||
return __builtin_llrintf (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 @@ __llrintf (float x)
|
||||
}
|
||||
|
||||
return sx ? -result : result;
|
||||
#endif /* ! USE_LLRINTF_BUILTIN */
|
||||
}
|
||||
|
||||
libm_alias_float (__llrint, llrint)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user