This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Test for host long long support rather than for gcc
- From: Ian Lance Taylor <ian at airs dot com>
- To: binutils at sourceware dot org
- Date: 24 Aug 2003 21:24:58 -0700
- Subject: Test for host long long support rather than for gcc
The current C standard mandates support for the `long long' type.
Currently in bfd.h we test for __GNUC__ to see whether `long long' is
supported. I propose changing that to test whether the host compiler
supports `long long'. This will let BFD use `long long' when
compiling with a new compiler which is not gcc.
The potential drawback is that bfd.h is installed, and it is possible
that somebody will use it with a different compiler. Therefore, using
tests for the host compiler in bfd.h is not necessarily completely
safe. However, it should be fine in practice.
Any comments?
Diffs to generated files omitted.
Ian
2003-08-24 Ian Lance Taylor <ian@airs.com>
* configure.in: Define and substitute BFD_HOST_LONG_LONG.
* bfd-in.h: Define BFD_HOST_LONG_LONG. Test it rather than
__GNUC__ when deciding whether to use long long for
BFD_HOST_64_BIT.
* configure, Makefile.in, doc/Makefile.in, bfd-in2.h: Regenerate.
Index: bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.64
diff -u -p -r1.64 bfd-in.h
--- bfd-in.h 11 Jul 2003 14:59:40 -0000 1.64
+++ bfd-in.h 25 Aug 2003 04:17:56 -0000
@@ -51,6 +51,7 @@ extern "C" {
#define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
+#define BFD_HOST_LONG_LONG @BFD_HOST_LONG_LONG@
#if @BFD_HOST_64_BIT_DEFINED@
#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
@@ -96,21 +97,19 @@ typedef int bfd_boolean;
/* Support for different sizes of target format ints and addresses.
If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
- set to 1 above. Otherwise, if gcc is being used, this code will
- use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be
- defined above. */
+ set to 1 above. Otherwise, if the host compiler used during
+ configuration supports long long, this code will use it.
+ Otherwise, BFD_HOST_64_BIT must be defined above. */
#ifndef BFD_HOST_64_BIT
# if BFD_HOST_64BIT_LONG
# define BFD_HOST_64_BIT long
# define BFD_HOST_U_64_BIT unsigned long
# else
-# ifdef __GNUC__
-# if __GNUC__ >= 2
+# if BFD_HOST_LONG_LONG
# define BFD_HOST_64_BIT long long
# define BFD_HOST_U_64_BIT unsigned long long
-# endif /* __GNUC__ >= 2 */
-# endif /* ! defined (__GNUC__) */
+# endif /* ! BFD_HOST_LONG_LONG */
# endif /* ! BFD_HOST_64BIT_LONG */
#endif /* ! defined (BFD_HOST_64_BIT) */
Index: configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.134
diff -u -p -r1.134 configure.in
--- configure.in 16 Jul 2003 22:48:58 -0000 1.134
+++ configure.in 25 Aug 2003 04:18:01 -0000
@@ -113,6 +113,7 @@ AC_SUBST(HDEFINES)
AC_PROG_INSTALL
BFD_HOST_64BIT_LONG=0
+BFD_HOST_LONG_LONG=0
BFD_HOST_64_BIT_DEFINED=0
BFD_HOST_64_BIT=
BFD_HOST_U_64_BIT=
@@ -123,7 +124,19 @@ elif test "x${HOST_64BIT_TYPE}" != "x";
BFD_HOST_64_BIT=${HOST_64BIT_TYPE}
BFD_HOST_U_64_BIT=${HOST_U_64BIT_TYPE}
fi
+
+AC_MSG_CHECKING([for long long])
+AC_CACHE_VAL(bfd_cv_has_long_long,
+[AC_TRY_COMPILE(,
+[unsigned long long ll = 18446744073709551615ULL;],
+bfd_cv_has_long_long=yes, bfd_cv_has_long_long=no)])
+AC_MSG_RESULT($bfd_cv_has_long_long)
+if test $bfd_cv_has_long_long = yes; then
+ BFD_HOST_LONG_LONG=1
+fi
+
AC_SUBST(BFD_HOST_64BIT_LONG)
+AC_SUBST(BFD_HOST_LONG_LONG)
AC_SUBST(BFD_HOST_64_BIT_DEFINED)
AC_SUBST(BFD_HOST_64_BIT)
AC_SUBST(BFD_HOST_U_64_BIT)