Patch to test for HAVE_LONG_DOUBLE before using long double

Kaveh R. Ghazi ghaziATcaip.rutgers.edu
Tue Sep 14 15:22:00 GMT 1999


	Here's what I had in mind for the long double problem.  The
default autoconf test for long double uses AC_TRY_RUN which doesn't
work for cross compilers.  So I wrote my own test which only uses a
compile check.  Its based off of a compile time hack used in the
autoconf macro archive:

http://peti.cys.de/autoconf-archive/Miscellaneous/ac_compile_check_sizeof.html

	Okay to install?

		--Kaveh




1999-09-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* aclocal.m4 (GCC_C_LONG_DOUBLE): New macro.

	* configure.in (GCC_C_LONG_DOUBLE): Call it.

	* gansidecl.h (HAVE_LONG_DOUBLE): Define if gcc for stage2.

	* ggc-simple.c (HAVE_LONG_DOUBLE): Test before using long double.


diff -rup orig/egcs-CVS19990914/gcc/aclocal.m4 egcs-CVS19990914/gcc/aclocal.m4
--- orig/egcs-CVS19990914/gcc/aclocal.m4	Thu Apr 15 09:46:03 1999
+++ egcs-CVS19990914/gcc/aclocal.m4	Tue Sep 14 17:56:38 1999
@@ -172,6 +172,25 @@ if test $gcc_cv_c_volatile = yes ; then
 fi
 ])
 
+dnl Check whether long double is supported.  This differs from the
+dnl built-in autoconf test in that it works for cross compiles.
+AC_DEFUN(GCC_C_LONG_DOUBLE,
+[AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
+[if test "$GCC" = yes; then
+  gcc_cv_c_long_double=yes
+else
+AC_TRY_COMPILE(,
+[/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
+long double foo = 0.0;
+/* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
+switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
+gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
+fi])
+if test $gcc_cv_c_long_double = yes; then
+  AC_DEFINE(HAVE_LONG_DOUBLE)
+fi
+])
+
 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
 dnl of the usual 2.
 AC_DEFUN(GCC_FUNC_MKDIR_TAKES_ONE_ARG,
diff -rup orig/egcs-CVS19990914/gcc/configure.in egcs-CVS19990914/gcc/configure.in
--- orig/egcs-CVS19990914/gcc/configure.in	Tue Sep 14 07:42:55 1999
+++ egcs-CVS19990914/gcc/configure.in	Tue Sep 14 17:52:36 1999
@@ -284,6 +284,7 @@ AC_CANONICAL_SYSTEM
 
 # Find the native compiler
 AC_PROG_CC
+GCC_C_LONG_DOUBLE
 
 # If the native compiler is GCC, we can enable warnings even in stage1.  
 # That's useful for people building cross-compilers, or just running a
diff -rup orig/egcs-CVS19990914/gcc/gansidecl.h egcs-CVS19990914/gcc/gansidecl.h
--- orig/egcs-CVS19990914/gcc/gansidecl.h	Wed Sep  8 11:36:06 1999
+++ egcs-CVS19990914/gcc/gansidecl.h	Tue Sep 14 18:01:05 1999
@@ -45,6 +45,9 @@ Boston, MA 02111-1307, USA.  */
 # undef const
 # undef inline
 # define inline __inline__  /* Modern gcc can use `__inline__' freely. */
+# ifndef HAVE_LONG_DOUBLE
+#  define HAVE_LONG_DOUBLE 1
+# endif
 #endif /* GCC >= 2.7 */
 
 #ifndef NULL_PTR
diff -rup orig/egcs-CVS19990914/gcc/ggc-simple.c egcs-CVS19990914/gcc/ggc-simple.c
--- orig/egcs-CVS19990914/gcc/ggc-simple.c	Sun Sep 12 14:31:11 1999
+++ egcs-CVS19990914/gcc/ggc-simple.c	Tue Sep 14 17:59:48 1999
@@ -86,7 +86,11 @@ struct ggc_any
   union {
     char c;
     HOST_WIDE_INT i;
+#ifdef HAVE_LONG_DOUBLE
     long double d;
+#else
+    double d;
+#endif
   } u;
 };
 


More information about the Gcc-patches mailing list