From: Bruno Haible Date: Fri, 30 Sep 2011 01:56:26 +0000 (+0200) Subject: float: Fix LDBL_MAX value on Linux/PowerPC. X-Git-Tag: v0.1~1727 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=c65d65a81e9d66960ae7ce5abe5069d5b7338ed2;p=gnulib.git float: Fix LDBL_MAX value on Linux/PowerPC. * m4/float_h.m4 (gl_FLOAT_H): Set FLOAT_H and REPLACE_FLOAT_LDBL also on Linux/PowerPC. * lib/float.in.h (LDBL_MAX): Redefine also on Linux/PowerPC. * lib/float.c (gl_LDBL_MAX): Also define on Linux/PowerPC. * doc/posix-headers/float.texi: Mention Linux/PowerPC as an affected platform. Reported by Andreas Metzler . --- diff --git a/ChangeLog b/ChangeLog index 0a63ba05d..c629f0a45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-09-29 Bruno Haible + float: Fix LDBL_MAX value on Linux/PowerPC. + * m4/float_h.m4 (gl_FLOAT_H): Set FLOAT_H and REPLACE_FLOAT_LDBL also + on Linux/PowerPC. + * lib/float.in.h (LDBL_MAX): Redefine also on Linux/PowerPC. + * lib/float.c (gl_LDBL_MAX): Also define on Linux/PowerPC. + * doc/posix-headers/float.texi: Mention Linux/PowerPC as an affected + platform. + Reported by Andreas Metzler . + +2011-09-29 Bruno Haible + doc: Improve doc about gl_EARLY. * doc/gnulib-tool.texi (Initial import): Mention where to place an AC_PROG_CC_STDC invocation. diff --git a/doc/posix-headers/float.texi b/doc/posix-headers/float.texi index c222a2342..f2e0e9b2d 100644 --- a/doc/posix-headers/float.texi +++ b/doc/posix-headers/float.texi @@ -14,8 +14,9 @@ On OpenBSD 4.0, MirBSD 10, and BeOS, they are the same as the values of the @samp{double}. On FreeBSD/x86 6.4, they represent the incorrect 53-bit precision assumptions in the compiler, not the real 64-bit precision at runtime. -On AIX 7.1 with GCC 4.2 and on IRIX 6.5, they don't reflect the -``double double'' representation of @code{long double} correctly. +On Linux/PowerPC with GCC 4.4, on AIX 7.1 with GCC 4.2, and on IRIX 6.5, +they don't reflect the ``double double'' representation of @code{long double} +correctly. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/float.c b/lib/float.c index c453d6d19..b05b40c2d 100644 --- a/lib/float.c +++ b/lib/float.c @@ -20,7 +20,7 @@ /* Specification. */ #include -#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ +#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ const union gl_long_double_union gl_LDBL_MAX = { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; #elif defined __i386__ diff --git a/lib/float.in.h b/lib/float.in.h index 57b7bc93a..b132035d8 100644 --- a/lib/float.in.h +++ b/lib/float.in.h @@ -109,7 +109,8 @@ extern const union gl_long_double_union gl_LDBL_MAX; #endif /* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are - wrong. */ + wrong. + On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP @@ -117,6 +118,8 @@ extern const union gl_long_double_union gl_LDBL_MAX; # define LDBL_MIN_10_EXP DBL_MIN_10_EXP # undef LDBL_MIN # define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ +#endif +#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MAX /* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. It is not easy to define: diff --git a/m4/float_h.m4 b/m4/float_h.m4 index 261f1ac3a..da11c0e2d 100644 --- a/m4/float_h.m4 +++ b/m4/float_h.m4 @@ -1,4 +1,4 @@ -# float_h.m4 serial 7 +# float_h.m4 serial 8 dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,9 +33,16 @@ changequote([,])dnl ;; esac ;; + linux*) + case "$host_cpu" in + powerpc*) + FLOAT_H=float.h + ;; + esac + ;; esac case "$host_os" in - aix* | freebsd*) + aix* | freebsd* | linux*) if test -n "$FLOAT_H"; then REPLACE_FLOAT_LDBL=1 fi