Deleted Added
full compact
gdtoaimp.h (196916) gdtoaimp.h (219557)
1/****************************************************************
2
3The author of this software is David M. Gay.
4
5Copyright (C) 1998-2000 by Lucent Technologies
6All Rights Reserved
7
8Permission to use, copy, modify, and distribute this software and

--- 12 unchanged lines hidden (view full) ---

21SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25THIS SOFTWARE.
26
27****************************************************************/
28
1/****************************************************************
2
3The author of this software is David M. Gay.
4
5Copyright (C) 1998-2000 by Lucent Technologies
6All Rights Reserved
7
8Permission to use, copy, modify, and distribute this software and

--- 12 unchanged lines hidden (view full) ---

21SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25THIS SOFTWARE.
26
27****************************************************************/
28
29/* $FreeBSD: head/contrib/gdtoa/gdtoaimp.h 196916 2009-09-07 09:30:37Z attilio $ */
29/* $FreeBSD: head/contrib/gdtoa/gdtoaimp.h 219557 2011-03-12 07:03:06Z das $ */
30
31/* This is a variation on dtoa.c that converts arbitary binary
32 floating-point formats to and from decimal notation. It uses
33 double-precision arithmetic internally, so there are still
34 various #ifdefs that adapt the calculations to the native
35 double-precision arithmetic (any of IEEE, VAX D_floating,
36 or IBM mainframe arithmetic).
37

--- 53 unchanged lines hidden (view full) ---

91 * #define IBM for IBM mainframe-style floating-point arithmetic.
92 * #define VAX for VAX-style floating-point arithmetic (D_floating).
93 * #define No_leftright to omit left-right logic in fast floating-point
94 * computation of dtoa.
95 * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
96 * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
97 * that use extended-precision instructions to compute rounded
98 * products and quotients) with IBM.
30
31/* This is a variation on dtoa.c that converts arbitary binary
32 floating-point formats to and from decimal notation. It uses
33 double-precision arithmetic internally, so there are still
34 various #ifdefs that adapt the calculations to the native
35 double-precision arithmetic (any of IEEE, VAX D_floating,
36 or IBM mainframe arithmetic).
37

--- 53 unchanged lines hidden (view full) ---

91 * #define IBM for IBM mainframe-style floating-point arithmetic.
92 * #define VAX for VAX-style floating-point arithmetic (D_floating).
93 * #define No_leftright to omit left-right logic in fast floating-point
94 * computation of dtoa.
95 * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
96 * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
97 * that use extended-precision instructions to compute rounded
98 * products and quotients) with IBM.
99 * #define ROUND_BIASED for IEEE-format with biased rounding.
99 * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic
100 * that rounds toward +Infinity.
101 * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased
102 * rounding when the underlying floating-point arithmetic uses
103 * unbiased rounding. This prevent using ordinary floating-point
104 * arithmetic when the result could be computed with one rounding error.
100 * #define Inaccurate_Divide for IEEE-format with correctly rounded
101 * products but inaccurate quotients, e.g., for Intel i860.
102 * #define NO_LONG_LONG on machines that do not have a "long long"
103 * integer type (of >= 64 bits). On such machines, you can
104 * #define Just_16 to store 16 bits per 32-bit Long when doing
105 * high-precision integer arithmetic. Whether this speeds things
106 * up or slows things down depends on the machine and the number
107 * being converted. If long long is available and the name is
108 * something other than "long long", #define Llong to be the name,
109 * and if "unsigned Llong" does not work as an unsigned version of
110 * Llong, #define #ULLong to be the corresponding unsigned type.
111 * #define KR_headers for old-style C function headers.
112 * #define Bad_float_h if your system lacks a float.h or if it does not
113 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
114 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
115 * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
116 * if memory is available and otherwise does something you deem
117 * appropriate. If MALLOC is undefined, malloc will be invoked
105 * #define Inaccurate_Divide for IEEE-format with correctly rounded
106 * products but inaccurate quotients, e.g., for Intel i860.
107 * #define NO_LONG_LONG on machines that do not have a "long long"
108 * integer type (of >= 64 bits). On such machines, you can
109 * #define Just_16 to store 16 bits per 32-bit Long when doing
110 * high-precision integer arithmetic. Whether this speeds things
111 * up or slows things down depends on the machine and the number
112 * being converted. If long long is available and the name is
113 * something other than "long long", #define Llong to be the name,
114 * and if "unsigned Llong" does not work as an unsigned version of
115 * Llong, #define #ULLong to be the corresponding unsigned type.
116 * #define KR_headers for old-style C function headers.
117 * #define Bad_float_h if your system lacks a float.h or if it does not
118 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
119 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
120 * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
121 * if memory is available and otherwise does something you deem
122 * appropriate. If MALLOC is undefined, malloc will be invoked
118 * directly -- and assumed always to succeed.
123 * directly -- and assumed always to succeed. Similarly, if you
124 * want something other than the system's free() to be called to
125 * recycle memory acquired from MALLOC, #define FREE to be the
126 * name of the alternate routine. (FREE or free is only called in
127 * pathological cases, e.g., in a gdtoa call after a gdtoa return in
128 * mode 3 with thousands of digits requested.)
119 * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
120 * memory allocations from a private pool of memory when possible.
121 * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
122 * unless #defined to be a different length. This default length
123 * suffices to get rid of MALLOC calls except for unusual cases,
124 * such as decimal-to-binary conversion of a very long string of
125 * digits. When converting IEEE double precision values, the
126 * longest string gdtoa can return is about 751 bytes long. For

--- 32 unchanged lines hidden (view full) ---

159 * dtoa.c).
160 * #define NO_HEX_FP to disable recognition of C9x's hexadecimal
161 * floating-point constants.
162 * #define -DNO_ERRNO to suppress setting errno (in strtod.c and
163 * strtodg.c).
164 * #define NO_STRING_H to use private versions of memcpy.
165 * On some K&R systems, it may also be necessary to
166 * #define DECLARE_SIZE_T in this case.
129 * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
130 * memory allocations from a private pool of memory when possible.
131 * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
132 * unless #defined to be a different length. This default length
133 * suffices to get rid of MALLOC calls except for unusual cases,
134 * such as decimal-to-binary conversion of a very long string of
135 * digits. When converting IEEE double precision values, the
136 * longest string gdtoa can return is about 751 bytes long. For

--- 32 unchanged lines hidden (view full) ---

169 * dtoa.c).
170 * #define NO_HEX_FP to disable recognition of C9x's hexadecimal
171 * floating-point constants.
172 * #define -DNO_ERRNO to suppress setting errno (in strtod.c and
173 * strtodg.c).
174 * #define NO_STRING_H to use private versions of memcpy.
175 * On some K&R systems, it may also be necessary to
176 * #define DECLARE_SIZE_T in this case.
167 * #define YES_ALIAS to permit aliasing certain double values with
168 * arrays of ULongs. This leads to slightly better code with
169 * some compilers and was always used prior to 19990916, but it
170 * is not strictly legal and can cause trouble with aggressively
171 * optimizing compilers (e.g., gcc 2.95.1 under -O2).
172 * #define USE_LOCALE to use the current locale's decimal_point value.
173 */
174
175#ifndef GDTOAIMP_H_INCLUDED
176#define GDTOAIMP_H_INCLUDED
177
178#define Long int
179

