/* Copyright (c) 1994 Xerox Corporation.  All rights reserved. */
#include <doc/copyright.h>

/*
$Id$

$Date$
*
* The ieee float constants here were taken from SunOS 4.1.3
*/

#include <config/PCR←StdDefs.h>
#include <config/PCR←Arch.h>
#include <config/PCR←OS.h>


#include <math.h>

#if defined(PCR←OS←SUNOS4) || defined(PCR←OS←SUNOS5) \
	|| defined(PCR←OS←IRIX4) || defined(PCR←OS←IRIX5)
int
PCR←EmuHDieee←Dummy(double x)
{
    /* SVID & X/Open */
    x = erf(x);
    x = erfc(x);
    x = gamma(x);
    x = hypot(x,x);
    x = j0(x);
    x = j1(x);
    x = jn(11,x);
    x = lgamma(x);
    x = y0(x);
    x = y1(x);
    x = yn(11,x);
    /* SVID */
    x = acosh(x);
    x = asinh(x);
    x = atanh(x);
    return 0;
}

#   if defined(PCR←OS←SUNOS4)
int
PCR←EmuHDieee←DummyFPClass(double x)
{
    return (int) fp←class(x);
}
#   else
int
fp←class(double x)
{
    return (int) fpclass(x);
}
#   endif

#elif defined(PCR←OS←OS2) || defined(PCR←OS←linux) || defined(PCR←OS←bsdi)
/* don't know what to do here, but skip it for now */
#else
#   error ieee float?
#endif

/* 
 * IEEE double precision constants 
 */
static double align←←double = 0.0;
#if defined(PCR←Arch←ENDIAN0123) 
    /* little-endian */
static long ln2x[] = 		{ 0xfefa39ef, 0x3fe62e42 };
static long ln2hix[] = 		{ 0xfee00000, 0x3fe62e42 };
static long ln2lox[] = 		{ 0x35793c76, 0x3dea39ef };
static long NaNx[] = 		{ 0xffffffff, 0x7fffffff };
static long sNaNx[] = 		{ 0x00000001, 0x7ff00000 };
static long Infx[] = 		{ 0x00000000, 0x7ff00000 };
static long two52x[] = 		{ 0x00000000, 0x43300000 };
static long twom52x[] = 	{ 0x00000000, 0x3cb00000 };
static long PI←RZx[] = 		{ 0x54442d18, 0x400921fb };
static long sqrt2x[] = 		{ 0x667f3bcd, 0x3ff6a09e };/* rounded up */
static long sqrt2p1←hix[] = 	{ 0x333f9de6, 0x4003504f };
static long sqrt2p1←lox[] = 	{ 0xf626cdd5, 0x3ca21165 };
static long fmaxx[] = 		{ 0xffffffff, 0x7fefffff };
static long fminx[] = 		{ 0x00000001, 0x00000000 };
static long fminnx[] = 		{ 0x00000000, 0x00100000 };
static long fmaxsx[] = 		{ 0xffffffff, 0x000fffff };
static long lnovftx[] = 	{ 0xfefa39ef, 0x40862e42 };/* chopped */
static long lnunftx[] = 	{ 0xd52d3052, 0xc0874910 };/* ln(minf/2) chop*/
static long invln2x[] = 	{ 0x652b82fe, 0x3ff71547 };
#elif defined(PCR←ARCH←ENDIAN3210)
    /* big-endian */
static long ln2x[] = 		{ 0x3fe62e42, 0xfefa39ef };
static long ln2hix[] = 		{ 0x3fe62e42, 0xfee00000 };
static long ln2lox[] = 		{ 0x3dea39ef, 0x35793c76 };
static long NaNx[] = 		{ 0x7fffffff, 0xffffffff };
static long sNaNx[] = 		{ 0x7ff00000, 0x00000001 };
static long Infx[] = 		{ 0x7ff00000, 0x00000000 };
static long two52x[] = 		{ 0x43300000, 0x00000000 };
static long twom52x[] = 	{ 0x3cb00000, 0x00000000 };
static long PI←RZx[] = 		{ 0x400921fb, 0x54442d18 };
static long sqrt2x[] = 		{ 0x3ff6a09e, 0x667f3bcd };/* rounded up */
static long sqrt2p1←hix[] = 	{ 0x4003504f, 0x333f9de6 };
static long sqrt2p1←lox[] = 	{ 0x3ca21165, 0xf626cdd5 };
static long fmaxx[] = 		{ 0x7fefffff, 0xffffffff };
static long fminx[] = 		{ 0x00000000, 0x00000001 };
static long fminnx[] = 		{ 0x00100000, 0x00000000 };
static long fmaxsx[] = 		{ 0x000fffff, 0xffffffff };
static long lnovftx[] = 	{ 0x40862e42, 0xfefa39ef };/* chopped */
static long lnunftx[] = 	{ 0xc0874910, 0xd52d3052 };/* ln(minf/2) chop*/
static long invln2x[] = 	{ 0x3ff71547, 0x652b82fe };
#else
#   error constants not known
#endif

#define ln2 		(*(double*)ln2x)
#define NaN 		(*(double*)NaNx)
#define sNaN 		(*(double*)sNaNx)
#define Inf 		(*(double*)Infx)
#define two52 		(*(double*)two52x)
#define twom52 		(*(double*)twom52x)
#define ln2hi 		(*(double*)ln2hix)
#define ln2lo 		(*(double*)ln2lox)
#define PI←RZ 		(*(double*)PI←RZx)
#define sqrt2 		(*(double*)sqrt2x)
#define sqrt2p1←hi 	(*(double*)sqrt2p1←hix)
#define sqrt2p1←lo 	(*(double*)sqrt2p1←lox)
#define fmax 		(*(double*)fmaxx)
#define fmin 		(*(double*)fminx)
#define fminn 		(*(double*)fminnx)
#define fmaxs 		(*(double*)fmaxsx)
#define lnovft 		(*(double*)lnovftx)
#define lnunft 		(*(double*)lnunftx)
#define invln2 		(*(double*)invln2x)


double
min←subnormal(void)
{
    return fmin;
}

double
max←subnormal(void)
{
    return fmaxs;
}

double
min←normal(void)
{
    return fminn;
}

double
max←normal(void)
{
    return fmax;
}

double
infinity(void)
{
    return Inf;
}

double
quiet←nan(long n)
{
    return NaN;
}

double
signaling←nan(long n)
{
    return sNaN;
}

/*
$Log$
*/