version 1.1.1.2, 2011/03/19 16:26:37 |
version 1.9, 2011/03/20 23:15:35 |
|
|
|
/* $NetBSD$ */ |
|
|
/**************************************************************** |
/**************************************************************** |
|
|
The author of this software is David M. Gay. |
The author of this software is David M. Gay. |
|
|
*/ |
*/ |
|
|
/* |
/* |
* #define IEEE_8087 for IEEE-arithmetic machines where the least |
* #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least |
* significant byte has the lowest address. |
* significant byte has the lowest address. |
* #define IEEE_MC68k for IEEE-arithmetic machines where the most |
* #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most |
* significant byte has the lowest address. |
* significant byte has the lowest address. |
* #define Long int on machines with 32-bit ints and 64-bit longs. |
* #define Long int on machines with 32-bit ints and 64-bit longs. |
* #define Sudden_Underflow for IEEE-format machines without gradual |
* #define Sudden_Underflow for IEEE-format machines without gradual |
|
|
* #define USE_LOCALE to use the current locale's decimal_point value. |
* #define USE_LOCALE to use the current locale's decimal_point value. |
*/ |
*/ |
|
|
|
/* #define IEEE_{BIG,LITTLE}_ENDIAN in ${ARCHDIR}/gdtoa/arith.h */ |
|
|
|
#include <stdint.h> |
|
#define Short int16_t |
|
#define UShort uint16_t |
|
#define Long int32_t |
|
#define ULong uint32_t |
|
#define LLong int64_t |
|
#define ULLong uint64_t |
|
|
|
#define INFNAN_CHECK |
|
#ifdef _REENTRANT |
|
#define MULTIPLE_THREADS |
|
#endif |
|
#define USE_LOCALE |
|
|
#ifndef GDTOAIMP_H_INCLUDED |
#ifndef GDTOAIMP_H_INCLUDED |
#define GDTOAIMP_H_INCLUDED |
#define GDTOAIMP_H_INCLUDED |
#include "gdtoa.h" |
#include "gdtoa.h" |
Line 205 extern Char *MALLOC ANSI((size_t)); |
|
Line 223 extern Char *MALLOC ANSI((size_t)); |
|
|
|
#undef IEEE_Arith |
#undef IEEE_Arith |
#undef Avoid_Underflow |
#undef Avoid_Underflow |
#ifdef IEEE_MC68k |
#ifdef IEEE_BIG_ENDIAN |
#define IEEE_Arith |
#define IEEE_Arith |
#endif |
#endif |
#ifdef IEEE_8087 |
#ifdef IEEE_LITTLE_ENDIAN |
#define IEEE_Arith |
#define IEEE_Arith |
#endif |
#endif |
|
|
Line 261 extern Char *MALLOC ANSI((size_t)); |
|
Line 279 extern Char *MALLOC ANSI((size_t)); |
|
#define n_bigtens 2 |
#define n_bigtens 2 |
#endif |
#endif |
|
|
#ifndef __MATH_H__ |
|
#include "math.h" |
#include "math.h" |
#endif |
|
|
|
#ifdef __cplusplus |
#ifdef __cplusplus |
extern "C" { |
extern "C" { |
#endif |
#endif |
|
|
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1 |
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. |
#endif |
#endif |
|
|
typedef union { double d; ULong L[2]; } U; |
typedef union { double d; ULong L[2]; } __attribute__((__may_alias__)) U; |
|
|
#ifdef IEEE_8087 |
#ifdef YES_ALIAS |
#define word0(x) (x)->L[1] |
#define dval(x) x |
#define word1(x) (x)->L[0] |
#ifdef IEEE_LITTLE_ENDIAN |
|
#define word0(x) ((ULong *)x)[1] |
|
#define word1(x) ((ULong *)x)[0] |
#else |
#else |
#define word0(x) (x)->L[0] |
#define word0(x) ((ULong *)x)[0] |
#define word1(x) (x)->L[1] |
#define word1(x) ((ULong *)x)[1] |
#endif |
#endif |
#define dval(x) (x)->d |
#else /* !YES_ALIAS */ |
|
#ifdef IEEE_LITTLE_ENDIAN |
|
#define word0(x) ( /* LINTED */ (U*)x)->L[1] |
|
#define word1(x) ( /* LINTED */ (U*)x)->L[0] |
|
#else |
|
#define word0(x) ( /* LINTED */ (U*)x)->L[0] |
|
#define word1(x) ( /* LINTED */ (U*)x)->L[1] |
|
#endif |
|
#define dval(x) ( /* LINTED */ (U*)x)->d |
|
#endif /* YES_ALIAS */ |
|
|
/* The following definition of Storeinc is appropriate for MIPS processors. |
/* The following definition of Storeinc is appropriate for MIPS processors. |
* An alternative that might be better on some machines is |
* An alternative that might be better on some machines is |
* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) |
* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) |
*/ |
*/ |
#if defined(IEEE_8087) + defined(VAX) |
#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) |
#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ |
#define Storeinc(a,b,c) \ |
((unsigned short *)a)[0] = (unsigned short)c, a++) |
(((unsigned short *)(void *)a)[1] = (unsigned short)b, \ |
#else |
((unsigned short *)(void *)a)[0] = (unsigned short)c, \ |
#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ |
a++) |
((unsigned short *)a)[1] = (unsigned short)c, a++) |
#else |
|
#define Storeinc(a,b,c) \ |
|
(((unsigned short *)(void *)a)[0] = (unsigned short)b, \ |
|
((unsigned short *)(void *)a)[1] = (unsigned short)c, \ |
|
a++) |
#endif |
#endif |
|
|
/* #define P DBL_MANT_DIG */ |
/* #define P DBL_MANT_DIG */ |
Line 459 extern double rnd_prod(double, double), |
|
Line 490 extern double rnd_prod(double, double), |
|
#ifndef MULTIPLE_THREADS |
#ifndef MULTIPLE_THREADS |
#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ |
#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ |
#define FREE_DTOA_LOCK(n) /*nothing*/ |
#define FREE_DTOA_LOCK(n) /*nothing*/ |
|
#else |
|
#include "reentrant.h" |
|
|
|
extern mutex_t __gdtoa_locks[2]; |
|
|
|
#define ACQUIRE_DTOA_LOCK(n) \ |
|
do { \ |
|
if (__isthreaded) \ |
|
mutex_lock(&__gdtoa_locks[n]); \ |
|
} while (/* CONSTCOND */ 0) |
|
#define FREE_DTOA_LOCK(n) \ |
|
do { \ |
|
if (__isthreaded) \ |
|
mutex_unlock(&__gdtoa_locks[n]); \ |
|
} while (/* CONSTCOND */ 0) |
#endif |
#endif |
|
|
#define Kmax 9 |
#define Kmax (sizeof(size_t) << 3) |
|
|
struct |
struct |
Bigint { |
Bigint { |
Line 482 extern void memcpy_D2A ANSI((void*, cons |
|
Line 528 extern void memcpy_D2A ANSI((void*, cons |
|
#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) |
#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) |
#endif /* NO_STRING_H */ |
#endif /* NO_STRING_H */ |
|
|
#define Balloc Balloc_D2A |
#define Balloc __Balloc_D2A |
#define Bfree Bfree_D2A |
#define Bfree __Bfree_D2A |
#define ULtoQ ULtoQ_D2A |
#define ULtoQ __ULtoQ_D2A |
#define ULtof ULtof_D2A |
#define ULtof __ULtof_D2A |
#define ULtod ULtod_D2A |
#define ULtod __ULtod_D2A |
#define ULtodd ULtodd_D2A |
#define ULtodd __ULtodd_D2A |
#define ULtox ULtox_D2A |
#define ULtox __ULtox_D2A |
#define ULtoxL ULtoxL_D2A |
#define ULtoxL __ULtoxL_D2A |
#define any_on any_on_D2A |
#define any_on __any_on_D2A |
#define b2d b2d_D2A |
#define b2d __b2d_D2A |
#define bigtens bigtens_D2A |
#define bigtens __bigtens_D2A |
#define cmp cmp_D2A |
#define cmp __cmp_D2A |
#define copybits copybits_D2A |
#define copybits __copybits_D2A |
#define d2b d2b_D2A |
#define d2b __d2b_D2A |
#define decrement decrement_D2A |
#define decrement __decrement_D2A |
#define diff diff_D2A |
#define diff __diff_D2A |
#define dtoa_result dtoa_result_D2A |
#define dtoa_result __dtoa_result_D2A |
#define g__fmt g__fmt_D2A |
#define g__fmt __g__fmt_D2A |
#define gethex gethex_D2A |
#define gethex __gethex_D2A |
#define hexdig hexdig_D2A |
#define hexdig __hexdig_D2A |
#define hexnan hexnan_D2A |
#define hexdig_init_D2A __hexdig_init_D2A |
#define hi0bits(x) hi0bits_D2A((ULong)(x)) |
#define hexnan __hexnan_D2A |
#define i2b i2b_D2A |
#define hi0bits __hi0bits_D2A |
#define increment increment_D2A |
#define hi0bits_D2A __hi0bits_D2A |
#define lo0bits lo0bits_D2A |
#define i2b __i2b_D2A |
#define lshift lshift_D2A |
#define increment __increment_D2A |
#define match match_D2A |
#define lo0bits __lo0bits_D2A |
#define mult mult_D2A |
#define lshift __lshift_D2A |
#define multadd multadd_D2A |
#define match __match_D2A |
#define nrv_alloc nrv_alloc_D2A |
#define mult __mult_D2A |
#define pow5mult pow5mult_D2A |
#define multadd __multadd_D2A |
#define quorem quorem_D2A |
#define nrv_alloc __nrv_alloc_D2A |
#define ratio ratio_D2A |
#define pow5mult __pow5mult_D2A |
#define rshift rshift_D2A |
#define quorem __quorem_D2A |
#define rv_alloc rv_alloc_D2A |
#define ratio __ratio_D2A |
#define s2b s2b_D2A |
#define rshift __rshift_D2A |
#define set_ones set_ones_D2A |
#define rv_alloc __rv_alloc_D2A |
#define strcp strcp_D2A |
#define s2b __s2b_D2A |
#define strtoIg strtoIg_D2A |
#define set_ones __set_ones_D2A |
#define sum sum_D2A |
#define strcp __strcp_D2A |
#define tens tens_D2A |
#define strcp_D2A __strcp_D2A |
#define tinytens tinytens_D2A |
#define strtoIg __strtoIg_D2A |
#define tinytens tinytens_D2A |
#define sum __sum_D2A |
#define trailz trailz_D2A |
#define tens __tens_D2A |
#define ulp ulp_D2A |
#define tinytens __tinytens_D2A |
|
#define tinytens __tinytens_D2A |
|
#define trailz __trailz_D2A |
|
#define ulp __ulp_D2A |
|
|
extern char *dtoa_result; |
extern char *dtoa_result; |
extern CONST double bigtens[], tens[], tinytens[]; |
extern CONST double bigtens[], tens[], tinytens[]; |
extern unsigned char hexdig[]; |
extern unsigned char hexdig[]; |
|
|
extern Bigint *Balloc ANSI((int)); |
extern Bigint *Balloc ANSI((size_t)); |
extern void Bfree ANSI((Bigint*)); |
extern void Bfree ANSI((Bigint*)); |
extern void ULtof ANSI((ULong*, ULong*, Long, int)); |
extern void ULtof ANSI((ULong*, ULong*, Long, int)); |
extern void ULtod ANSI((ULong*, ULong*, Long, int)); |
extern void ULtod ANSI((ULong*, ULong*, Long, int)); |
Line 550 extern void memcpy_D2A ANSI((void*, cons |
|
Line 599 extern void memcpy_D2A ANSI((void*, cons |
|
extern char *dtoa ANSI((double d, int mode, int ndigits, |
extern char *dtoa ANSI((double d, int mode, int ndigits, |
int *decpt, int *sign, char **rve)); |
int *decpt, int *sign, char **rve)); |
extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t)); |
extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t)); |
extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int)); |
extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int)); |
extern void hexdig_init_D2A(Void); |
extern void hexdig_init_D2A(Void); |
extern int hexnan ANSI((CONST char**, FPI*, ULong*)); |
extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*)); |
extern int hi0bits_D2A ANSI((ULong)); |
extern int hi0bits_D2A ANSI((ULong)); |
extern Bigint *i2b ANSI((int)); |
extern Bigint *i2b ANSI((int)); |
extern Bigint *increment ANSI((Bigint*)); |
extern Bigint *increment ANSI((Bigint*)); |
extern int lo0bits ANSI((ULong*)); |
extern int lo0bits ANSI((ULong*)); |
extern Bigint *lshift ANSI((Bigint*, int)); |
extern Bigint *lshift ANSI((Bigint*, int)); |
extern int match ANSI((CONST char**, char*)); |
extern int match ANSI((CONST char**, CONST char*)); |
extern Bigint *mult ANSI((Bigint*, Bigint*)); |
extern Bigint *mult ANSI((Bigint*, Bigint*)); |
extern Bigint *multadd ANSI((Bigint*, int, int)); |
extern Bigint *multadd ANSI((Bigint*, int, int)); |
extern char *nrv_alloc ANSI((char*, char **, int)); |
extern char *nrv_alloc ANSI((CONST char*, char **, size_t)); |
extern Bigint *pow5mult ANSI((Bigint*, int)); |
extern Bigint *pow5mult ANSI((Bigint*, int)); |
extern int quorem ANSI((Bigint*, Bigint*)); |
extern int quorem ANSI((Bigint*, Bigint*)); |
extern double ratio ANSI((Bigint*, Bigint*)); |
extern double ratio ANSI((Bigint*, Bigint*)); |
extern void rshift ANSI((Bigint*, int)); |
extern void rshift ANSI((Bigint*, int)); |
extern char *rv_alloc ANSI((int)); |
extern char *rv_alloc ANSI((size_t)); |
extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int)); |
extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int)); |
extern Bigint *set_ones ANSI((Bigint*, int)); |
extern Bigint *set_ones ANSI((Bigint*, int)); |
extern char *strcp ANSI((char*, const char*)); |
extern char *strcp ANSI((char*, const char*)); |
extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); |
extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); |
extern double strtod ANSI((const char *s00, char **se)); |
extern double strtod ANSI((const char *s00, char **se)); |
extern Bigint *sum ANSI((Bigint*, Bigint*)); |
extern Bigint *sum ANSI((Bigint*, Bigint*)); |
extern int trailz ANSI((Bigint*)); |
extern int trailz ANSI((CONST Bigint*)); |
|
/*###626 [lint] syntax error '*' [249]%%%*/ |
|
/*###626 [lint] incomplete or misplaced function definition [22]%%%*/ |
extern double ulp ANSI((U*)); |
extern double ulp ANSI((U*)); |
|
|
#ifdef __cplusplus |
#ifdef __cplusplus |
Line 593 extern void memcpy_D2A ANSI((void*, cons |
|
Line 644 extern void memcpy_D2A ANSI((void*, cons |
|
#undef INFNAN_CHECK |
#undef INFNAN_CHECK |
#define INFNAN_CHECK |
#define INFNAN_CHECK |
#endif |
#endif |
#ifdef IEEE_MC68k |
#ifdef IEEE_BIG_ENDIAN |
#define _0 0 |
#define _0 0 |
#define _1 1 |
#define _1 1 |
#ifndef NAN_WORD0 |
#ifndef NAN_WORD0 |