--- 102 unchanged lines hidden (view full) ---

282#endif
283
284#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
285Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
286#endif
287
288typedef union { double d; ULong L[2]; } U;
289
177 * #define USE_LOCALE to use the current locale's decimal_point value.
178 */
179
180#ifndef GDTOAIMP_H_INCLUDED
181#define GDTOAIMP_H_INCLUDED
182
183#define Long int
184

--- 102 unchanged lines hidden (view full) ---

287#endif
288
289#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
290Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
291#endif
292
293typedef union { double d; ULong L[2]; } U;
294
290#ifdef YES_ALIAS
291#define dval(x) x
292#ifdef IEEE_8087
295#ifdef IEEE_8087
293#define word0(x) ((ULong *)&x)[1]
294#define word1(x) ((ULong *)&x)[0]
296#define word0(x) (x)->L[1]
297#define word1(x) (x)->L[0]
295#else
298#else
296#define word0(x) ((ULong *)&x)[0]
297#define word1(x) ((ULong *)&x)[1]
299#define word0(x) (x)->L[0]
300#define word1(x) (x)->L[1]
298#endif
301#endif
299#else /* !YES_ALIAS */
300#ifdef IEEE_8087
301#define word0(x) ((U*)&x)->L[1]
302#define word1(x) ((U*)&x)->L[0]
303#else
304#define word0(x) ((U*)&x)->L[0]
305#define word1(x) ((U*)&x)->L[1]
306#endif
307#define dval(x) ((U*)&x)->d
308#endif /* YES_ALIAS */
302#define dval(x) (x)->d
309
310/* The following definition of Storeinc is appropriate for MIPS processors.
311 * An alternative that might be better on some machines is
312 * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
313 */
314#if defined(IEEE_8087) + defined(VAX)
315#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
316((unsigned short *)a)[0] = (unsigned short)c, a++)

