public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH INSTALLED]: const typedefs part 2/N
@ 2007-07-25 18:40 Kaveh R. GHAZI
  0 siblings, 0 replies; only message in thread
From: Kaveh R. GHAZI @ 2007-07-25 18:40 UTC (permalink / raw)
  To: gcc-patches

This patch mainly reduces the number of -Wcast-qual warnings.  I use that
warning flag to sanity check const typedef additions applied in later
patches.  So reducing the noise was (is) very helpful.

Bootstrapped on sparc-sun-solaris2.10, no regressions.  Installed.

		--Kaveh


2007-07-22  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* c-lex.c (c_lex_with_flags, lex_string): Constify.
	* c-ppoutput.c (print_line, pp_dir_change): Likewise.
	* c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise.
	* cfg.c (bb_copy_original_hash, bb_copy_original_eq): Likewise.
	* cfgloop.c (loop_exit_hash, loop_exit_eq): Likewise.
	* ddg.c (compare_sccs): Likewise.
	* df-scan.c (df_ref_compare, df_mw_compare): Likewise.
	* dfp.c (decimal_real_from_string, decimal_to_decnumber,
	decimal_to_binary, decimal_do_compare, decimal_real_to_decimal,
	decimal_do_fix_trunc, decimal_real_to_integer,
	decimal_real_to_integer2, decimal_real_maxval): Likewise.
	* dse.c (const_group_info_t): New.
	(invariant_group_base_eq, invariant_group_base_hash): Constify.
	* dwarf2out.c (const_dw_die_ref): New.
	(decl_die_table_hash, decl_die_table_eq, file_info_cmp): Constify.
	* tree-browser.c (TB_parent_eq): Likewise.
	* unwind-dw2-fde.c (__register_frame_info_bases,
	__deregister_frame_info_bases, fde_unencoded_compare, fde_split,
	add_fdes, linear_search_fdes, binary_search_unencoded_fdes):
	Likewise.
	* unwind-dw2-fde.h (get_cie, next_fde): Likewise.
	* unwind-dw2.c (uw_frame_state_for): Likewise.
	* value-prof.c (histogram_hash, histogram_eq): Likewise.
	* value-prof.h (const_histogram_value): New.

diff -rup orig/egcc-SVN20070721/gcc/c-lex.c egcc-SVN20070721/gcc/c-lex.c
--- orig/egcc-SVN20070721/gcc/c-lex.c	2007-07-03 11:26:18.000000000 -0400
+++ egcc-SVN20070721/gcc/c-lex.c	2007-07-22 13:29:26.240633416 -0400
@@ -460,7 +460,7 @@ c_lex_with_flags (tree *value, location_
 	  type = lex_string (tok, value, false);
 	  break;
 	}
-      *value = build_string (tok->val.str.len, (char *) tok->val.str.text);
+      *value = build_string (tok->val.str.len, (const char *) tok->val.str.text);
       break;

     case CPP_PRAGMA:
