* 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.
From-SVN: r126920
+2007-07-25 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.
+
2007-07-25 Richard Sandiford <richard@codesourcery.com>
* config/mips/mips.c (machine_function): Add
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:
? 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)
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);
/* 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,
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);
}
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;
}
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;
}
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);
}
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;
}
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));
}
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;
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;
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.
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 ();
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);
/* 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);
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. */
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);
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);
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);
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 ();
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. */
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);
}
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);
}
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;
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. */
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. */
{
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
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)
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;
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;
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 ();
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;
{
static const fde *marker;
size_t count = linear->count;
- const fde **chain_end = ▮
+ const fde *const *chain_end = ▮
size_t i, j, k;
/* This should optimize out, but it is wise to make sure this assumption
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;
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
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;
}
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;
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 *);
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)
/* 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;
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. */
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. */
};
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);