Commit 8fb48945 authored by Raymond Toy's avatar Raymond Toy
Browse files

Remove the NetBSD setexception changes on the master branch. This is

only for the upcoming release.
parent 02c1bde6
......@@ -12,7 +12,7 @@ FDLIBM = k_sin.c k_cos.c k_tan.c s_sin.c s_cos.c s_tan.c sincos.c \
e_acosh.c s_asinh.c e_atanh.c \
e_atan2.c \
e_rem_pio2.c k_rem_pio2.c \
setexception.c double-values.c
setexception.c
SRCS = lisp.c coreparse.c alloc.c monitor.c print.c interr.c \
vars.c parse.c interrupt.c search.c validate.c globals.c \
......
/*
* Some helper functions to return specific double values for use by
* fdlibm_setexceptions on NetBSD. Currently, NetBSD doesn't have
* feraiseexcept so we have to do something special. See
* fdlibm_setexceptions.
*/
#include "fdlibm.h"
double
double_zero()
{
return 0.0;
}
/*
* Return most-positive-double-float
*/
double
double_huge()
{
union { int i[2]; double d; } ux;
ux.i[HIWORD] = 0x7fefffff;
ux.i[LOWORD] = 0xffffffff;
return ux.d;
}
/*
* Return least-positive-double-float
*/
double
double_tiny()
{
union { int i[2]; double d; } ux;
ux.i[HIWORD] = 0;
ux.i[LOWORD] = 1;
return ux.d;
}
#if defined(__NetBSD__)
/*
* NetBSD doesn't have fenv.h. At least the version currently being
* used to build cmucl doesn't. Assume this also means we don't have
* feraiseexcept. So, to generate the desired exceptions, we have to
* create the appropriate operations to generate the desired
* exceptions.
*/
#undef HAVE_FERAISEEXCEPT
extern double double_zero();
extern double double_huge();
extern double double_tiny();
#else
#define HAVE_FERAISEEXCEPT
#endif
#ifdef HAVE_FERAISEEXCEPT
#include <fenv.h>
#endif
#include <math.h>
#include <stdio.h>
......@@ -71,48 +50,32 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type)
/* Division by zero. Use the sign of x to get the correct
* signed infinity
*/
#ifdef HAVE_FERAISEEXCEPT
feraiseexcept(FE_DIVBYZERO);
ret = copysign(INFINITY, x);
#else
ret = copysign(1, x) / double_zero();
#endif
ret = copysign(INFINITY, x);
break;
case 1:
/* Underflow. Use the sign of x to get a signed zero. */
#ifdef HAVE_FERAISEEXCEPT
feraiseexcept(FE_UNDERFLOW);
ret = copysign(0.0, x);
#else
ret = double_tiny() * double_tiny();;
#endif
break;
case 2:
/* overflow */
#ifdef HAVE_FERAISEEXCEPT
feraiseexcept(FE_OVERFLOW);
ret = copysign(INFINITY, x);
#else
ret = double_huge() * copysign(double_huge(), x);
#endif
break;
case 3:
{
/* if */
/* invalid */
if (!isQNaN(x)) {
/*
* If it's not a quiet NaN, we want to signal an invalid
* operation. Otherwise, we silently return a NaN.
*/
#ifdef HAVE_FERAISEEXCEPT
feraiseexcept(FE_INVALID);
#else
ret = double_zero() / double_zero();
return ret;
#endif
}
/*
* FIXME: Of the many NaN values that we have, what NaN
* should we return?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment