summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/gdtoa/gdtoaimp.h
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/gdtoa/gdtoaimp.h')
-rwxr-xr-xwinsup/mingw/mingwex/gdtoa/gdtoaimp.h188
1 files changed, 92 insertions, 96 deletions
diff --git a/winsup/mingw/mingwex/gdtoa/gdtoaimp.h b/winsup/mingw/mingwex/gdtoa/gdtoaimp.h
index 04e625cff..69f4ab809 100755
--- a/winsup/mingw/mingwex/gdtoa/gdtoaimp.h
+++ b/winsup/mingw/mingwex/gdtoa/gdtoaimp.h
@@ -2,7 +2,7 @@
The author of this software is David M. Gay.
-Copyright (C) 1998-2008 by Lucent Technologies
+Copyright (C) 1998-2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
@@ -126,17 +126,22 @@ THIS SOFTWARE.
* conversions of IEEE doubles in single-threaded executions with
* 8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with
* 4-byte pointers, PRIVATE_MEM >= 7112 appears adequate.
- * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
- * Infinity and NaN (case insensitively).
+ * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK
+ * #defined automatically on IEEE systems. On such systems,
+ * when INFNAN_CHECK is #defined, strtod checks
+ * for Infinity and NaN (case insensitively).
* When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
* strtodg also accepts (case insensitively) strings of the form
- * NaN(x), where x is a string of hexadecimal digits and spaces;
- * if there is only one string of hexadecimal digits, it is taken
- * for the fraction bits of the resulting NaN; if there are two or
- * more strings of hexadecimal digits, each string is assigned
- * to the next available sequence of 32-bit words of fractions
- * bits (starting with the most significant), right-aligned in
- * each sequence.
+ * NaN(x), where x is a string of hexadecimal digits (optionally
+ * preceded by 0x or 0X) and spaces; if there is only one string
+ * of hexadecimal digits, it is taken for the fraction bits of the
+ * resulting NaN; if there are two or more strings of hexadecimal
+ * digits, each string is assigned to the next available sequence
+ * of 32-bit words of fractions bits (starting with the most
+ * significant), right-aligned in each sequence.
+ * Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)"
+ * is consumed even when ... has the wrong form (in which case the
+ * "(...)" is consumed but ignored).
* #define MULTIPLE_THREADS if the system offers preemptively scheduled
* multiple threads. In this case, you must provide (or suitably
* #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
@@ -157,11 +162,6 @@ THIS SOFTWARE.
* #define NO_STRING_H to use private versions of memcpy.
* On some K&R systems, it may also be necessary to
* #define DECLARE_SIZE_T in this case.
- * #define YES_ALIAS to permit aliasing certain double values with
- * arrays of ULongs. This leads to slightly better code with
- * some compilers and was always used prior to 19990916, but it
- * is not strictly legal and can cause trouble with aggressively
- * optimizing compilers (e.g., gcc 2.95.1 under -O2).
* #define USE_LOCALE to use the current locale's decimal_point value.
*/
@@ -170,9 +170,15 @@ THIS SOFTWARE.
#include "gdtoa.h"
#include "gd_qnan.h"
-#define INFNAN_CHECK 1
+#if defined(__MINGW32__) || defined(__MINGW64__)
#define MULTIPLE_THREADS 1
#define USE_LOCALE 1
+#define NO_LOCALE_CACHE 1
+#endif /* MinGW */
+
+#ifdef Honor_FLT_ROUNDS
+#include <fenv.h>
+#endif
#ifdef DEBUG
#include <stdio.h>
@@ -182,14 +188,8 @@ THIS SOFTWARE.
#include <stdlib.h>
#include <string.h>
-#ifdef KR_headers
-#define Char char
-#else
-#define Char void
-#endif
-
#ifdef MALLOC
-extern Char *MALLOC ANSI((size_t));
+extern void *MALLOC (size_t);
#else
#define MALLOC malloc
#endif
@@ -204,6 +204,14 @@ extern Char *MALLOC ANSI((size_t));
#endif
#include <errno.h>
+
+#ifdef NO_ERRNO
+#define SET_ERRNO(x)
+#else
+#define SET_ERRNO(x) \
+ errno = (x)
+#endif
+
#ifdef Bad_float_h
#ifdef IEEE_Arith
@@ -264,27 +272,16 @@ extern "C" {
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
#endif
-typedef union { double d; ULong L[2]; } U;
+typedef union _dbl_union { double d; ULong L[2]; } dbl_union;
-#ifdef YES_ALIAS
-#define dval(x) x
#ifdef IEEE_8087
-#define word0(x) ((ULong *)&x)[1]
-#define word1(x) ((ULong *)&x)[0]
+#define word0(x) (x)->L[1]
+#define word1(x) (x)->L[0]
#else
-#define word0(x) ((ULong *)&x)[0]
-#define word1(x) ((ULong *)&x)[1]
+#define word0(x) (x)->L[0]
+#define word1(x) (x)->L[1]
#endif
-#else /* !YES_ALIAS */
-#ifdef IEEE_8087
-#define word0(x) ((U*)&x)->L[1]
-#define word1(x) ((U*)&x)->L[0]
-#else
-#define word0(x) ((U*)&x)->L[0]
-#define word1(x) ((U*)&x)->L[1]
-#endif
-#define dval(x) ((U*)&x)->d
-#endif /* YES_ALIAS */
+#define dval(x) (x)->d
/* The following definition of Storeinc is appropriate for MIPS processors.
* An alternative that might be better on some machines is
@@ -403,11 +400,7 @@ typedef union { double d; ULong L[2]; } U;
#ifdef RND_PRODQUOT
#define rounded_product(a,b) a = rnd_prod(a, b)
#define rounded_quotient(a,b) a = rnd_quot(a, b)
-#ifdef KR_headers
-extern double rnd_prod(), rnd_quot();
-#else
extern double rnd_prod(double, double), rnd_quot(double, double);
-#endif
#else
#define rounded_product(a,b) a *= b
#define rounded_quotient(a,b) a /= b
@@ -458,23 +451,22 @@ extern double rnd_prod(double, double), rnd_quot(double, double);
#define FREE_DTOA_LOCK(n) /*nothing*/
#endif
-#define Kmax 15
+#define Kmax 9
#define Bigint __Bigint
- struct
+struct
Bigint {
struct Bigint *next;
int k, maxwds, sign, wds;
ULong x[1];
- };
-
- typedef struct Bigint Bigint;
+};
+typedef struct Bigint Bigint;
#ifdef NO_STRING_H
#ifdef DECLARE_SIZE_T
typedef unsigned int size_t;
#endif
-extern void memcpy_D2A ANSI((void*, const void*, size_t));
+extern void memcpy_D2A (void*, const void*, size_t);
#define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
#else /* !NO_STRING_H */
#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
@@ -484,15 +476,15 @@ extern void memcpy_D2A ANSI((void*, const void*, size_t));
static inline int
__lo0bits_D2A (ULong *y)
{
- int ret = __builtin_ctz(*y);
- *y = *y >> ret;
- return ret;
+ int ret = __builtin_ctz(*y);
+ *y = *y >> ret;
+ return ret;
}
static inline int
__hi0bits_D2A (ULong y)
{
- return __builtin_clz(y);
+ return __builtin_clz(y);
}
#endif
@@ -543,48 +535,48 @@ __hi0bits_D2A (ULong y)
#define trailz __trailz_D2A
#define ulp __ulp_D2A
- extern char *dtoa_result;
- extern CONST double bigtens[], tens[], tinytens[];
- extern unsigned char hexdig[];
-
- extern Bigint *Balloc ANSI((int));
- extern void Bfree ANSI((Bigint*));
- extern void ULtof ANSI((ULong*, ULong*, Long, int));
- extern void ULtod ANSI((ULong*, ULong*, Long, int));
- extern void ULtodd ANSI((ULong*, ULong*, Long, int));
- extern void ULtoQ ANSI((ULong*, ULong*, Long, int));
- extern void ULtox ANSI((UShort*, ULong*, Long, int));
- extern void ULtoxL ANSI((ULong*, ULong*, Long, int));
- extern ULong any_on ANSI((Bigint*, int));
- extern double b2d ANSI((Bigint*, int*));
- extern int cmp ANSI((Bigint*, Bigint*));
- extern void copybits ANSI((ULong*, int, Bigint*));
- extern Bigint *d2b ANSI((double, int*, int*));
- extern int decrement ANSI((Bigint*));
- extern Bigint *diff ANSI((Bigint*, Bigint*));
- extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int));
- extern void hexdig_init_D2A(Void);
- extern int hexnan ANSI((CONST char**, FPI*, ULong*));
- extern int hi0bits_D2A ANSI((ULong));
- extern Bigint *i2b ANSI((int));
- extern Bigint *increment ANSI((Bigint*));
- extern int lo0bits ANSI((ULong*));
- extern Bigint *lshift ANSI((Bigint*, int));
- extern int match ANSI((CONST char**, char*));
- extern Bigint *mult ANSI((Bigint*, Bigint*));
- extern Bigint *multadd ANSI((Bigint*, int, int));
- extern char *nrv_alloc ANSI((char*, char **, int));
- extern Bigint *pow5mult ANSI((Bigint*, int));
- extern int quorem ANSI((Bigint*, Bigint*));
- extern double ratio ANSI((Bigint*, Bigint*));
- extern void rshift ANSI((Bigint*, int));
- extern char *rv_alloc ANSI((int));
- extern Bigint *s2b ANSI((CONST char*, int, int, ULong));
- extern Bigint *set_ones ANSI((Bigint*, int));
- extern char *strcp ANSI((char*, const char*));
- extern Bigint *sum ANSI((Bigint*, Bigint*));
- extern int trailz ANSI((Bigint*));
- extern double ulp ANSI((double));
+extern char *dtoa_result;
+extern const double bigtens[], tens[], tinytens[];
+extern unsigned char hexdig[];
+
+extern Bigint *Balloc (int);
+extern void Bfree (Bigint*);
+extern void ULtof (ULong*, ULong*, Long, int);
+extern void ULtod (ULong*, ULong*, Long, int);
+extern void ULtodd (ULong*, ULong*, Long, int);
+extern void ULtoQ (ULong*, ULong*, Long, int);
+extern void ULtox (UShort*, ULong*, Long, int);
+extern void ULtoxL (ULong*, ULong*, Long, int);
+extern ULong any_on (Bigint*, int);
+extern double b2d (Bigint*, int*);
+extern int cmp (Bigint*, Bigint*);
+extern void copybits (ULong*, int, Bigint*);
+extern Bigint *d2b (double, int*, int*);
+extern void decrement (Bigint*);
+extern Bigint *diff (Bigint*, Bigint*);
+extern int gethex (const char**, FPI*, Long*, Bigint**, int);
+extern void hexdig_init_D2A(void);
+extern int hexnan (const char**, FPI*, ULong*);
+extern int hi0bits_D2A (ULong);
+extern Bigint *i2b (int);
+extern Bigint *increment (Bigint*);
+extern int lo0bits (ULong*);
+extern Bigint *lshift (Bigint*, int);
+extern int match (const char**, char*);
+extern Bigint *mult (Bigint*, Bigint*);
+extern Bigint *multadd (Bigint*, int, int);
+extern char *nrv_alloc (char*, char **, int);
+extern Bigint *pow5mult (Bigint*, int);
+extern int quorem (Bigint*, Bigint*);
+extern double ratio (Bigint*, Bigint*);
+extern void rshift (Bigint*, int);
+extern char *rv_alloc (int);
+extern Bigint *s2b (const char*, int, int, ULong, int);
+extern Bigint *set_ones (Bigint*, int);
+extern char *strcp (char*, const char*);
+extern Bigint *sum (Bigint*, Bigint*);
+extern int trailz (Bigint*);
+extern double ulp (dbl_union *);
#ifdef __cplusplus
}
@@ -599,6 +591,10 @@ __hi0bits_D2A (ULong y)
* (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
*/
#ifdef IEEE_Arith
+#ifndef NO_INFNAN_CHECK
+#undef INFNAN_CHECK
+#define INFNAN_CHECK
+#endif
#ifdef IEEE_MC68k
#define _0 0
#define _1 1