Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gdtoa/gdtoaimp.h,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libc/gdtoa/gdtoaimp.h,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.5 retrieving revision 1.11 diff -u -p -r1.5 -r1.11 --- src/lib/libc/gdtoa/gdtoaimp.h 2006/05/04 18:59:23 1.5 +++ src/lib/libc/gdtoa/gdtoaimp.h 2011/03/21 22:33:29 1.11 @@ -1,4 +1,4 @@ -/* $NetBSD: gdtoaimp.h,v 1.5 2006/05/04 18:59:23 christos Exp $ */ +/* $NetBSD: gdtoaimp.h,v 1.11 2011/03/21 22:33:29 christos Exp $ */ /**************************************************************** @@ -96,7 +96,12 @@ THIS SOFTWARE. * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines * that use extended-precision instructions to compute rounded * products and quotients) with IBM. - * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic + * that rounds toward +Infinity. + * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased + * rounding when the underlying floating-point arithmetic uses + * unbiased rounding. This prevent using ordinary floating-point + * arithmetic when the result could be computed with one rounding error. * #define Inaccurate_Divide for IEEE-format with correctly rounded * products but inaccurate quotients, e.g., for Intel i860. * #define NO_LONG_LONG on machines that do not have a "long long" @@ -115,7 +120,12 @@ THIS SOFTWARE. * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) * if memory is available and otherwise does something you deem * appropriate. If MALLOC is undefined, malloc will be invoked - * directly -- and assumed always to succeed. + * directly -- and assumed always to succeed. Similarly, if you + * want something other than the system's free() to be called to + * recycle memory acquired from MALLOC, #define FREE to be the + * name of the alternate routine. (FREE or free is only called in + * pathological cases, e.g., in a gdtoa call after a gdtoa return in + * mode 3 with thousands of digits requested.) * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making * memory allocations from a private pool of memory when possible. * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, @@ -128,17 +138,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 @@ -150,7 +165,7 @@ THIS SOFTWARE. * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. * #define IMPRECISE_INEXACT if you do not care about the setting of * the STRTOG_Inexact bits in the special case of doing IEEE double - * precision conversions (which could also be done by the strtog in + * precision conversions (which could also be done by the strtod in * dtoa.c). * #define NO_HEX_FP to disable recognition of C9x's hexadecimal * floating-point constants. @@ -159,11 +174,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. */ @@ -187,6 +197,9 @@ THIS SOFTWARE. #define GDTOAIMP_H_INCLUDED #include "gdtoa.h" #include "gd_qnan.h" +#ifdef Honor_FLT_ROUNDS +#include +#endif #ifdef DEBUG #include "stdio.h" @@ -276,26 +289,26 @@ extern "C" { Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. #endif -typedef union { double d; ULong L[2]; } U; +typedef union { double d; ULong L[2]; } __attribute__((__may_alias__)) U; #ifdef YES_ALIAS #define dval(x) x #ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ((ULong *)&x)[1] -#define word1(x) ((ULong *)&x)[0] +#define word0(x) ((ULong *)x)[1] +#define word1(x) ((ULong *)x)[0] #else -#define word0(x) ((ULong *)&x)[0] -#define word1(x) ((ULong *)&x)[1] +#define word0(x) ((ULong *)x)[0] +#define word1(x) ((ULong *)x)[1] #endif #else /* !YES_ALIAS */ #ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ( /* LINTED */ (U*)&x)->L[1] -#define word1(x) ( /* LINTED */ (U*)&x)->L[0] +#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] +#define word0(x) ( /* LINTED */ (U*)x)->L[0] +#define word1(x) ( /* LINTED */ (U*)x)->L[1] #endif -#define dval(x) ( /* LINTED */ (U*)&x)->d +#define dval(x) ( /* LINTED */ (U*)x)->d #endif /* YES_ALIAS */ /* The following definition of Storeinc is appropriate for MIPS processors. @@ -393,6 +406,7 @@ typedef union { double d; ULong L[2]; } #define Exp_mask 0x7f80 #define P 56 #define Bias 129 +#define Emin (-127) /* XXX: Check this */ #define Exp_1 0x40800000 #define Exp_11 0x4080 #define Ebits 8 @@ -414,6 +428,11 @@ typedef union { double d; ULong L[2]; } #ifndef IEEE_Arith #define ROUND_BIASED +#else +#ifdef ROUND_BIASED_without_Round_Up +#undef ROUND_BIASED +#define ROUND_BIASED +#endif #endif #ifdef RND_PRODQUOT @@ -489,7 +508,7 @@ extern mutex_t __gdtoa_locks[2]; } while (/* CONSTCOND */ 0) #endif -#define Kmax 15 +#define Kmax (sizeof(size_t) << 3) struct Bigint { @@ -576,11 +595,11 @@ extern void memcpy_D2A ANSI((void*, cons 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 void decrement ANSI((Bigint*)); extern Bigint *diff ANSI((Bigint*, Bigint*)); extern char *dtoa ANSI((double d, int mode, int ndigits, int *decpt, int *sign, char **rve)); - extern char *g__fmt ANSI((char*, char*, char*, int, ULong)); + extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t)); extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int)); extern void hexdig_init_D2A(Void); extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*)); @@ -592,20 +611,22 @@ extern void memcpy_D2A ANSI((void*, cons extern int match ANSI((CONST char**, CONST char*)); extern Bigint *mult ANSI((Bigint*, Bigint*)); extern Bigint *multadd ANSI((Bigint*, int, int)); - extern char *nrv_alloc ANSI((CONST char*, char **, int)); + extern char *nrv_alloc ANSI((CONST char*, char **, size_t)); 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 char *rv_alloc ANSI((size_t)); + extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int)); extern Bigint *set_ones ANSI((Bigint*, int)); extern char *strcp ANSI((char*, const char*)); extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); extern double strtod ANSI((const char *s00, char **se)); extern Bigint *sum ANSI((Bigint*, Bigint*)); extern int trailz ANSI((CONST Bigint*)); - extern double ulp ANSI((double)); +/*###626 [lint] syntax error '*' [249]%%%*/ +/*###626 [lint] incomplete or misplaced function definition [22]%%%*/ + extern double ulp ANSI((U*)); #ifdef __cplusplus } @@ -620,6 +641,10 @@ extern void memcpy_D2A ANSI((void*, cons * (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_BIG_ENDIAN #define _0 0 #define _1 1