]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2014-06-04 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Jun 2014 12:35:26 +0000 (12:35 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Jun 2014 12:35:26 +0000 (12:35 +0000)
* configure.ac: Check whether the underlying type of int64_t
is long or long long.
* configure: Regenerate.
* config.in: Likewise.
* hwint.h (HOST_WIDE_INT): Match the underlying type of int64_t.
(HOST_WIDE_INT_PRINT_*): Define in terms of PRI*64.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211228 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config.in
gcc/configure
gcc/configure.ac
gcc/hwint.h

index 645dc0b4cc09db4ea422af57de757f8d885b2ffa..71bad63bf07ec835cf5496fd0373858bb3a0172c 100644 (file)
@@ -1,3 +1,12 @@
+2014-06-04  Richard Biener  <rguenther@suse.de>
+
+       * configure.ac: Check whether the underlying type of int64_t
+       is long or long long.
+       * configure: Regenerate.
+       * config.in: Likewise.
+       * hwint.h (HOST_WIDE_INT): Match the underlying type of int64_t.
+       (HOST_WIDE_INT_PRINT_*): Define in terms of PRI*64.
+
 2014-06-04  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/60098
index 2313307117cd09e92c256a70c9d03fbc1df91363..fb7bf954db2203729f7aa2e9f0aaf0b3da5c92f7 100644 (file)
 #endif
 
 
+/* Define if int64_t uses long as underlying type. */
+#ifndef USED_FOR_TARGET
+#undef INT64_T_IS_LONG
+#endif
+
+
 /* Define to the linker option to ignore unused dependencies. */
 #ifndef USED_FOR_TARGET
 #undef LD_AS_NEEDED_OPTION
index f60d3476a654af1608ae32f887426115cbc1a08f..6c35041b6a79039fa72b683e0f2b31dc7d833abd 100755 (executable)
@@ -6230,6 +6230,87 @@ if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then
   as_fn_error "uint64_t or int64_t not found" "$LINENO" 5
 fi
 
+# check what underlying integer type int64_t uses
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for int64_t underlying type" >&5
+$as_echo_n "checking for int64_t underlying type... " >&6; }
+if test "${ac_cv_int64_t_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+template <typename T> struct X { };
+template <>
+struct X<long> { typedef long t; };
+
+int
+main ()
+{
+X<int64_t>::t x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_int64_t_type=long
+else
+  ac_cv_int64_t_type="long long"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_int64_t_type" >&5
+$as_echo "$ac_cv_int64_t_type" >&6; }
+if test "$ac_cv_int64_t_type" = "long"; then
+
+$as_echo "#define INT64_T_IS_LONG 1" >>confdefs.h
+
+else
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+template <typename T> struct X { };
+template <>
+struct X<long long> { typedef long long t; };
+
+int
+main ()
+{
+X<int64_t>::t x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  as_fn_error "error verifying int64_t uses long long" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
 # ---------------------
 # Warnings and checking
 # ---------------------
@@ -8746,7 +8827,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
 
-
 for ac_header in unordered_map
 do :
   ac_fn_cxx_check_header_preproc "$LINENO" "unordered_map" "ac_cv_header_unordered_map"
@@ -9163,7 +9243,8 @@ LIBS="$save_LIBS"
 
 
 # Use <inttypes.h> only if it exists,
-# doesn't clash with <sys/types.h>, and declares intmax_t.
+# doesn't clash with <sys/types.h>, declares intmax_t and defines
+# PRId64
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5
 $as_echo_n "checking for inttypes.h... " >&6; }
 if test "${gcc_cv_header_inttypes_h+set}" = set; then :
@@ -9171,12 +9252,16 @@ if test "${gcc_cv_header_inttypes_h+set}" = set; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+#define __STDC_FORMAT_MACROS
 #include <sys/types.h>
 #include <inttypes.h>
 int
 main ()
 {
 intmax_t i = -1;
+#ifndef PRId64
+choke me
+#endif
   ;
   return 0;
 }
@@ -17948,7 +18033,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17951 "configure"
+#line 18036 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18054,7 +18139,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18057 "configure"
+#line 18142 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index aa697cebce9ac27f710292fc09dc5fdb63591c8e..2cec62a7eaead684c54039e37a22ee2e401bf76e 100644 (file)
@@ -316,6 +316,35 @@ if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then
   AC_MSG_ERROR([uint64_t or int64_t not found])
 fi
 
+# check what underlying integer type int64_t uses
+AC_LANG_PUSH(C++)
+AC_CACHE_CHECK(for int64_t underlying type, ac_cv_int64_t_type, [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+template <typename T> struct X { };
+template <>
+struct X<long> { typedef long t; };
+]], [[X<int64_t>::t x;]])],[ac_cv_int64_t_type=long],[ac_cv_int64_t_type="long long"])])
+if test "$ac_cv_int64_t_type" = "long"; then
+  AC_DEFINE(INT64_T_IS_LONG, 1,
+  [Define if int64_t uses long as underlying type.])
+else
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+template <typename T> struct X { };
+template <>
+struct X<long long> { typedef long long t; };
+]], [[X<int64_t>::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])])
+fi
+AC_LANG_POP(C++)
+
+
+
+
 # ---------------------
 # Warnings and checking
 # ---------------------
@@ -1055,13 +1084,18 @@ LIBS="$save_LIBS"
 AC_SUBST(LDEXP_LIB)
 
 # Use <inttypes.h> only if it exists,
