Hi,

this removes all the occurrences of int64_t in the host code, as well as some 
gratuitous occurrences of int32_t (there are real ones in DFP and LTO code).
Tested on i586-suse-linux and x86_64-suse-linux.  Any objections?

Are the LTO files present in the gcc directory compiled when LTO is disabled?
If so, a compiler with a 64-bit type is required on the host since GCC 4.5.0.


2011-12-10  Eric Botcazou  <ebotca...@adacore.com>

        * lto-streamer-out.c (write_symbol): Use proper 64-bit host type.
        * lto-cgraph.c (input_cgraph_opt_section): Use 'int' for offsets.
        * lto-streamer-in.c (lto_read_body): Likewise.
        (lto_input_toplevel_asms): Likewise.
        * lto-section-in.c (lto_create_simple_input_block): Likewise.
        * ipa-inline-analysis.c (inline_read_section): Likewise.
        * ipa-prop.c (ipa_prop_read_section): Likewise.
lto/
        * lto.h (lto_parse_hex): Delete.
        * lto.c (lto_read_decls): Use 'int' for offsets.
        (lto_parse_hex): Make static and return proper 64-bit host type.
        (lto_resolution_read): Use proper 64-bit host type.


-- 
Eric Botcazou
Index: lto-cgraph.c
===================================================================
--- lto-cgraph.c	(revision 182102)
+++ lto-cgraph.c	(working copy)
@@ -1689,9 +1689,9 @@ input_cgraph_opt_section (struct lto_fil
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib_main;
   unsigned int i;
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 182102)
+++ lto-streamer-out.c	(working copy)
@@ -1271,6 +1271,14 @@ lto_out_decl_state_written_size (struct
 /* Write symbol T into STREAM in CACHE. SEEN specifies symbols we wrote
    so far.  */
 
+#if HOST_BITS_PER_WIDE_INT >= 64
+# define host_int64 HOST_WIDE_INT
+#elif HOST_BITS_PER_WIDEST_INT >= 64
+# define host_int64 HOST_WIDEST_INT
+#else
+# error "host has no 64-bit type"
+#endif
+
 static void
 write_symbol (struct streamer_tree_cache_d *cache,
 	      struct lto_output_stream *stream,
@@ -1280,7 +1288,7 @@ write_symbol (struct streamer_tree_cache
   enum gcc_plugin_symbol_kind kind;
   enum gcc_plugin_symbol_visibility visibility;
   unsigned slot_num;
-  uint64_t size;
+  unsigned host_int64 size;
   const char *comdat;
   unsigned char c;
 
@@ -1338,7 +1346,7 @@ write_symbol (struct streamer_tree_cache
      when symbol has attribute (visibility("hidden")) specified.
      targetm.binds_local_p check DECL_VISIBILITY_SPECIFIED and gets this
      right. */
-     
+
   if (DECL_EXTERNAL (t)
       && !targetm.binds_local_p (t))
     visibility = GCCPV_DEFAULT;
@@ -1363,10 +1371,13 @@ write_symbol (struct streamer_tree_cache
       && DECL_SIZE (t)
       && TREE_CODE (DECL_SIZE (t)) == INTEGER_CST)
     {
-      size = (HOST_BITS_PER_WIDE_INT >= 64)
-	? (uint64_t) int_size_in_bytes (TREE_TYPE (t))
-	: (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
-		| TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#if HOST_BITS_PER_WIDE_INT >= 64
+      size = (unsigned host_int64) int_size_in_bytes (TREE_TYPE (t));
+#else
+      size
+	= (unsigned host_int64) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t)) << 32
+	  || (unsigned host_int64) TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#endif
     }
   else
     size = 0;
Index: lto-streamer-in.c
===================================================================
--- lto-streamer-in.c	(revision 182102)
+++ lto-streamer-in.c	(working copy)
@@ -979,9 +979,9 @@ lto_read_body (struct lto_file_decl_data
 {
   const struct lto_function_header *header;
   struct data_in *data_in;
-  int32_t cfg_offset;
-  int32_t main_offset;
-  int32_t string_offset;
+  int cfg_offset;
+  int main_offset;
+  int string_offset;
   struct lto_input_block ib_cfg;
   struct lto_input_block ib_main;
 
@@ -1172,7 +1172,7 @@ lto_input_toplevel_asms (struct lto_file
   const char *data = lto_get_section_data (file_data, LTO_section_asm,
 					   NULL, &len);
   const struct lto_asm_header *header = (const struct lto_asm_header *) data;
-  int32_t string_offset;
+  int string_offset;
   struct data_in *data_in;
   struct lto_input_block ib;
   tree str;
Index: lto-section-in.c
===================================================================
--- lto-section-in.c	(revision 182102)
+++ lto-section-in.c	(working copy)
@@ -224,7 +224,7 @@ lto_create_simple_input_block (struct lt
     = (const struct lto_simple_header *) data;
 
   struct lto_input_block* ib_main;
-  int32_t main_offset = sizeof (struct lto_simple_header);
+  int main_offset = sizeof (struct lto_simple_header);
 
   if (!data)
     return NULL;
Index: ipa-inline-analysis.c
===================================================================
--- ipa-inline-analysis.c	(revision 182102)
+++ ipa-inline-analysis.c	(working copy)
@@ -3019,9 +3019,9 @@ inline_read_section (struct lto_file_dec
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib;
   unsigned int i, count2, j;
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 182102)
+++ lto/lto.c	(working copy)
@@ -267,7 +267,7 @@ lto_read_in_decl_state (struct data_in *
   uint32_t ix;
   tree decl;
   uint32_t i, j;
-  
+
   ix = *data++;
   decl = streamer_tree_cache_get (data_in->reader_cache, ix);
   if (TREE_CODE (decl) != FUNCTION_DECL)
@@ -879,9 +879,9 @@ lto_read_decls (struct lto_file_decl_dat
 		VEC(ld_plugin_symbol_resolution_t,heap) *resolutions)
 {
   const struct lto_decl_header *header = (const struct lto_decl_header *) data;
-  const int32_t decl_offset = sizeof (struct lto_decl_header);
-  const int32_t main_offset = decl_offset + header->decl_state_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int decl_offset = sizeof (struct lto_decl_header);
+  const int main_offset = decl_offset + header->decl_state_size;
+  const int string_offset = main_offset + header->main_size;
   struct lto_input_block ib_main;
   struct data_in *data_in;
   unsigned int i;
@@ -939,10 +939,21 @@ lto_read_decls (struct lto_file_decl_dat
   lto_data_in_delete (data_in);
 }
 
-/* strtoll is not portable. */
-int64_t
-lto_parse_hex (const char *p) {
-  uint64_t ret = 0;
+#if HOST_BITS_PER_WIDE_INT >= 64
+# define host_int64 HOST_WIDE_INT
+#elif HOST_BITS_PER_WIDEST_INT >= 64
+# define host_int64 HOST_WIDEST_INT
+#else
+# error "host has no 64-bit type"
+#endif
+
+/* strtoll is not portable.  */
+
+static host_int64
+lto_parse_hex (const char *p)
+{
+  host_int64 ret = 0;
+
   for (; *p != '\0'; ++p)
     {
       char c = *p;
@@ -958,6 +969,7 @@ lto_parse_hex (const char *p) {
         internal_error ("could not parse hex number");
       ret |= part;
     }
+
   return ret;
 }
 
@@ -993,7 +1005,7 @@ lto_resolution_read (splay_tree file_ids
     {
       int t;
       char offset_p[17];
-      int64_t offset;
+      host_int64 offset;
       t = fscanf (resolution, "@0x%16s", offset_p);
       if (t != 1)
         internal_error ("could not parse file offset");
Index: lto/lto.h
===================================================================
--- lto/lto.h	(revision 182102)
+++ lto/lto.h	(working copy)
@@ -68,6 +68,4 @@ struct lto_section_list
   struct lto_section_slot *first, *last;
 };
 
-int64_t lto_parse_hex (const char *p);
-
 #endif /* LTO_H */
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 182102)
+++ ipa-prop.c	(working copy)
@@ -3003,9 +3003,9 @@ ipa_prop_read_section (struct lto_file_d
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib_main;
   unsigned int i;

Reply via email to