This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/3516] New: Simplify bits/mathdef.h files

bits/mathdef.h defines float_t to be the type the compiler uses for arithmetic
on float values.  If FLT_EVAL_METHOD is 0, then C99 (7.12#2) requires float_t to
be float; FLT_EVAL_METHOD is 0 with GCC on all processors except x86 and m68k
(so float_t being something else in glibc indicates a bug in either GCC or
glibc, except on those processors).

For some processors such as PowerPC, glibc has the following logic to determine

# ifdef __GNUC__
#  if __STDC__ == 1

/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
typedef float float_t;          /* `float' expressions are evaluated as
                                   `float'.  */
typedef double double_t;        /* `double' expressions are evaluated as
                                   `double'.  */

#  else

/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
typedef double float_t;         /* `float' expressions are evaluated as
                                   `double'.  */
typedef double double_t;        /* `double' expressions are evaluated as
                                   `double'.  */

#  endif
# else

/* Wild guess at types for float_t and double_t. */
typedef double float_t;
typedef double double_t;

# endif

This has several problems:

* The __STDC__ == 1 conditional is interpreted by GCC's fixincludes as intended
to mean strict conformance mode, and so is rewritten to check __STRICT_ANSI__,
meaning that in default non-strict mode you actually get the incorrect double type.

* glibc doesn't support pre-standard C at all.  There's no point in having
__STDC__ checks *anywhere* in glibc to allow for pre-standard C.  GCC hasn't
supported -traditional for some time either.  Anyway, these are C99 definitions;
hardly likely to be of use in a compatibility mode for ancient code.

* The "Wild guess" default of double for float_t for other compilers is unlikely
to be right; these processors support float arithmetic, so other compilers are
more likely to use float arithmetic.

Thus it's simpler, more accurate and avoids the header being changed by
fixincludes just to use

typedef float float_t;
typedef double double_t;

unconditionally for these targets.  I'll attach a patch to do so.

           Summary: Simplify bits/mathdef.h files
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: jsm28 at gcc dot gnu dot org
                CC: glibc-bugs at sources dot redhat dot com

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]