2003-10-31 Andreas Jaeger <aj@suse.de>,

Zack Weinberg  <zack@codesourcery.com>


        * crtstuff.c (__register_frame_info, __register_frame_info_bases)
        (__deregister_frame_info, __deregister_frame_info_bases):
        Constify void * argument.
        * unwind-dw2-fde.h (struct fde_vector):
        Constify 'orig_data' and 'array' fields.
        (__register_frame_info, __register_frame_info_bases)
        (__deregister_frame_info, __deregister_frame_info_bases):
        Constify void * argument.
        (get_cie, next_fde, _Unwind_Find_FDE): Constify arguments,
        return values, and casts of type fde *, struct dwarf_fde *,
        and struct dwarf_cie *.
        * unwind-dw2-fde.c (__register_frame_info, __register_frame_info_bases)
        (__deregister_frame_info, __deregister_frame_info_bases):
        Constify void * argument.
        (get_cie_encoding, ): Constify struct dwarf_cie * argument.
        (get_fde_encoding, fde_unencoded_compare, fde_single_encoding_compare)
        (fde_mixed_encoding_compare, fde_compare_t, start_fde_sort, fde_insert)
        fde_split, SWAP, frame_downheap, frame_heapsort)
        (classify_object_over_fdes, add_fdes, linear_search_fdes,
        binary_search_unencoded_fdes, binary_search_single_encoding_fdes,
        binary_search_mixed_encoding_fdes, search_object, _Unwind_Find_FDE):
        Constify arguments, local variables, return values, and casts
        of type fde *, fde **, struct dwarf_fde *, and struct dwarf_cie *.
        Use const pointer types in sizeof expressions, for clarity.
        * unwind-dw2-fde-glibc.c
        (_Unwind_find_registered_FDE, _Unwind_find_FDE): Constify return value.
        (struct unw_eh_callback_data): Constify 'ret' field.

Co-Authored-By: Zack Weinberg <zack@codesourcery.com>

From-SVN: r73155
This commit is contained in:
Andreas Jaeger 2003-10-31 21:46:26 +01:00 committed by Andreas Jaeger
parent f3dd79b90f
commit a30794da51
5 changed files with 97 additions and 65 deletions

View File

@ -1,3 +1,35 @@
2003-10-31 Andreas Jaeger <aj@suse.de>,
Zack Weinberg <zack@codesourcery.com>
* crtstuff.c (__register_frame_info, __register_frame_info_bases)
(__deregister_frame_info, __deregister_frame_info_bases):
Constify void * argument.
* unwind-dw2-fde.h (struct fde_vector):
Constify 'orig_data' and 'array' fields.
(__register_frame_info, __register_frame_info_bases)
(__deregister_frame_info, __deregister_frame_info_bases):
Constify void * argument.
(get_cie, next_fde, _Unwind_Find_FDE): Constify arguments,
return values, and casts of type fde *, struct dwarf_fde *,
and struct dwarf_cie *.
* unwind-dw2-fde.c (__register_frame_info, __register_frame_info_bases)
(__deregister_frame_info, __deregister_frame_info_bases):
Constify void * argument.
(get_cie_encoding, ): Constify struct dwarf_cie * argument.
(get_fde_encoding, fde_unencoded_compare, fde_single_encoding_compare)
(fde_mixed_encoding_compare, fde_compare_t, start_fde_sort, fde_insert)
fde_split, SWAP, frame_downheap, frame_heapsort)
(classify_object_over_fdes, add_fdes, linear_search_fdes,
binary_search_unencoded_fdes, binary_search_single_encoding_fdes,
binary_search_mixed_encoding_fdes, search_object, _Unwind_Find_FDE):
Constify arguments, local variables, return values, and casts
of type fde *, fde **, struct dwarf_fde *, and struct dwarf_cie *.
Use const pointer types in sizeof expressions, for clarity.
* unwind-dw2-fde-glibc.c
(_Unwind_find_registered_FDE, _Unwind_find_FDE): Constify return value.
(struct unw_eh_callback_data): Constify 'ret' field.
2003-10-31 Fariborz Jahanian <fjahanian@apple.com>
David Edelsohn <edelsohn@gnu.org>

