/* Implement __kernel_standard_l.
- Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ Copyright (C) 2012-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>.
+ <https://www.gnu.org/licenses/>.
Parts based on k_standard.c from fdlibm: */
*/
#include <math.h>
-#include <math_private.h>
+#include <math-barriers.h>
+#include <math-svid-compat.h>
+#include <fenv.h>
#include <float.h>
#include <errno.h>
+#if LIBM_SVID_COMPAT
+
static double zero = 0.0;
/* Handle errors for a libm function as specified by TYPE (see
{
double dx, dy;
struct exception exc;
+ fenv_t env;
- if (isfinite (x))
- {
- long double ax = fabsl (x);
- if (ax > DBL_MAX)
- dx = __copysignl (DBL_MAX, x);
- else if (ax > 0 && ax < DBL_MIN)
- dx = __copysignl (DBL_MIN, x);
- else
- dx = x;
- }
- else
- dx = x;
- if (isfinite (y))
- {
- long double ay = fabsl (y);
- if (ay > DBL_MAX)
- dy = __copysignl (DBL_MAX, y);
- else if (ay > 0 && ay < DBL_MIN)
- dy = __copysignl (DBL_MIN, y);
- else
- dy = y;
- }
- else
- dy = y;
+ feholdexcept (&env);
+ dx = x;
+ dy = y;
+ math_force_eval (dx);
+ math_force_eval (dy);
+ fesetenv (&env);
switch (type)
{
{
exc.retval = HUGE;
y *= 0.5;
- if (x < zero && __rintl (y) != y)
+ if (x < zero && rintl (y) != y)
exc.retval = -HUGE;
}
else
{
exc.retval = HUGE_VAL;
y *= 0.5;
- if (x < zero && __rintl (y) != y)
+ if (x < zero && rintl (y) != y)
exc.retval = -HUGE_VAL;
}
if (_LIB_VERSION == _POSIX_)
exc.name = (char *) "powl";
exc.retval = zero;
y *= 0.5;
- if (x < zero && __rintl (y) != y)
+ if (x < zero && rintl (y) != y)
exc.retval = -zero;
if (_LIB_VERSION == _POSIX_)
__set_errno (ERANGE);
return __kernel_standard (dx, dy, type);
}
}
+#endif