@@ -811,7 +811,7 @@ lex_string (const cpp_token *tok, tree *
        ? cpp_interpret_string : cpp_interpret_string_notranslate)
       (parse_in, strs, concats + 1, &istr, wide))
     {
-      value = build_string (istr.len, (char *) istr.text);
+      value = build_string (istr.len, (const char *) istr.text);
       free ((void *) istr.text);

       if (c_lex_string_translate == -1)
@@ -824,13 +824,13 @@ lex_string (const cpp_token *tok, tree *
 	  gcc_assert (xlated);

 	  if (TREE_STRING_LENGTH (value) != (int) istr.len
-	      || 0 != strncmp (TREE_STRING_POINTER (value), (char *) istr.text,
-			       istr.len))
+	      || 0 != strncmp (TREE_STRING_POINTER (value),
+			       (const char *) istr.text, istr.len))
 	    {
 	      /* Arrange for us to return the untranslated string in
 		 *valp, but to set up the C type of the translated
 		 one.  */
-	      *valp = build_string (istr.len, (char *) istr.text);
+	      *valp = build_string (istr.len, (const char *) istr.text);
 	      valp = &TREE_CHAIN (*valp);
 	    }
 	  free ((void *) istr.text);
diff -rup orig/egcc-SVN20070721/gcc/c-ppoutput.c egcc-SVN20070721/gcc/c-ppoutput.c
--- orig/egcc-SVN20070721/gcc/c-ppoutput.c	2006-06-01 20:00:49.000000000 -0400
+++ egcc-SVN20070721/gcc/c-ppoutput.c	2007-07-22 14:46:48.991502966 -0400
@@ -255,7 +255,7 @@ print_line (source_location src_loc, con
       /* cpp_quote_string does not nul-terminate, so we have to do it
 	 ourselves.  */
       p = cpp_quote_string (to_file_quoted,
-			    (unsigned char *) map->to_file, to_file_len);
+			    (const unsigned char *) map->to_file, to_file_len);
       *p = '\0';
       fprintf (print.outf, "# %u \"%s\"%s",
 	       print.src_line == 0 ? 1 : print.src_line,
@@ -375,7 +375,7 @@ pp_dir_change (cpp_reader *pfile ATTRIBU
   unsigned char *p;

   /* cpp_quote_string does not nul-terminate, so we have to do it ourselves.  */
-  p = cpp_quote_string (to_file_quoted, (unsigned char *) dir, to_file_len);
+  p = cpp_quote_string (to_file_quoted, (const unsigned char *) dir, to_file_len);
   *p = '\0';
   fprintf (print.outf, "# 1 \"%s//\"\n", to_file_quoted);
 }
diff -rup orig/egcc-SVN20070721/gcc/c-typeck.c egcc-SVN20070721/gcc/c-typeck.c
--- orig/egcc-SVN20070721/gcc/c-typeck.c	2007-07-18 12:20:30.000000000 -0400
+++ egcc-SVN20070721/gcc/c-typeck.c	2007-07-22 13:26:52.775873071 -0400
@@ -1024,9 +1024,10 @@ free_all_tagged_tu_seen_up_to (const str
   const struct tagged_tu_seen_cache *tu = tagged_tu_seen_base;
   while (tu != tu_til)
     {
-      struct tagged_tu_seen_cache *tu1 = (struct tagged_tu_seen_cache*)tu;
+      const struct tagged_tu_seen_cache *tu1
+	= (const struct tagged_tu_seen_cache*)tu;
       tu = tu1->next;
-      free (tu1);
+      free ((void *)tu1);
     }
   tagged_tu_seen_base = tu_til;
 }
diff -rup orig/egcc-SVN20070721/gcc/cfg.c egcc-SVN20070721/gcc/cfg.c
--- orig/egcc-SVN20070721/gcc/cfg.c	2007-07-09 23:03:16.000000000 -0400
+++ egcc-SVN20070721/gcc/cfg.c	2007-07-22 14:51:30.011271303 -0400
@@ -1107,18 +1107,18 @@ struct htab_bb_copy_original_entry
 static hashval_t
 bb_copy_original_hash (const void *p)
 {
-  struct htab_bb_copy_original_entry *data
-    = ((struct htab_bb_copy_original_entry *)p);
+  const struct htab_bb_copy_original_entry *data
+    = ((const struct htab_bb_copy_original_entry *)p);

   return data->index1;
 }
 static int
 bb_copy_original_eq (const void *p, const void *q)
 {
-  struct htab_bb_copy_original_entry *data
-    = ((struct htab_bb_copy_original_entry *)p);
-  struct htab_bb_copy_original_entry *data2
-    = ((struct htab_bb_copy_original_entry *)q);
+  const struct htab_bb_copy_original_entry *data
+    = ((const struct htab_bb_copy_original_entry *)p);
+  const struct htab_bb_copy_original_entry *data2
+    = ((const struct htab_bb_copy_original_entry *)q);

   return data->index1 == data2->index1;
 }
diff -rup orig/egcc-SVN20070721/gcc/cfgloop.c egcc-SVN20070721/gcc/cfgloop.c
--- orig/egcc-SVN20070721/gcc/cfgloop.c	2007-06-11 23:03:28.000000000 -0400
+++ egcc-SVN20070721/gcc/cfgloop.c	2007-07-22 14:53:14.673231245 -0400
@@ -930,7 +930,7 @@ get_loop_body_in_bfs_order (const struct
 static hashval_t
 loop_exit_hash (const void *ex)
 {
-  struct loop_exit *exit = (struct loop_exit *) ex;
+  const struct loop_exit *const exit = (const struct loop_exit *) ex;

   return htab_hash_pointer (exit->e);
 }
@@ -940,7 +940,7 @@ loop_exit_hash (const void *ex)
 static int
 loop_exit_eq (const void *ex, const void *e)
 {
-  struct loop_exit *exit = (struct loop_exit *) ex;
+  const struct loop_exit *const exit = (const struct loop_exit *) ex;

   return exit->e == e;
 }
diff -rup orig/egcc-SVN20070721/gcc/ddg.c egcc-SVN20070721/gcc/ddg.c
--- orig/egcc-SVN20070721/gcc/ddg.c	2007-07-03 11:26:18.000000000 -0400
+++ egcc-SVN20070721/gcc/ddg.c	2007-07-22 14:50:41.755466541 -0400
@@ -856,8 +856,8 @@ find_predecessors (sbitmap preds, ddg_pt
 static int
 compare_sccs (const void *s1, const void *s2)
 {
-  int rec_l1 = (*(ddg_scc_ptr *)s1)->recurrence_length;
-  int rec_l2 = (*(ddg_scc_ptr *)s2)->recurrence_length;
+  const int rec_l1 = (*(const ddg_scc_ptr *)s1)->recurrence_length;
+  const int rec_l2 = (*(const ddg_scc_ptr *)s2)->recurrence_length;
   return ((rec_l2 > rec_l1) - (rec_l2 < rec_l1));

 }
diff -rup orig/egcc-SVN20070721/gcc/df-scan.c egcc-SVN20070721/gcc/df-scan.c
--- orig/egcc-SVN20070721/gcc/df-scan.c	2007-07-07 23:02:54.000000000 -0400
+++ egcc-SVN20070721/gcc/df-scan.c	2007-07-22 14:43:36.772927425 -0400
@@ -2148,8 +2148,8 @@ df_ref_equal_p (struct df_ref *ref1, str
 static int
 df_ref_compare (const void *r1, const void *r2)
 {
-  const struct df_ref *ref1 = *(struct df_ref **)r1;
-  const struct df_ref *ref2 = *(struct df_ref **)r2;
+  const struct df_ref *const ref1 = *(const struct df_ref *const*)r1;
+  const struct df_ref *const ref2 = *(const struct df_ref *const*)r2;

   if (ref1 == ref2)
     return 0;
@@ -2265,8 +2265,8 @@ df_mw_equal_p (struct df_mw_hardreg *mw1
 static int
 df_mw_compare (const void *m1, const void *m2)
 {
-  const struct df_mw_hardreg *mw1 = *(struct df_mw_hardreg **)m1;
-  const struct df_mw_hardreg *mw2 = *(struct df_mw_hardreg **)m2;
+  const struct df_mw_hardreg *const mw1 = *(const struct df_mw_hardreg *const*)m1;
+  const struct df_mw_hardreg *const mw2 = *(const struct df_mw_hardreg *const*)m2;

   if (mw1 == mw2)
     return 0;
diff -rup orig/egcc-SVN20070721/gcc/dfp.c egcc-SVN20070721/gcc/dfp.c
--- orig/egcc-SVN20070721/gcc/dfp.c	2007-03-24 20:02:39.000000000 -0500
+++ egcc-SVN20070721/gcc/dfp.c	2007-07-22 14:39:45.392485100 -0400
@@ -96,7 +96,7 @@ decimal_real_from_string (REAL_VALUE_TYP
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;

-  decNumberFromString (&dn, (char *) s, &set);
+  decNumberFromString (&dn, s, &set);

   /* It would be more efficient to store directly in decNumber format,
      but that is impractical from current data structure size.
@@ -119,17 +119,17 @@ decimal_to_decnumber (const REAL_VALUE_T
       decNumberZero (dn);
       break;
     case rvc_inf:
-      decNumberFromString (dn, (char *)"Infinity", &set);
+      decNumberFromString (dn, "Infinity", &set);
       break;
     case rvc_nan:
       if (r->signalling)
-        decNumberFromString (dn, (char *)"snan", &set);
+        decNumberFromString (dn, "snan", &set);
       else
-        decNumberFromString (dn, (char *)"nan", &set);
+        decNumberFromString (dn, "nan", &set);
       break;
     case rvc_normal:
       gcc_assert (r->decimal);
-      decimal128ToNumber ((decimal128 *) r->sig, dn);
+      decimal128ToNumber ((const decimal128 *) r->sig, dn);
       break;
     default:
       gcc_unreachable ();
@@ -312,8 +312,7 @@ decimal_to_binary (REAL_VALUE_TYPE *to,
 		   enum machine_mode mode)
 {
   char string[256];
-  decimal128 *d128;
-  d128 = (decimal128 *) from->sig;
+  const decimal128 *const d128 = (const decimal128 *) from->sig;

   decimal128ToString (d128, string);
   real_from_string3 (to, string, mode);
@@ -360,8 +359,8 @@ decimal_do_compare (const REAL_VALUE_TYP
   /* Convert into decNumber form for comparison operation.  */
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;
-  decimal128ToNumber ((decimal128 *) a->sig, &dn2);
-  decimal128ToNumber ((decimal128 *) b->sig, &dn3);
+  decimal128ToNumber ((const decimal128 *) a->sig, &dn2);
+  decimal128ToNumber ((const decimal128 *) b->sig, &dn3);

   /* Finally, do the comparison.  */
   decNumberCompare (&dn, &dn2, &dn3, &set);
@@ -451,7 +450,7 @@ decimal_real_to_decimal (char *str, cons
 			 size_t digits ATTRIBUTE_UNUSED,
 			 int crop_trailing_zeros ATTRIBUTE_UNUSED)
 {
-  decimal128 *d128 = (decimal128*) r_orig->sig;
+  const decimal128 *const d128 = (const decimal128*) r_orig->sig;

   /* decimal128ToString requires space for at least 24 characters;
      Require two more for suffix.  */
@@ -540,7 +539,7 @@ decimal_do_fix_trunc (REAL_VALUE_TYPE *r
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;
   set.round = DEC_ROUND_DOWN;
-  decimal128ToNumber ((decimal128 *) a->sig, &dn2);
+  decimal128ToNumber ((const decimal128 *) a->sig, &dn2);

   decNumberToIntegralValue (&dn, &dn2, &set);
   decimal_from_decnumber (r, &dn, &set);
@@ -559,7 +558,7 @@ decimal_real_to_integer (const REAL_VALU
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;
   set.round = DEC_ROUND_DOWN;
-  decimal128ToNumber ((decimal128 *) r->sig, &dn);
+  decimal128ToNumber ((const decimal128 *) r->sig, &dn);

   decNumberToIntegralValue (&dn2, &dn, &set);
   decNumberZero (&dn3);
@@ -586,7 +585,7 @@ decimal_real_to_integer2 (HOST_WIDE_INT
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;
   set.round = DEC_ROUND_DOWN;
-  decimal128ToNumber ((decimal128 *) r->sig, &dn);
+  decimal128ToNumber ((const decimal128 *) r->sig, &dn);

   decNumberToIntegralValue (&dn2, &dn, &set);
   decNumberZero (&dn3);
@@ -689,18 +688,18 @@ decimal_real_arithmetic (REAL_VALUE_TYPE
 void
 decimal_real_maxval (REAL_VALUE_TYPE *r, int sign, enum machine_mode mode)
 {
-  char *max;
+  const char *max;

   switch (mode)
     {
     case SDmode:
-      max = (char *) "9.999999E96";
+      max = "9.999999E96";
       break;
     case DDmode:
-      max = (char *) "9.999999999999999E384";
+      max = "9.999999999999999E384";
       break;
     case TDmode:
-      max = (char *) "9.999999999999999999999999999999999E6144";
+      max = "9.999999999999999999999999999999999E6144";
       break;
     default:
       gcc_unreachable ();
diff -rup orig/egcc-SVN20070721/gcc/dse.c egcc-SVN20070721/gcc/dse.c
--- orig/egcc-SVN20070721/gcc/dse.c	2007-07-07 23:02:54.000000000 -0400
+++ egcc-SVN20070721/gcc/dse.c	2007-07-22 14:41:50.699256339 -0400
@@ -441,6 +441,7 @@ struct group_info
   int offset_map_size_n, offset_map_size_p;
 };
 typedef struct group_info *group_info_t;
+typedef const struct group_info *const_group_info_t;
 static alloc_pool rtx_group_info_pool;

 /* Tables of group_info structures, hashed by base value.  */
@@ -575,8 +576,8 @@ clear_alias_set_lookup (HOST_WIDE_INT al
 static int
 invariant_group_base_eq (const void *p1, const void *p2)
 {
-  const group_info_t gi1 = (const group_info_t) p1;
-  const group_info_t gi2 = (const group_info_t) p2;
+  const_group_info_t gi1 = (const_group_info_t) p1;
+  const_group_info_t gi2 = (const_group_info_t) p2;
   return rtx_equal_p (gi1->rtx_base, gi2->rtx_base);
 }

@@ -584,7 +585,7 @@ invariant_group_base_eq (const void *p1,
 static hashval_t
 invariant_group_base_hash (const void *p)
 {
-  const group_info_t gi = (const group_info_t) p;
+  const_group_info_t gi = (const_group_info_t) p;
   int do_not_record;
   return hash_rtx (gi->rtx_base, Pmode, &do_not_record, NULL, false);
 }
diff -rup orig/egcc-SVN20070721/gcc/dwarf2out.c egcc-SVN20070721/gcc/dwarf2out.c
--- orig/egcc-SVN20070721/gcc/dwarf2out.c	2007-07-13 23:02:14.000000000 -0400
+++ egcc-SVN20070721/gcc/dwarf2out.c	2007-07-22 14:35:27.636890666 -0400
@@ -2700,6 +2700,7 @@ struct dwarf_file_data GTY(())

 typedef struct dw_val_struct *dw_val_ref;
 typedef struct die_struct *dw_die_ref;
+typedef const struct die_struct *const_dw_die_ref;
 typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
 typedef struct dw_loc_list_struct *dw_loc_list_ref;

@@ -5685,7 +5686,7 @@ equate_type_number_to_die (tree type, dw
 static hashval_t
 decl_die_table_hash (const void *x)
 {
-  return (hashval_t) ((const dw_die_ref) x)->decl_id;
+  return (hashval_t) ((const_dw_die_ref) x)->decl_id;
 }

 /* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y.  */
@@ -5693,7 +5694,7 @@ decl_die_table_hash (const void *x)
 static int
 decl_die_table_eq (const void *x, const void *y)
 {
-  return (((const dw_die_ref) x)->decl_id == DECL_UID ((const tree) y));
+  return (((const_dw_die_ref) x)->decl_id == DECL_UID ((const tree) y));
 }

 /* Return the DIE associated with a given declaration.  */
@@ -7778,8 +7779,8 @@ file_info_cmp (const void *p1, const voi
 {
   const struct file_info *s1 = p1;
   const struct file_info *s2 = p2;
-  unsigned char *cp1;
-  unsigned char *cp2;
+  const unsigned char *cp1;
+  const unsigned char *cp2;

   /* Take care of file names without directories.  We need to make sure that
      we return consistent values to qsort since some will get confused if
@@ -7789,18 +7790,18 @@ file_info_cmp (const void *p1, const voi
   if ((s1->path == s1->fname || s2->path == s2->fname))
     return (s2->path == s2->fname) - (s1->path == s1->fname);

-  cp1 = (unsigned char *) s1->path;
-  cp2 = (unsigned char *) s2->path;
+  cp1 = (const unsigned char *) s1->path;
+  cp2 = (const unsigned char *) s2->path;

   while (1)
     {
       ++cp1;
       ++cp2;
       /* Reached the end of the first path?  If so, handle like above.  */
-      if ((cp1 == (unsigned char *) s1->fname)
-	  || (cp2 == (unsigned char *) s2->fname))
-	return ((cp2 == (unsigned char *) s2->fname)
-		- (cp1 == (unsigned char *) s1->fname));
+      if ((cp1 == (const unsigned char *) s1->fname)
+	  || (cp2 == (const unsigned char *) s2->fname))
+	return ((cp2 == (const unsigned char *) s2->fname)
+		- (cp1 == (const unsigned char *) s1->fname));

       /* Character of current path component the same?  */
       else if (*cp1 != *cp2)
diff -rup orig/egcc-SVN20070721/gcc/tree-browser.c egcc-SVN20070721/gcc/tree-browser.c
--- orig/egcc-SVN20070721/gcc/tree-browser.c	2007-02-15 20:03:53.000000000 -0500
+++ egcc-SVN20070721/gcc/tree-browser.c	2007-07-22 14:45:40.994235016 -0400
@@ -751,9 +751,8 @@ store_child_info (tree *tp, int *walk_su
 static int
 TB_parent_eq (const void *p1, const void *p2)
 {
-  tree node, parent;
-  node = (tree) p2;
-  parent = (tree) p1;
+  const_tree node = (const_tree)p2;
+  tree parent = (tree) p1;

   if (p1 == NULL || p2 == NULL)
     return 0;
diff -rup orig/egcc-SVN20070721/gcc/unwind-dw2-fde.c egcc-SVN20070721/gcc/unwind-dw2-fde.c
--- orig/egcc-SVN20070721/gcc/unwind-dw2-fde.c	2007-01-24 20:02:27.000000000 -0500
+++ egcc-SVN20070721/gcc/unwind-dw2-fde.c	2007-07-22 13:21:01.452549219 -0400
@@ -79,7 +79,7 @@ __register_frame_info_bases (const void
 			     void *tbase, void *dbase)
 {
   /* If .eh_frame is empty, don't register at all.  */
-  if ((uword *) begin == 0 || *(uword *) begin == 0)
+  if ((const uword *) begin == 0 || *(const uword *) begin == 0)
     return;

   ob->pc_begin = (void *)-1;
@@ -177,7 +177,7 @@ __deregister_frame_info_bases (const voi
   struct object *ob = 0;

   /* If .eh_frame is empty, we haven't registered.  */
-  if ((uword *) begin == 0 || *(uword *) begin == 0)
+  if ((const uword *) begin == 0 || *(const uword *) begin == 0)
     return ob;

   init_object_mutex_once ();
@@ -323,8 +323,8 @@ static int
 fde_unencoded_compare (struct object *ob __attribute__((unused)),
 		       const fde *x, const fde *y)
 {
-  _Unwind_Ptr x_ptr = *(_Unwind_Ptr *) x->pc_begin;
-  _Unwind_Ptr y_ptr = *(_Unwind_Ptr *) y->pc_begin;
+  const _Unwind_Ptr x_ptr = *(const _Unwind_Ptr *) x->pc_begin;
+  const _Unwind_Ptr y_ptr = *(const _Unwind_Ptr *) y->pc_begin;

   if (x_ptr > y_ptr)
     return 1;
@@ -434,7 +434,7 @@ fde_split (struct object *ob, fde_compar
 {
   static const fde *marker;
   size_t count = linear->count;
-  const fde **chain_end = &marker;
+  const fde *const *chain_end = &marker;
   size_t i, j, k;

   /* This should optimize out, but it is wise to make sure this assumption
@@ -444,13 +444,13 @@ fde_split (struct object *ob, fde_compar

   for (i = 0; i < count; i++)
     {
-      const fde **probe;
+      const fde *const *probe;

       for (probe = chain_end;
 	   probe != &marker && fde_compare (ob, linear->array[i], *probe) < 0;
 	   probe = chain_end)
 	{
-	  chain_end = (const fde **) erratic->array[probe - linear->array];
+	  chain_end = (const fde *const*) erratic->array[probe - linear->array];
 	  erratic->array[probe - linear->array] = NULL;
 	}
       erratic->array[i] = (const fde *) chain_end;
@@ -679,7 +679,7 @@ add_fdes (struct object *ob, struct fde_

       if (encoding == DW_EH_PE_absptr)
 	{
-	  if (*(_Unwind_Ptr *) this_fde->pc_begin == 0)
+	  if (*(const _Unwind_Ptr *) this_fde->pc_begin == 0)
 	    continue;
 	}
       else
@@ -797,8 +797,8 @@ linear_search_fdes (struct object *ob, c

       if (encoding == DW_EH_PE_absptr)
 	{
-	  pc_begin = ((_Unwind_Ptr *) this_fde->pc_begin)[0];
-	  pc_range = ((_Unwind_Ptr *) this_fde->pc_begin)[1];
+	  pc_begin = ((const _Unwind_Ptr *) this_fde->pc_begin)[0];
+	  pc_range = ((const _Unwind_Ptr *) this_fde->pc_begin)[1];
 	  if (pc_begin == 0)
 	    continue;
 	}
@@ -844,12 +844,9 @@ binary_search_unencoded_fdes (struct obj
   for (lo = 0, hi = vec->count; lo < hi; )
     {
       size_t i = (lo + hi) / 2;
-      const fde *f = vec->array[i];
-      void *pc_begin;
-      uaddr pc_range;
-
-      pc_begin = ((void **) f->pc_begin)[0];
-      pc_range = ((uaddr *) f->pc_begin)[1];
+      const fde *const f = vec->array[i];
+      const void *pc_begin = ((const void *const*) f->pc_begin)[0];
+      const uaddr pc_range = ((const uaddr *) f->pc_begin)[1];

       if (pc < pc_begin)
 	hi = i;
diff -rup orig/egcc-SVN20070721/gcc/unwind-dw2-fde.h egcc-SVN20070721/gcc/unwind-dw2-fde.h
--- orig/egcc-SVN20070721/gcc/unwind-dw2-fde.h	2006-01-23 00:23:57.000000000 -0500
+++ egcc-SVN20070721/gcc/unwind-dw2-fde.h	2007-07-22 13:01:32.841274542 -0400
@@ -160,13 +160,13 @@ typedef struct dwarf_fde fde;
 static inline const struct dwarf_cie *
 get_cie (const struct dwarf_fde *f)
 {
-  return (void *)&f->CIE_delta - f->CIE_delta;
+  return (const void *)&f->CIE_delta - f->CIE_delta;
 }

 static inline const fde *
 next_fde (const fde *f)
 {
-  return (const fde *) ((char *) f + f->length + sizeof (f->length));
+  return (const fde *) ((const char *) f + f->length + sizeof (f->length));
 }

 extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
diff -rup orig/egcc-SVN20070721/gcc/unwind-dw2.c egcc-SVN20070721/gcc/unwind-dw2.c
--- orig/egcc-SVN20070721/gcc/unwind-dw2.c	2007-05-18 23:02:37.000000000 -0400
+++ egcc-SVN20070721/gcc/unwind-dw2.c	2007-07-22 13:07:45.553871181 -0400
@@ -1141,11 +1141,11 @@ uw_frame_state_for (struct _Unwind_Conte
     return _URC_FATAL_PHASE1_ERROR;

   /* First decode all the insns in the CIE.  */
-  end = (unsigned char *) next_fde ((struct dwarf_fde *) cie);
+  end = (const unsigned char *) next_fde ((const struct dwarf_fde *) cie);
   execute_cfa_program (insn, end, context, fs);

   /* Locate augmentation for the fde.  */
-  aug = (unsigned char *) fde + sizeof (*fde);
+  aug = (const unsigned char *) fde + sizeof (*fde);
   aug += 2 * size_of_encoded_value (fs->fde_encoding);
   insn = NULL;
   if (fs->saw_z)
@@ -1165,7 +1165,7 @@ uw_frame_state_for (struct _Unwind_Conte
   /* Then the insns in the FDE up to our target PC.  */
   if (insn == NULL)
     insn = aug;
-  end = (unsigned char *) next_fde (fde);
+  end = (const unsigned char *) next_fde (fde);
   execute_cfa_program (insn, end, context, fs);

   return _URC_NO_REASON;
diff -rup orig/egcc-SVN20070721/gcc/value-prof.c egcc-SVN20070721/gcc/value-prof.c
--- orig/egcc-SVN20070721/gcc/value-prof.c	2007-04-27 20:03:02.000000000 -0400
+++ egcc-SVN20070721/gcc/value-prof.c	2007-07-22 13:24:41.097160439 -0400
@@ -107,7 +107,7 @@ gimple_alloc_histogram_value (struct fun
 static hashval_t
 histogram_hash (const void *x)
 {
-  return htab_hash_pointer (((histogram_value)x)->hvalue.stmt);
+  return htab_hash_pointer (((const_histogram_value)x)->hvalue.stmt);
 }

 /* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y.  */
@@ -115,7 +115,7 @@ histogram_hash (const void *x)
 static int
 histogram_eq (const void *x, const void *y)
 {
-  return ((histogram_value) x)->hvalue.stmt == (tree)y;
+  return ((const_histogram_value) x)->hvalue.stmt == (const_tree)y;
 }

 /* Set histogram for STMT.  */
diff -rup orig/egcc-SVN20070721/gcc/value-prof.h egcc-SVN20070721/gcc/value-prof.h
--- orig/egcc-SVN20070721/gcc/value-prof.h	2007-01-28 20:02:58.000000000 -0500
+++ egcc-SVN20070721/gcc/value-prof.h	2007-07-22 13:24:03.810749538 -0400
@@ -64,6 +64,7 @@ struct histogram_value_t
 };

 typedef struct histogram_value_t *histogram_value;
+typedef const struct histogram_value_t *const_histogram_value;

 DEF_VEC_P(histogram_value);
 DEF_VEC_ALLOC_P(histogram_value,heap);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-25 18:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25 18:40 [PATCH INSTALLED]: const typedefs part 2/N Kaveh R. GHAZI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).