softfloat-native.h revision 4c37c32b924cb13b821f9d2e01f42cabbd3d9cf9
/* Native implementation of soft float functions */
#include <math.h>
#include <ieeefp.h>
#else
#include <fenv.h>
#endif
#if defined(__OpenBSD__) || defined(__NetBSD__)
#endif
/*
* Define some C99-7.12.3 classification macros and
* some C99-.12.4 for Solaris systems OS less than 10,
* or Solaris 10 systems running GCC 3.x or less.
* Solaris 10 with GCC4 does not need these macros as they
* are defined in <iso/math_c99.h> with a compiler directive
*/
&& (__GNUC__ < 4))) \
/*
* C99 7.12.3 classification macros
* and
* C99 7.12.14 comparison macros
*
* ... do not work on Solaris 10 using GNU CC 3.4.x.
* Try to workaround the missing / broken C99 math macros.
*/
#if defined(__OpenBSD__)
#endif
#ifdef __NetBSD__
#ifndef isgreater
#define isgreater(x, y) __builtin_isgreater(x, y)
#endif
#ifndef isgreaterequal
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
#endif
#ifndef isless
#define isless(x, y) __builtin_isless(x, y)
#endif
#ifndef islessequal
#define islessequal(x, y) __builtin_islessequal(x, y)
#endif
#ifndef isunordered
#define isunordered(x, y) __builtin_isunordered(x, y)
#endif
#endif
#define isgreaterequal(x, y) ((!unordered(x, y)) && ((x) >= (y)))
#define islessequal(x, y) ((!unordered(x, y)) && ((x) <= (y)))
#define isunordered(x,y) unordered(x, y)
#endif
#if defined(__sun__) && !defined(NEED_LIBSUNMATH)
#ifndef isnan
# define isnan(x) \
(sizeof (x) == sizeof (long double) ? isnan_ld (x) \
: sizeof (x) == sizeof (double) ? isnan_d (x) \
: isnan_f (x))
static inline int isnan_f (float x) { return x != x; }
static inline int isnan_d (double x) { return x != x; }
static inline int isnan_ld (long double x) { return x != x; }
#endif
#ifndef isinf
# define isinf(x) \
(sizeof (x) == sizeof (long double) ? isinf_ld (x) \
: sizeof (x) == sizeof (double) ? isinf_d (x) \
: isinf_f (x))
#endif
#endif
typedef float float32;
typedef double float64;
#ifdef FLOATX80
typedef long double floatx80;
#endif
typedef union {
float32 f;
uint32_t i;
} float32u;
typedef union {
float64 f;
uint64_t i;
} float64u;
#ifdef FLOATX80
typedef union {
floatx80 f;
struct {
} i;
} floatx80u;
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#if defined(__OpenBSD__)
#endif
enum {
};
enum {
float_round_down = 1,
float_round_up = 2,
};
#else
enum {
};
#endif
typedef struct float_status {
int float_rounding_mode;
#ifdef FLOATX80
#endif
} float_status;
#ifdef FLOATX80
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef FLOATX80
#endif
#ifdef FLOAT128
#endif
#ifdef FLOATX80
#endif
#ifdef FLOAT128
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef FLOATX80
#endif
#ifdef FLOAT128
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
{
return a + b;
}
{
return a - b;
}
{
return a * b;
}
{
return a / b;
}
{
return a == b;
}
{
return a <= b;
}
{
return a < b;
}
{
return a <= b && a >= b;
}
{
return islessequal(a, b);
}
{
return isless(a, b);
}
{
return isunordered(a, b);
}
int float32_is_signaling_nan( float32 );
int float32_is_nan( float32 );
{
return fabsf(a);
}
{
return -a;
}
{
return fpclassify(a) == FP_INFINITE;
}
{
float32u u;
u.f = a;
return u.i >> 31;
}
{
return fpclassify(a) == FP_ZERO;
}
{
return scalbnf(a, n);
}
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef FLOATX80
#endif
#ifdef FLOAT128
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
{
return a + b;
}
{
return a - b;
}
{
return a * b;
}
{
return a / b;
}
{
return a == b;
}
{
return a <= b;
}
{
return a < b;
}
{
return a <= b && a >= b;
}
{
return islessequal(a, b);
}
{
return isless(a, b);
}
{
return isunordered(a, b);
}
int float64_is_signaling_nan( float64 );
int float64_is_nan( float64 );
{
return fabs(a);
}
{
return -a;
}
{
return fpclassify(a) == FP_INFINITE;
}
{
float64u u;
u.f = a;
return u.i >> 63;
}
{
return fpclassify(a) == FP_ZERO;
}
{
return scalbn(a, n);
}
#ifdef FLOATX80
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef FLOAT128
#endif
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
{
return a + b;
}
{
return a - b;
}
{
return a * b;
}
{
return a / b;
}
{
return a == b;
}
{
return a <= b;
}
{
return a < b;
}
{
return a <= b && a >= b;
}
{
return islessequal(a, b);
}
{
return isless(a, b);
}
{
return isunordered(a, b);
}
int floatx80_is_signaling_nan( floatx80 );
int floatx80_is_nan( floatx80 );
{
return fabsl(a);
}
{
return -a;
}
{
return fpclassify(a) == FP_INFINITE;
}
{
floatx80u u;
u.f = a;
return u.i.high >> 15;
}
{
return fpclassify(a) == FP_ZERO;
}
{
return scalbnl(a, n);
}
#endif