--- 97 unchanged lines hidden (view full) ---

414#define Tiny1 0
415#define Quick_max 15
416#define Int_max 15
417#endif /* IBM, VAX */
418#endif /* IEEE_Arith */
419
420#ifndef IEEE_Arith
421#define ROUND_BIASED
303
304/* The following definition of Storeinc is appropriate for MIPS processors.
305 * An alternative that might be better on some machines is
306 * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
307 */
308#if defined(IEEE_8087) + defined(VAX)
309#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
310((unsigned short *)a)[0] = (unsigned short)c, a++)

--- 97 unchanged lines hidden (view full) ---

408#define Tiny1 0
409#define Quick_max 15
410#define Int_max 15
411#endif /* IBM, VAX */
412#endif /* IEEE_Arith */
413
414#ifndef IEEE_Arith
415#define ROUND_BIASED
416#else
417#ifdef ROUND_BIASED_without_Round_Up
418#undef ROUND_BIASED
419#define ROUND_BIASED
422#endif
420#endif
421#endif
423
424#ifdef RND_PRODQUOT
425#define rounded_product(a,b) a = rnd_prod(a, b)
426#define rounded_quotient(a,b) a = rnd_quot(a, b)
427#ifdef KR_headers
428extern double rnd_prod(), rnd_quot();
429#else
430extern double rnd_prod(double, double), rnd_quot(double, double);

--- 223 unchanged lines hidden (view full) ---

654 extern int strtord ANSI((CONST char *, char **, int, double *));
655 extern int strtordd ANSI((CONST char *, char **, int, double *));
656 extern int strtorf ANSI((CONST char *, char **, int, float *));
657 extern int strtorQ ANSI((CONST char *, char **, int, void *));
658 extern int strtorx ANSI((CONST char *, char **, int, void *));
659 extern int strtorxL ANSI((CONST char *, char **, int, void *));
660 extern Bigint *sum ANSI((Bigint*, Bigint*));
661 extern int trailz ANSI((Bigint*));
422
423#ifdef RND_PRODQUOT
424#define rounded_product(a,b) a = rnd_prod(a, b)
425#define rounded_quotient(a,b) a = rnd_quot(a, b)
426#ifdef KR_headers
427extern double rnd_prod(), rnd_quot();
428#else
429extern double rnd_prod(double, double), rnd_quot(double, double);

--- 223 unchanged lines hidden (view full) ---

653 extern int strtord ANSI((CONST char *, char **, int, double *));
654 extern int strtordd ANSI((CONST char *, char **, int, double *));
655 extern int strtorf ANSI((CONST char *, char **, int, float *));
656 extern int strtorQ ANSI((CONST char *, char **, int, void *));
657 extern int strtorx ANSI((CONST char *, char **, int, void *));
658 extern int strtorxL ANSI((CONST char *, char **, int, void *));
659 extern Bigint *sum ANSI((Bigint*, Bigint*));
660 extern int trailz ANSI((Bigint*));
662 extern double ulp ANSI((double));
661 extern double ulp ANSI((U*));
663
664#ifdef __cplusplus
665}
666#endif
667/*
668 * NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to
669 * 20050115, they used to be hard-wired here (to 0x7ff80000 and 0,
670 * respectively), but now are determined by compiling and running

--- 41 unchanged lines hidden ---
662
663#ifdef __cplusplus
664}
665#endif
666/*
667 * NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to
668 * 20050115, they used to be hard-wired here (to 0x7ff80000 and 0,
669 * respectively), but now are determined by compiling and running

--- 41 unchanged lines hidden ---