autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3


From: Oliver Kiddle
Subject: Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3
Date: Thu, 15 Nov 2001 18:18:49 +0000

Paul Eggert wrote:
> 
> > I think it would be more useful if the check was redefined as
> > `checking for a useful long double type'.
> 
> That sounds reasonable.  Can you please resubmit a patch along those lines?
> You'd have to change the documentation as well, of course.

Patch is below. Is the line break in the AC_DEFINE near the end ok? You
may be able to think of better wording for the documentation changes.

> Also, the patch should compare DBL_MAX to LDBL_MAX (defined in
> float.h).  This can be done at compile-time.  This will catch some of
> the counterexamples that I am thinking of.  If an implementation
> doesn't have float.h, DBL_MAX and LDBL_MAX, we should play it safe and
> assume it doesn't have 'long double'.

Without having much idea of what these counterexamples might be I might
have not quite got the logic right so I suggest you check the parameter
to exit is what you had in mind.

Paul Eggert wrote:
> 
> > Date: Tue, 13 Nov 2001 15:50:00 +0000
> > From: Oliver Kiddle <address@hidden>
> >
> > How can I compare DBL_MAX and LDBL_MAX at compile-time?
> 
> int a[LDBL_MAX <= DBL_MAX ? -1 : 1];

Ah, ok, thanks. Again, you should take a look that the patch is what
you had in mind. I assume that you didn't suggest the simpler
    int a = LDBL_MAX <= DBL_MAX ? -1 : 1
because it has some problem such as compilers doing it at runtime after
converting LDBL_MAX to a double or similar. I changed the -1 to 0 and
used sizeof(a) == 0 to then check the condition which may not be
reliable and you may know a better way.

Thanks

Oliver

PS. I'm away on holiday from Saturday so any further necessary fix and
resubmit of the patch by me might be even slower.

diff -r -u doc/autoconf.texi doc/autoconf.texi
--- doc/autoconf.texi    Fri Nov  2 16:10:56 2001
+++ doc/autoconf.texi       Thu Nov 15 17:34:27 2001
@@ -4775,7 +4775,8 @@
 @defmac AC_C_LONG_DOUBLE
 @acindex C_LONG_DOUBLE
 @cvindex HAVE_LONG_DOUBLE
-If the C compiler supports the @code{long double} type, define
+If the C compiler supports the @code{long double} type and this type
+provides greater precision than the @code{double} type, define
 @code{HAVE_LONG_DOUBLE}.  Some C compilers that do not define
 @code{__STDC__} do support the @code{long double} type; some compilers
 that define @code{__STDC__} do not support @code{long double}.
diff -r -u lib/autoconf/c.m4 lib/autoconf/c.m4
--- lib/autoconf/c.m4   Sat Sep 22 16:28:27 2001
+++ lib/autoconf/c.m4   Thu Nov 15 17:29:45 2001
@@ -828,25 +828,33 @@
 # AC_C_LONG_DOUBLE
 # ----------------
 AC_DEFUN([AC_C_LONG_DOUBLE],
-[AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
+[AC_CACHE_CHECK(for useful long double, ac_cv_c_long_double,
 [if test "$GCC" = yes; then
   ac_cv_c_long_double=yes
 else
 AC_TRY_RUN(
-[int
+[#include <float.h>
+int
 main ()
 {
   /* The Stardent Vistra knows sizeof(long double), but does not
      support it.  */
   long double foo = 0.0;
+#if defined (LDBL_MAX) && defined (DBL_MAX)
+  int a[LDBL_MAX <= DBL_MAX ? 0 : 1];
   /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
-  exit (sizeof (long double) < sizeof (double));
+  exit ((sizeof (a) == 0) ||
+      (sizeof (long double) <= sizeof (double)));
+#else
+  exit (1);
+#end if
 }],
 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
 fi])
 if test $ac_cv_c_long_double = yes; then
   AC_DEFINE(HAVE_LONG_DOUBLE, 1,
-            [Define if the `long double' type works.])
+            [Define if the `long double' type works and provides greater
+            precision than `double'.])
 fi
 ])# AC_C_LONG_DOUBLE

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]