-# doesn't clash with <sys/types.h>, and declares intmax_t.
+# doesn't clash with <sys/types.h>, declares intmax_t and defines
+# PRId64
 AC_MSG_CHECKING(for inttypes.h)
 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[#include <sys/types.h>
+[[#define __STDC_FORMAT_MACROS
+#include <sys/types.h>
 #include <inttypes.h>]],
-  [[intmax_t i = -1;]])],
+  [[intmax_t i = -1;
+#ifndef PRId64
+choke me
+#endif]])],
   [gcc_cv_header_inttypes_h=yes],
   [gcc_cv_header_inttypes_h=no])])
 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
index e3b8a8aa7d716784b19cde821c0bd2450dcfb61c..fd961fd91da4758f7ff62abeaff1280fe23e9009 100644 (file)
@@ -46,13 +46,11 @@ extern char sizeof_long_long_must_be_8[sizeof (long long) == 8 ? 1 : -1];
 #endif
 
 /* Set HOST_WIDE_INT, this should be always 64 bits.
-
-   With a sane ABI, 'long' is the largest efficient host integer type.
-   Thus, we use that unless we have to use 'long long'
-   because we're on a 32-bit host.  */
+   The underlying type is matched to that of int64_t and assumed
+   to be either long or long long.  */
 
 #define HOST_BITS_PER_WIDE_INT 64
-#if HOST_BITS_PER_LONG == 64
+#if INT64_T_IS_LONG   
 #   define HOST_WIDE_INT long
 #   define HOST_WIDE_INT_C(X) X ## L
 #else
@@ -75,48 +73,45 @@ extern char sizeof_long_long_must_be_8[sizeof (long long) == 8 ? 1 : -1];
    typedef before using the __asm_fprintf__ format attribute.  */
 typedef HOST_WIDE_INT __gcc_host_wide_int__;
 
-/* Various printf format strings for HOST_WIDE_INT.  */
-
-#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
-# define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
-# define HOST_WIDE_INT_PRINT_C "L"
-  /* HOST_BITS_PER_WIDE_INT is 64 bits.  */
-# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
-    "0x%" HOST_LONG_FORMAT "x%016" HOST_LONG_FORMAT "x"
-# define HOST_WIDE_INT_PRINT_PADDED_HEX \
-    "%016" HOST_LONG_FORMAT "x"
-#else
-# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
-# define HOST_WIDE_INT_PRINT_C "LL"
-  /* HOST_BITS_PER_WIDE_INT is 64 bits.  */
-# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
-    "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
-# define HOST_WIDE_INT_PRINT_PADDED_HEX \
-    "%016" HOST_LONG_LONG_FORMAT "x"
-#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */
-
-#define HOST_WIDE_INT_PRINT_DEC "%" HOST_WIDE_INT_PRINT "d"
-#define HOST_WIDE_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC HOST_WIDE_INT_PRINT_C
-#define HOST_WIDE_INT_PRINT_UNSIGNED "%" HOST_WIDE_INT_PRINT "u"
-#define HOST_WIDE_INT_PRINT_HEX "%#" HOST_WIDE_INT_PRINT "x"
-#define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
-
 /* Provide C99 <inttypes.h> style format definitions for 64bits.  */
 #ifndef HAVE_INTTYPES_H
+#if INT64_T_IS_LONG
+# define GCC_PRI64 HOST_LONG_FORMAT
+#else
+# define GCC_PRI64 HOST_LONG_LONG_FORMAT
+#endif
 #undef PRId64
-#define PRId64 HOST_WIDE_INT_PRINT "d"
+#define PRId64 GCC_PRI64 "d"
 #undef PRIi64
-#define PRIi64 HOST_WIDE_INT_PRINT "i"
+#define PRIi64 GCC_PRI64 "i"
 #undef PRIo64
-#define PRIo64 HOST_WIDE_INT_PRINT "o"
+#define PRIo64 GCC_PRI64 "o"
 #undef PRIu64
-#define PRIu64 HOST_WIDE_INT_PRINT "u"
+#define PRIu64 GCC_PRI64 "u"
 #undef PRIx64
-#define PRIx64 HOST_WIDE_INT_PRINT "x"
+#define PRIx64 GCC_PRI64 "x"
 #undef PRIX64
-#define PRIX64 HOST_WIDE_INT_PRINT "X"
+#define PRIX64 GCC_PRI64 "X"
 #endif
 
+/* Various printf format strings for HOST_WIDE_INT.  */
+
+#if INT64_T_IS_LONG
+# define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
+# define HOST_WIDE_INT_PRINT_C "L"
+#else
+# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
+# define HOST_WIDE_INT_PRINT_C "LL"
+#endif
+
+#define HOST_WIDE_INT_PRINT_DEC "%" PRId64
+#define HOST_WIDE_INT_PRINT_DEC_C "%" PRId64 HOST_WIDE_INT_PRINT_C
+#define HOST_WIDE_INT_PRINT_UNSIGNED "%" PRIu64
+#define HOST_WIDE_INT_PRINT_HEX "%#" PRIx64
+#define HOST_WIDE_INT_PRINT_HEX_PURE "%" PRIx64
+#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%" PRIx64 "%016" PRIx64
+#define HOST_WIDE_INT_PRINT_PADDED_HEX "%016" PRIx64
+
 /* Define HOST_WIDEST_FAST_INT to the widest integer type supported
    efficiently in hardware.  (That is, the widest integer type that fits
    in a hardware register.)  Normally this is "long" but on some hosts it