This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Modifying float-i64.h to Become C99-compliant: Volunteer Wanted
- To: gcc-patches at gcc dot gnu dot org
- Subject: Modifying float-i64.h to Become C99-compliant: Volunteer Wanted
- From: Jeffrey Oldham <oldham at codesourcery dot com>
- Date: Wed, 31 Jan 2001 11:10:19 -0800
- Cc: jsm28 at srcf dot ucam dot org, rth at redhat dot com, oldham at codesourcery dot com
- Organization: CodeSourcery LLC
(This thread was originally titled "Why Special float.h Files?".)
Joseph S. Myers writes:
> On Wed, 31 Jan 2001, Jeffrey Oldham wrote:
>
> > 1) How do we ensure that gcc's float.h are consistent with the
> > underlying system since the underlying system can change without
> > warning us? Do I just guess correct values?
>
> You don't guess values. The ISO C standard defines the contents of this
> header; you read the specification, and the specification of the floating
> point format for your architecture (either in the CPU manual, or deferred
> to IEEE 754 / IEC 60559), and compute the correct values and enter them in
> the file. enquire.c may generate the non-C99 parts of the file, but the
> results should still be checked - including making sure that the binary
> value compiled for decimal constants in the source file has the exact bits
> the minimal / maximal normalized floating point values should have.
>
> For many systems (those using only 32-bit and 64-bit IEEE format),
> float-i64.h suffices - someone with the IEEE floating point standard
> should add the C99 values to it.
Great! Using a C99-compliant gcc/config/float-i64.h would be the best
solution.
Would someone with access to the C99 standard be willing to modify
gcc/config/float-i64.h to include definitions for "FLT_EVAL_METHOD"
and "DECIMAL_DIG"?
As a starting point, I attached my best guesses based on Ulrich
Drepper's gcc/config/float-i386.h C99 changes. Here is a possible
gcc/config/ChangeLog entry:
2001-01-31 Your name here <Your email address here>
* config/float-i64.h: Define FLT_EVAL_METHOD and DECIMAL_DIG for C99.
Not having access to the C99 standard,
Jeffrey D. Oldham
oldham@codesourcery.com
Index: float-i64.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/float-i64.h,v
retrieving revision 1.2
diff -c -p -r1.2 float-i64.h
*** float-i64.h 1998/12/16 20:59:45 1.2
--- float-i64.h 2001/01/31 19:06:05
***************
*** 93,96 ****
--- 93,123 ----
#undef LDBL_MAX_10_EXP
#define LDBL_MAX_10_EXP 308
+ #if __STDC_VERSION__ >= 199901L
+ /* The floating-point expression evaluation method.
+ -1 indeterminate
+ 0 evaluate all operations and constants just to the range and
+ precision of the type
+ 1 evaluate operations and constants of type float and double
+ to the range and precision of the double type, evaluate
+ long double operations and constants to the range and
+ precision of the long double type
+ 2 evaluate all operations and constants to the range and
+ precision of the long double type
+ */
+ # undef FLT_EVAL_METHOD
+ # define FLT_EVAL_METHOD 1
+
+ /* Number of decimal digits to enable rounding to the given number of
+ decimal digits without loss of precision.
+ if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX)
+ else : ceil (1 + #mantissa * log10 (FLT_RADIX))
+ where #mantissa is the number of bits in the mantissa of the widest
+ supported floating-point type.
+ */
+ # undef DECIMAL_DIG
+ # define DECIMAL_DIG 17
+
+ #endif /* C99 */
+
#endif /* _FLOAT_H_ */