View File

@ -120,14 +120,14 @@ call_ ## FUNC (void) \
/* References to __register_frame_info and __deregister_frame_info should
be weak in this file if at all possible. */
extern void __register_frame_info (void *, struct object *)
extern void __register_frame_info (const void *, struct object *)
TARGET_ATTRIBUTE_WEAK;
extern void __register_frame_info_bases (void *, struct object *,
extern void __register_frame_info_bases (const void *, struct object *,
void *, void *)
TARGET_ATTRIBUTE_WEAK;
extern void *__deregister_frame_info (void *)
extern void *__deregister_frame_info (const void *)
TARGET_ATTRIBUTE_WEAK;
extern void *__deregister_frame_info_bases (void *)
extern void *__deregister_frame_info_bases (const void *)
TARGET_ATTRIBUTE_WEAK;
extern void __do_global_ctors_1 (void);

View File

@ -52,7 +52,7 @@
&& (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
static fde * _Unwind_Find_registered_FDE (void *pc, struct dwarf_eh_bases *bases);
static const fde * _Unwind_Find_registered_FDE (void *pc, struct dwarf_eh_bases *bases);
#define _Unwind_Find_FDE _Unwind_Find_registered_FDE
#include "unwind-dw2-fde.c"
@ -68,7 +68,7 @@ struct unw_eh_callback_data
void *tbase;
void *dbase;
void *func;
fde *ret;
const fde *ret;
};
struct unw_eh_frame_hdr
@ -261,11 +261,11 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
return 1;
}
fde *
const fde *
_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
{
struct unw_eh_callback_data data;
fde *ret;
const fde *ret;
ret = _Unwind_Find_registered_FDE (pc, bases);
if (ret != NULL)

View File

@ -1,5 +1,5 @@
/* Subroutines needed for unwinding stack frames for exception handling. */
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@cygnus.com>.
This file is part of GCC.
@ -74,7 +74,7 @@ init_object_mutex_once (void)
/* Called from crtbegin.o to register the unwind info for an object. */
void
__register_frame_info_bases (void *begin, struct object *ob,
__register_frame_info_bases (const void *begin, struct object *ob,
void *tbase, void *dbase)
{
/* If .eh_frame is empty, don't register at all. */
@ -101,7 +101,7 @@ __register_frame_info_bases (void *begin, struct object *ob,
}
void
__register_frame_info (void *begin, struct object *ob)
__register_frame_info (const void *begin, struct object *ob)
{
__register_frame_info_bases (begin, ob, 0, 0);
}
@ -170,7 +170,7 @@ __register_frame_table (void *begin)
implements __register_frame_info_bases. */
void *
__deregister_frame_info_bases (void *begin)
__deregister_frame_info_bases (const void *begin)
{
struct object **p;
struct object *ob = 0;
@ -220,7 +220,7 @@ __deregister_frame_info_bases (void *begin)
}
void *
__deregister_frame_info (void *begin)
__deregister_frame_info (const void *begin)
{
return __deregister_frame_info_bases (begin);
}
@ -262,7 +262,7 @@ base_from_object (unsigned char encoding, struct object *ob)
/* ??? This is a subset of extract_cie_info from unwind-dw2.c. */
static int
get_cie_encoding (struct dwarf_cie *cie)
get_cie_encoding (const struct dwarf_cie *cie)
{
const unsigned char *aug, *p;
_Unwind_Ptr dummy;
@ -304,7 +304,7 @@ get_cie_encoding (struct dwarf_cie *cie)
}
static inline int
get_fde_encoding (struct dwarf_fde *f)
get_fde_encoding (const struct dwarf_fde *f)
{
return get_cie_encoding (get_cie (f));
}
@ -318,7 +318,7 @@ get_fde_encoding (struct dwarf_fde *f)
static int
fde_unencoded_compare (struct object *ob __attribute__((unused)),
fde *x, fde *y)
const fde *x, const fde *y)
{
_Unwind_Ptr x_ptr = *(_Unwind_Ptr *) x->pc_begin;
_Unwind_Ptr y_ptr = *(_Unwind_Ptr *) y->pc_begin;
@ -331,7 +331,7 @@ fde_unencoded_compare (struct object *ob __attribute__((unused)),
}
static int
fde_single_encoding_compare (struct object *ob, fde *x, fde *y)
fde_single_encoding_compare (struct object *ob, const fde *x, const fde *y)
{
_Unwind_Ptr base, x_ptr, y_ptr;
@ -347,7 +347,7 @@ fde_single_encoding_compare (struct object *ob, fde *x, fde *y)
}
static int
fde_mixed_encoding_compare (struct object *ob, fde *x, fde *y)
fde_mixed_encoding_compare (struct object *ob, const fde *x, const fde *y)
{
int x_encoding, y_encoding;
_Unwind_Ptr x_ptr, y_ptr;
@ -367,7 +367,7 @@ fde_mixed_encoding_compare (struct object *ob, fde *x, fde *y)
return 0;
}
typedef int (*fde_compare_t) (struct object *, fde *, fde *);
typedef int (*fde_compare_t) (struct object *, const fde *, const fde *);
/* This is a special mix of insertion sort and heap sort, optimized for
@ -394,7 +394,7 @@ start_fde_sort (struct fde_accumulator *accu, size_t count)
if (! count)
return 0;
size = sizeof (struct fde_vector) + sizeof (fde *) * count;
size = sizeof (struct fde_vector) + sizeof (const fde *) * count;
if ((accu->linear = malloc (size)))
{
accu->linear->count = 0;
@ -407,7 +407,7 @@ start_fde_sort (struct fde_accumulator *accu, size_t count)
}
static inline void
fde_insert (struct fde_accumulator *accu, fde *this_fde)
fde_insert (struct fde_accumulator *accu, const fde *this_fde)
{
if (accu->linear)
accu->linear->array[accu->linear->count++] = this_fde;
@ -429,29 +429,29 @@ static inline void
fde_split (struct object *ob, fde_compare_t fde_compare,
struct fde_vector *linear, struct fde_vector *erratic)
{
static fde *marker;
static const fde *marker;
size_t count = linear->count;
fde **chain_end = &marker;
const fde **chain_end = &marker;
size_t i, j, k;
/* This should optimize out, but it is wise to make sure this assumption
is correct. Should these have different sizes, we cannot cast between
them and the overlaying onto ERRATIC will not work. */
if (sizeof (fde *) != sizeof (fde **))
if (sizeof (const fde *) != sizeof (const fde **))
abort ();
for (i = 0; i < count; i++)
{
fde **probe;
const fde **probe;
for (probe = chain_end;
probe != &marker && fde_compare (ob, linear->array[i], *probe) < 0;
probe = chain_end)
{
chain_end = (fde **) erratic->array[probe - linear->array];
chain_end = (const fde **) erratic->array[probe - linear->array];
erratic->array[probe - linear->array] = NULL;
}
erratic->array[i] = (fde *) chain_end;
erratic->array[i] = (const fde *) chain_end;
chain_end = &linear->array[i];
}
@ -467,13 +467,13 @@ fde_split (struct object *ob, fde_compare_t fde_compare,
erratic->count = k;
}
#define SWAP(x,y) do { fde * tmp = x; x = y; y = tmp; } while (0)
#define SWAP(x,y) do { const fde * tmp = x; x = y; y = tmp; } while (0)
/* Convert a semi-heap to a heap. A semi-heap is a heap except possibly
for the first (root) node; push it down to its rightful place. */
static void
frame_downheap (struct object *ob, fde_compare_t fde_compare, fde **a,
frame_downheap (struct object *ob, fde_compare_t fde_compare, const fde **a,
int lo, int hi)
{
int i, j;
@ -505,7 +505,7 @@ frame_heapsort (struct object *ob, fde_compare_t fde_compare,
/* For a description of this algorithm, see:
Samuel P. Harbison, Guy L. Steele Jr.: C, a reference manual, 2nd ed.,
p. 60-61. */
fde ** a = erratic->array;
const fde ** a = erratic->array;
/* A portion of the array is called a "heap" if for all i>=0:
If i and 2i+1 are valid indices, then a[i] >= a[2i+1].
If i and 2i+2 are valid indices, then a[i] >= a[2i+2]. */
@ -535,7 +535,7 @@ fde_merge (struct object *ob, fde_compare_t fde_compare,
struct fde_vector *v1, struct fde_vector *v2)
{
size_t i1, i2;
fde * fde2;
const fde * fde2;
i2 = v2->count;
if (i2 > 0)
@ -595,16 +595,16 @@ end_fde_sort (struct object *ob, struct fde_accumulator *accu, size_t count)
encountered along the way. */
static size_t
classify_object_over_fdes (struct object *ob, fde *this_fde)
classify_object_over_fdes (struct object *ob, const fde *this_fde)
{
struct dwarf_cie *last_cie = 0;
const struct dwarf_cie *last_cie = 0;
size_t count = 0;
int encoding = DW_EH_PE_absptr;
_Unwind_Ptr base = 0;
for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
{
struct dwarf_cie *this_cie;
const struct dwarf_cie *this_cie;
_Unwind_Ptr mask, pc_begin;
/* Skip CIEs. */
@ -650,15 +650,15 @@ classify_object_over_fdes (struct object *ob, fde *this_fde)
}
static void
add_fdes (struct object *ob, struct fde_accumulator *accu, fde *this_fde)
add_fdes (struct object *ob, struct fde_accumulator *accu, const fde *this_fde)
{
struct dwarf_cie *last_cie = 0;
const struct dwarf_cie *last_cie = 0;
int encoding = ob->s.b.encoding;
_Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
{
struct dwarf_cie *this_cie;
const struct dwarf_cie *this_cie;
/* Skip CIEs. */
if (this_fde->CIE_delta == 0)
@ -766,16 +766,16 @@ init_object (struct object* ob)
used when there was insufficient memory to allocate and sort an
array. */
static fde *
linear_search_fdes (struct object *ob, fde *this_fde, void *pc)
static const fde *
linear_search_fdes (struct object *ob, const fde *this_fde, void *pc)
{
struct dwarf_cie *last_cie = 0;
const struct dwarf_cie *last_cie = 0;
int encoding = ob->s.b.encoding;
_Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
{
struct dwarf_cie *this_cie;
const struct dwarf_cie *this_cie;
_Unwind_Ptr pc_begin, pc_range;
/* Skip CIEs. */
@ -835,7 +835,7 @@ linear_search_fdes (struct object *ob, fde *this_fde, void *pc)
/* Binary search for an FDE containing the given PC. Here are three
implementations of increasing complexity. */
static inline fde *
static inline const fde *
binary_search_unencoded_fdes (struct object *ob, void *pc)
{
struct fde_vector *vec = ob->u.sort;
@ -844,7 +844,7 @@ binary_search_unencoded_fdes (struct object *ob, void *pc)
for (lo = 0, hi = vec->count; lo < hi; )
{
size_t i = (lo + hi) / 2;
fde *f = vec->array[i];
const fde *f = vec->array[i];
void *pc_begin;
uaddr pc_range;
@ -862,7 +862,7 @@ binary_search_unencoded_fdes (struct object *ob, void *pc)
return NULL;
}
static inline fde *
static inline const fde *
binary_search_single_encoding_fdes (struct object *ob, void *pc)
{
struct fde_vector *vec = ob->u.sort;
@ -873,7 +873,7 @@ binary_search_single_encoding_fdes (struct object *ob, void *pc)
for (lo = 0, hi = vec->count; lo < hi; )
{
size_t i = (lo + hi) / 2;
fde *f = vec->array[i];
const fde *f = vec->array[i];
_Unwind_Ptr pc_begin, pc_range;
const char *p;
@ -892,7 +892,7 @@ binary_search_single_encoding_fdes (struct object *ob, void *pc)
return NULL;
}
static inline fde *
static inline const fde *
binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
{
struct fde_vector *vec = ob->u.sort;
@ -901,7 +901,7 @@ binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
for (lo = 0, hi = vec->count; lo < hi; )
{
size_t i = (lo + hi) / 2;
fde *f = vec->array[i];
const fde *f = vec->array[i];
_Unwind_Ptr pc_begin, pc_range;
const char *p;
int encoding;
@ -923,7 +923,7 @@ binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
return NULL;
}
static fde *
static const fde *
search_object (struct object* ob, void *pc)
{
/* If the data hasn't been sorted, try to do this now. We may have
@ -956,7 +956,7 @@ search_object (struct object* ob, void *pc)
fde **p;
for (p = ob->u.array; *p ; p++)
{
fde *f = linear_search_fdes (ob, *p, pc);
const fde *f = linear_search_fdes (ob, *p, pc);
if (f)
return f;
}
@ -967,11 +967,11 @@ search_object (struct object* ob, void *pc)
}
}
fde *
const fde *
_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
{
struct object *ob;
fde *f = NULL;
const fde *f = NULL;
init_object_mutex_once ();
__gthread_mutex_lock (&object_mutex);

View File

@ -32,9 +32,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
struct fde_vector
{
void *orig_data;
const void *orig_data;
size_t count;
struct dwarf_fde *array[];
const struct dwarf_fde *array[];
};
struct object
@ -43,7 +43,7 @@ struct object
void *tbase;
void *dbase;
union {
struct dwarf_fde *single;
const struct dwarf_fde *single;
struct dwarf_fde **array;
struct fde_vector *sort;
} u;
@ -90,16 +90,16 @@ struct dwarf_eh_bases
};
extern void __register_frame_info_bases (void *, struct object *,
extern void __register_frame_info_bases (const void *, struct object *,
void *, void *);
extern void __register_frame_info (void *, struct object *);
extern void __register_frame_info (const void *, struct object *);
extern void __register_frame (void *);
extern void __register_frame_info_table_bases (void *, struct object *,
void *, void *);
extern void __register_frame_info_table (void *, struct object *);
extern void __register_frame_table (void *);
extern void *__deregister_frame_info (void *);
extern void *__deregister_frame_info_bases (void *);
extern void *__deregister_frame_info (const void *);
extern void *__deregister_frame_info_bases (const void *);
extern void __deregister_frame (void *);
@ -151,22 +151,22 @@ typedef struct dwarf_fde fde;
/* Locate the CIE for a given FDE. */
static inline struct dwarf_cie *
get_cie (struct dwarf_fde *f)
static inline const struct dwarf_cie *
get_cie (const struct dwarf_fde *f)
{
return (void *)&f->CIE_delta - f->CIE_delta;
}
static inline fde *
next_fde (fde *f)
static inline const fde *
next_fde (const fde *f)
{
return (fde *) ((char *) f + f->length + sizeof (f->length));
return (const fde *) ((char *) f + f->length + sizeof (f->length));
}
extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
static inline int
last_fde (struct object *obj __attribute__ ((__unused__)), fde *f)
last_fde (struct object *obj __attribute__ ((__unused__)), const fde *f)
{
#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
return (char *)f == obj->fde_end || f->length == 0;