Commit 20c1dc5e by Andreas Jaeger Committed by Andreas Jaeger

ggc.h: Convert to ISO C90 prototypes.

	* ggc.h: Convert to ISO C90 prototypes.
	* ggc-none.c: Likewise.
	* ggc-common.c: Likewise.
	* ggc-page.c: Likewise.
	* ggc-simple.c: Likewise.

From-SVN: r67596
parent 60e9f0d7
2003-06-07 Andreas Jaeger <aj@suse.de> 2003-06-07 Andreas Jaeger <aj@suse.de>
* ggc.h: Convert to ISO C90 prototypes.
* ggc-none.c: Likewise.
* ggc-common.c: Likewise.
* ggc-page.c: Likewise.
* ggc-simple.c: Likewise.
* crtstuff.c: Remove undefined usage of INIT_SECTION_PREAMBLE. * crtstuff.c: Remove undefined usage of INIT_SECTION_PREAMBLE.
* system.h: Poison INIT_SECTION_PREAMBLE. * system.h: Poison INIT_SECTION_PREAMBLE.
......
...@@ -54,25 +54,23 @@ static ggc_statistics *ggc_stats; ...@@ -54,25 +54,23 @@ static ggc_statistics *ggc_stats;
struct traversal_state; struct traversal_state;
static int ggc_htab_delete PARAMS ((void **, void *)); static int ggc_htab_delete (void **, void *);
static hashval_t saving_htab_hash PARAMS ((const PTR)); static hashval_t saving_htab_hash (const void *);
static int saving_htab_eq PARAMS ((const PTR, const PTR)); static int saving_htab_eq (const void *, const void *);
static int call_count PARAMS ((void **, void *)); static int call_count (void **, void *);
static int call_alloc PARAMS ((void **, void *)); static int call_alloc (void **, void *);
static int compare_ptr_data PARAMS ((const void *, const void *)); static int compare_ptr_data (const void *, const void *);
static void relocate_ptrs PARAMS ((void *, void *)); static void relocate_ptrs (void *, void *);
static void write_pch_globals PARAMS ((const struct ggc_root_tab * const *tab, static void write_pch_globals (const struct ggc_root_tab * const *tab,
struct traversal_state *state)); struct traversal_state *state);
static double ggc_rlimit_bound PARAMS ((double)); static double ggc_rlimit_bound (double);
/* Maintain global roots that are preserved during GC. */ /* Maintain global roots that are preserved during GC. */
/* Process a slot of an htab by deleting it if it has not been marked. */ /* Process a slot of an htab by deleting it if it has not been marked. */
static int static int
ggc_htab_delete (slot, info) ggc_htab_delete (void **slot, void *info)
void **slot;
void *info;
{ {
const struct ggc_cache_tab *r = (const struct ggc_cache_tab *) info; const struct ggc_cache_tab *r = (const struct ggc_cache_tab *) info;
...@@ -87,7 +85,7 @@ ggc_htab_delete (slot, info) ...@@ -87,7 +85,7 @@ ggc_htab_delete (slot, info)
/* Iterate through all registered roots and mark each element. */ /* Iterate through all registered roots and mark each element. */
void void
ggc_mark_roots () ggc_mark_roots (void)
{ {
const struct ggc_root_tab *const *rt; const struct ggc_root_tab *const *rt;
const struct ggc_root_tab *rti; const struct ggc_root_tab *rti;
...@@ -113,15 +111,14 @@ ggc_mark_roots () ...@@ -113,15 +111,14 @@ ggc_mark_roots ()
if (*cti->base) if (*cti->base)
{ {
ggc_set_mark (*cti->base); ggc_set_mark (*cti->base);
htab_traverse_noresize (*cti->base, ggc_htab_delete, (PTR) cti); htab_traverse_noresize (*cti->base, ggc_htab_delete, (void *) cti);
ggc_set_mark ((*cti->base)->entries); ggc_set_mark ((*cti->base)->entries);
} }
} }
/* Allocate a block of memory, then clear it. */ /* Allocate a block of memory, then clear it. */
void * void *
ggc_alloc_cleared (size) ggc_alloc_cleared (size_t size)
size_t size;
{ {
void *buf = ggc_alloc (size); void *buf = ggc_alloc (size);
memset (buf, 0, size); memset (buf, 0, size);
...@@ -130,9 +127,7 @@ ggc_alloc_cleared (size) ...@@ -130,9 +127,7 @@ ggc_alloc_cleared (size)
/* Resize a block of memory, possibly re-allocating it. */ /* Resize a block of memory, possibly re-allocating it. */
void * void *
ggc_realloc (x, size) ggc_realloc (void *x, size_t size)
void *x;
size_t size;
{ {
void *r; void *r;
size_t old_size; size_t old_size;
...@@ -177,17 +172,14 @@ ggc_realloc (x, size) ...@@ -177,17 +172,14 @@ ggc_realloc (x, size)
/* Like ggc_alloc_cleared, but performs a multiplication. */ /* Like ggc_alloc_cleared, but performs a multiplication. */
void * void *
ggc_calloc (s1, s2) ggc_calloc (size_t s1, size_t s2)
size_t s1, s2;
{ {
return ggc_alloc_cleared (s1 * s2); return ggc_alloc_cleared (s1 * s2);
} }
/* These are for splay_tree_new_ggc. */ /* These are for splay_tree_new_ggc. */
PTR void *
ggc_splay_alloc (sz, nl) ggc_splay_alloc (int sz, void *nl)
int sz;
PTR nl;
{ {
if (nl != NULL) if (nl != NULL)
abort (); abort ();
...@@ -195,9 +187,7 @@ ggc_splay_alloc (sz, nl) ...@@ -195,9 +187,7 @@ ggc_splay_alloc (sz, nl)
} }
void void
ggc_splay_dont_free (x, nl) ggc_splay_dont_free (void * x ATTRIBUTE_UNUSED, void *nl)
PTR x ATTRIBUTE_UNUSED;
PTR nl;
{ {
if (nl != NULL) if (nl != NULL)
abort (); abort ();
...@@ -212,9 +202,8 @@ ggc_splay_dont_free (x, nl) ...@@ -212,9 +202,8 @@ ggc_splay_dont_free (x, nl)
#define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M')) #define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M'))
void void
ggc_print_common_statistics (stream, stats) ggc_print_common_statistics (FILE *stream ATTRIBUTE_UNUSED,
FILE *stream ATTRIBUTE_UNUSED; ggc_statistics *stats)
ggc_statistics *stats;
{ {
/* Set the pointer so that during collection we will actually gather /* Set the pointer so that during collection we will actually gather
the statistics. */ the statistics. */
...@@ -248,10 +237,8 @@ struct ptr_data ...@@ -248,10 +237,8 @@ struct ptr_data
/* Register an object in the hash table. */ /* Register an object in the hash table. */
int int
gt_pch_note_object (obj, note_ptr_cookie, note_ptr_fn) gt_pch_note_object (void *obj, void *note_ptr_cookie,
void *obj; gt_note_pointers note_ptr_fn)
void *note_ptr_cookie;
gt_note_pointers note_ptr_fn;
{ {
struct ptr_data **slot; struct ptr_data **slot;
...@@ -283,10 +270,8 @@ gt_pch_note_object (obj, note_ptr_cookie, note_ptr_fn) ...@@ -283,10 +270,8 @@ gt_pch_note_object (obj, note_ptr_cookie, note_ptr_fn)
/* Register an object in the hash table. */ /* Register an object in the hash table. */
void void
gt_pch_note_reorder (obj, note_ptr_cookie, reorder_fn) gt_pch_note_reorder (void *obj, void *note_ptr_cookie,
void *obj; gt_handle_reorder reorder_fn)
void *note_ptr_cookie;
gt_handle_reorder reorder_fn;
{ {
struct ptr_data *data; struct ptr_data *data;
...@@ -304,16 +289,13 @@ gt_pch_note_reorder (obj, note_ptr_cookie, reorder_fn) ...@@ -304,16 +289,13 @@ gt_pch_note_reorder (obj, note_ptr_cookie, reorder_fn)
/* Hash and equality functions for saving_htab, callbacks for htab_create. */ /* Hash and equality functions for saving_htab, callbacks for htab_create. */
static hashval_t static hashval_t
saving_htab_hash (p) saving_htab_hash (const void *p)
const PTR p;
{ {
return POINTER_HASH (((struct ptr_data *)p)->obj); return POINTER_HASH (((struct ptr_data *)p)->obj);
} }
static int static int
saving_htab_eq (p1, p2) saving_htab_eq (const void *p1, const void *p2)
const PTR p1;
const PTR p2;
{ {
return ((struct ptr_data *)p1)->obj == p2; return ((struct ptr_data *)p1)->obj == p2;
} }
...@@ -332,9 +314,7 @@ struct traversal_state ...@@ -332,9 +314,7 @@ struct traversal_state
/* Callbacks for htab_traverse. */ /* Callbacks for htab_traverse. */
static int static int
call_count (slot, state_p) call_count (void **slot, void *state_p)
void **slot;
void *state_p;
{ {
struct ptr_data *d = (struct ptr_data *)*slot; struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p; struct traversal_state *state = (struct traversal_state *)state_p;
...@@ -345,9 +325,7 @@ call_count (slot, state_p) ...@@ -345,9 +325,7 @@ call_count (slot, state_p)
} }
static int static int
call_alloc (slot, state_p) call_alloc (void **slot, void *state_p)
void **slot;
void *state_p;
{ {
struct ptr_data *d = (struct ptr_data *)*slot; struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p; struct traversal_state *state = (struct traversal_state *)state_p;
...@@ -360,9 +338,7 @@ call_alloc (slot, state_p) ...@@ -360,9 +338,7 @@ call_alloc (slot, state_p)
/* Callback for qsort. */ /* Callback for qsort. */
static int static int
compare_ptr_data (p1_p, p2_p) compare_ptr_data (const void *p1_p, const void *p2_p)
const void *p1_p;
const void *p2_p;
{ {
struct ptr_data *p1 = *(struct ptr_data *const *)p1_p; struct ptr_data *p1 = *(struct ptr_data *const *)p1_p;
struct ptr_data *p2 = *(struct ptr_data *const *)p2_p; struct ptr_data *p2 = *(struct ptr_data *const *)p2_p;
...@@ -373,9 +349,7 @@ compare_ptr_data (p1_p, p2_p) ...@@ -373,9 +349,7 @@ compare_ptr_data (p1_p, p2_p)
/* Callbacks for note_ptr_fn. */ /* Callbacks for note_ptr_fn. */
static void static void
relocate_ptrs (ptr_p, state_p) relocate_ptrs (void *ptr_p, void *state_p)
void *ptr_p;
void *state_p;
{ {
void **ptr = (void **)ptr_p; void **ptr = (void **)ptr_p;
struct traversal_state *state ATTRIBUTE_UNUSED struct traversal_state *state ATTRIBUTE_UNUSED
...@@ -393,9 +367,8 @@ relocate_ptrs (ptr_p, state_p) ...@@ -393,9 +367,8 @@ relocate_ptrs (ptr_p, state_p)
/* Write out, after relocation, the pointers in TAB. */ /* Write out, after relocation, the pointers in TAB. */
static void static void
write_pch_globals (tab, state) write_pch_globals (const struct ggc_root_tab * const *tab,
const struct ggc_root_tab * const *tab; struct traversal_state *state)
struct traversal_state *state;
{ {
const struct ggc_root_tab *const *rt; const struct ggc_root_tab *const *rt;
const struct ggc_root_tab *rti; const struct ggc_root_tab *rti;
...@@ -436,8 +409,7 @@ struct mmap_info ...@@ -436,8 +409,7 @@ struct mmap_info
/* Write out the state of the compiler to F. */ /* Write out the state of the compiler to F. */
void void
gt_pch_save (f) gt_pch_save (FILE *f)
FILE *f;
{ {
const struct ggc_root_tab *const *rt; const struct ggc_root_tab *const *rt;
const struct ggc_root_tab *rti; const struct ggc_root_tab *rti;
...@@ -552,8 +524,7 @@ gt_pch_save (f) ...@@ -552,8 +524,7 @@ gt_pch_save (f)
/* Read the state of the compiler back in from F. */ /* Read the state of the compiler back in from F. */
void void
gt_pch_restore (f) gt_pch_restore (FILE *f)
FILE *f;
{ {
const struct ggc_root_tab *const *rt; const struct ggc_root_tab *const *rt;
const struct ggc_root_tab *rti; const struct ggc_root_tab *rti;
...@@ -639,8 +610,7 @@ gt_pch_restore (f) ...@@ -639,8 +610,7 @@ gt_pch_restore (f)
/* Modify the bound based on rlimits. Keep the smallest number found. */ /* Modify the bound based on rlimits. Keep the smallest number found. */
static double static double
ggc_rlimit_bound (limit) ggc_rlimit_bound (double limit)
double limit;
{ {
#if defined(HAVE_GETRLIMIT) #if defined(HAVE_GETRLIMIT)
struct rlimit rlim; struct rlimit rlim;
...@@ -669,7 +639,7 @@ ggc_rlimit_bound (limit) ...@@ -669,7 +639,7 @@ ggc_rlimit_bound (limit)
/* Heuristic to set a default for GGC_MIN_EXPAND. */ /* Heuristic to set a default for GGC_MIN_EXPAND. */
int int
ggc_min_expand_heuristic() ggc_min_expand_heuristic (void)
{ {
double min_expand = physmem_total(); double min_expand = physmem_total();
...@@ -688,7 +658,7 @@ ggc_min_expand_heuristic() ...@@ -688,7 +658,7 @@ ggc_min_expand_heuristic()
/* Heuristic to set a default for GGC_MIN_HEAPSIZE. */ /* Heuristic to set a default for GGC_MIN_HEAPSIZE. */
int int
ggc_min_heapsize_heuristic() ggc_min_heapsize_heuristic (void)
{ {
double min_heap_kbytes = physmem_total(); double min_heap_kbytes = physmem_total();
...@@ -707,7 +677,7 @@ ggc_min_heapsize_heuristic() ...@@ -707,7 +677,7 @@ ggc_min_heapsize_heuristic()
} }
void void
init_ggc_heuristics () init_ggc_heuristics (void)
{ {
#ifndef ENABLE_GC_ALWAYS_COLLECT #ifndef ENABLE_GC_ALWAYS_COLLECT
set_param_value ("ggc-min-expand", ggc_min_expand_heuristic()); set_param_value ("ggc-min-expand", ggc_min_expand_heuristic());
......
/* Null garbage collection for the GNU compiler. /* Null garbage collection for the GNU compiler.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2003
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -29,23 +30,19 @@ ...@@ -29,23 +30,19 @@
#include "ggc.h" #include "ggc.h"
void * void *
ggc_alloc (size) ggc_alloc (size_t size)
size_t size;
{ {
return xmalloc (size); return xmalloc (size);
} }
void * void *
ggc_alloc_cleared (size) ggc_alloc_cleared (size_t size)
size_t size;
{ {
return xcalloc (size, 1); return xcalloc (size, 1);
} }
void * void *
ggc_realloc (x, size) ggc_realloc (void *x, size_t size)
void *x;
size_t size;
{ {
return xrealloc (x, size); return xrealloc (x, size);
} }
/* Simple garbage collection for the GNU compiler. /* Simple garbage collection for the GNU compiler.
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -113,25 +114,24 @@ static struct globals ...@@ -113,25 +114,24 @@ static struct globals
/* Local function prototypes. */ /* Local function prototypes. */
static void tree_insert PARAMS ((struct ggc_mem *)); static void tree_insert (struct ggc_mem *);
static int tree_lookup PARAMS ((struct ggc_mem *)); static int tree_lookup (struct ggc_mem *);
static void clear_marks PARAMS ((struct ggc_mem *)); static void clear_marks (struct ggc_mem *);
static void sweep_objs PARAMS ((struct ggc_mem **)); static void sweep_objs (struct ggc_mem **);
static void ggc_pop_context_1 PARAMS ((struct ggc_mem *, int)); static void ggc_pop_context_1 (struct ggc_mem *, int);
/* For use from debugger. */ /* For use from debugger. */
extern void debug_ggc_tree PARAMS ((struct ggc_mem *, int)); extern void debug_ggc_tree (struct ggc_mem *, int);
#ifdef GGC_BALANCE #ifdef GGC_BALANCE
extern void debug_ggc_balance PARAMS ((void)); extern void debug_ggc_balance (void);
#endif #endif
static void tally_leaves PARAMS ((struct ggc_mem *, int, size_t *, size_t *)); static void tally_leaves (struct ggc_mem *, int, size_t *, size_t *);
/* Insert V into the search tree. */ /* Insert V into the search tree. */
static inline void static inline void
tree_insert (v) tree_insert (struct ggc_mem *v)
struct ggc_mem *v;
{ {
size_t v_key = PTR_KEY (v); size_t v_key = PTR_KEY (v);
struct ggc_mem *p, **pp; struct ggc_mem *p, **pp;
...@@ -147,8 +147,7 @@ tree_insert (v) ...@@ -147,8 +147,7 @@ tree_insert (v)
/* Return true if V is in the tree. */ /* Return true if V is in the tree. */
static inline int static inline int
tree_lookup (v) tree_lookup (struct ggc_mem *v)
struct ggc_mem *v;
{ {
size_t v_key = PTR_KEY (v); size_t v_key = PTR_KEY (v);
struct ggc_mem *p = G.root; struct ggc_mem *p = G.root;
...@@ -167,8 +166,7 @@ tree_lookup (v) ...@@ -167,8 +166,7 @@ tree_lookup (v)
/* Alloc SIZE bytes of GC'able memory. If ZERO, clear the memory. */ /* Alloc SIZE bytes of GC'able memory. If ZERO, clear the memory. */
void * void *
ggc_alloc (size) ggc_alloc (size_t size)
size_t size;
{ {
struct ggc_mem *x; struct ggc_mem *x;
...@@ -193,8 +191,7 @@ ggc_alloc (size) ...@@ -193,8 +191,7 @@ ggc_alloc (size)
/* Mark a node. */ /* Mark a node. */
int int
ggc_set_mark (p) ggc_set_mark (const void *p)
const void *p;
{ {
struct ggc_mem *x; struct ggc_mem *x;
...@@ -217,8 +214,7 @@ ggc_set_mark (p) ...@@ -217,8 +214,7 @@ ggc_set_mark (p)
/* Return 1 if P has been marked, zero otherwise. */ /* Return 1 if P has been marked, zero otherwise. */
int int
ggc_marked_p (p) ggc_marked_p (const void *p)
const void *p;
{ {
struct ggc_mem *x; struct ggc_mem *x;
...@@ -234,8 +230,7 @@ ggc_marked_p (p) ...@@ -234,8 +230,7 @@ ggc_marked_p (p)
/* Return the size of the gc-able object P. */ /* Return the size of the gc-able object P. */
size_t size_t
ggc_get_size (p) ggc_get_size (const void *p)
const void *p;
{ {
struct ggc_mem *x struct ggc_mem *x
= (struct ggc_mem *) ((const char *)p - offsetof (struct ggc_mem, u)); = (struct ggc_mem *) ((const char *)p - offsetof (struct ggc_mem, u));
...@@ -245,8 +240,7 @@ ggc_get_size (p) ...@@ -245,8 +240,7 @@ ggc_get_size (p)
/* Unmark all objects. */ /* Unmark all objects. */
static void static void
clear_marks (x) clear_marks (struct ggc_mem *x)
struct ggc_mem *x;
{ {
x->mark = 0; x->mark = 0;
if (x->sub[0]) if (x->sub[0])
...@@ -258,8 +252,7 @@ clear_marks (x) ...@@ -258,8 +252,7 @@ clear_marks (x)
/* Free all objects in the current context that are not marked. */ /* Free all objects in the current context that are not marked. */
static void static void
sweep_objs (root) sweep_objs (struct ggc_mem **root)
struct ggc_mem **root;
{ {
struct ggc_mem *x = *root; struct ggc_mem *x = *root;
if (!x) if (!x)
...@@ -308,7 +301,7 @@ sweep_objs (root) ...@@ -308,7 +301,7 @@ sweep_objs (root)
/* The top level mark-and-sweep routine. */ /* The top level mark-and-sweep routine. */
void void
ggc_collect () ggc_collect (void)
{ {
/* Avoid frequent unnecessary work by skipping collection if the /* Avoid frequent unnecessary work by skipping collection if the
total allocations haven't expanded much since the last total allocations haven't expanded much since the last
...@@ -351,7 +344,7 @@ ggc_collect () ...@@ -351,7 +344,7 @@ ggc_collect ()
/* Called once to initialize the garbage collector. */ /* Called once to initialize the garbage collector. */
void void
init_ggc () init_ggc (void)
{ {
} }
...@@ -359,7 +352,7 @@ init_ggc () ...@@ -359,7 +352,7 @@ init_ggc ()
will not be collected while the new context is active. */ will not be collected while the new context is active. */
void void
ggc_push_context () ggc_push_context (void)
{ {
G.context++; G.context++;
...@@ -373,7 +366,7 @@ ggc_push_context () ...@@ -373,7 +366,7 @@ ggc_push_context ()
will be merged with the old context. */ will be merged with the old context. */
void void
ggc_pop_context () ggc_pop_context (void)
{ {
G.context--; G.context--;
if (G.root) if (G.root)
...@@ -381,9 +374,7 @@ ggc_pop_context () ...@@ -381,9 +374,7 @@ ggc_pop_context ()
} }
static void static void
ggc_pop_context_1 (x, c) ggc_pop_context_1 (struct ggc_mem *x, int c)
struct ggc_mem *x;
int c;
{ {
if (x->context > c) if (x->context > c)
x->context = c; x->context = c;
...@@ -396,9 +387,7 @@ ggc_pop_context_1 (x, c) ...@@ -396,9 +387,7 @@ ggc_pop_context_1 (x, c)
/* Dump a tree. */ /* Dump a tree. */
void void
debug_ggc_tree (p, indent) debug_ggc_tree (struct ggc_mem *p, int indent)
struct ggc_mem *p;
int indent;
{ {
int i; int i;
...@@ -413,7 +402,7 @@ debug_ggc_tree (p, indent) ...@@ -413,7 +402,7 @@ debug_ggc_tree (p, indent)
for (i = 0; i < indent; ++i) for (i = 0; i < indent; ++i)
putc (' ', stderr); putc (' ', stderr);
fprintf (stderr, "%lx %p\n", (unsigned long)PTR_KEY (p), (PTR) p); fprintf (stderr, "%lx %p\n", (unsigned long)PTR_KEY (p), (void *) p);
if (p->sub[1]) if (p->sub[1])
debug_ggc_tree (p->sub[1], indent + 1); debug_ggc_tree (p->sub[1], indent + 1);
...@@ -425,7 +414,7 @@ debug_ggc_tree (p, indent) ...@@ -425,7 +414,7 @@ debug_ggc_tree (p, indent)
#include <math.h> #include <math.h>
void void
debug_ggc_balance () debug_ggc_balance (void)
{ {
size_t nleaf, sumdepth; size_t nleaf, sumdepth;
...@@ -443,11 +432,7 @@ debug_ggc_balance () ...@@ -443,11 +432,7 @@ debug_ggc_balance ()
/* Used by debug_ggc_balance, and also by ggc_print_statistics. */ /* Used by debug_ggc_balance, and also by ggc_print_statistics. */
static void static void
tally_leaves (x, depth, nleaf, sumdepth) tally_leaves (struct ggc_mem *x, int depth, size_t *nleaf, size_t *sumdepth)
struct ggc_mem *x;
int depth;
size_t *nleaf;
size_t *sumdepth;
{ {
if (! x->sub[0] && !x->sub[1]) if (! x->sub[0] && !x->sub[1])
{ {
...@@ -472,7 +457,7 @@ tally_leaves (x, depth, nleaf, sumdepth) ...@@ -472,7 +457,7 @@ tally_leaves (x, depth, nleaf, sumdepth)
/* Report on GC memory usage. */ /* Report on GC memory usage. */
void void
ggc_print_statistics () ggc_print_statistics (void)
{ {
struct ggc_statistics stats; struct ggc_statistics stats;
size_t nleaf = 0, sumdepth = 0; size_t nleaf = 0, sumdepth = 0;
...@@ -506,7 +491,7 @@ Total memory in GC arena\t%ld%c\n", ...@@ -506,7 +491,7 @@ Total memory in GC arena\t%ld%c\n",
} }
struct ggc_pch_data * struct ggc_pch_data *
init_ggc_pch () init_ggc_pch (void)
{ {
sorry ("Generating PCH files is not supported when using ggc-simple.c"); sorry ("Generating PCH files is not supported when using ggc-simple.c");
/* It could be supported, but the code is not yet written. */ /* It could be supported, but the code is not yet written. */
...@@ -514,65 +499,55 @@ init_ggc_pch () ...@@ -514,65 +499,55 @@ init_ggc_pch ()
} }
void void
ggc_pch_count_object (d, x, size) ggc_pch_count_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data *d ATTRIBUTE_UNUSED; void *x ATTRIBUTE_UNUSED,
void *x ATTRIBUTE_UNUSED; size_t size ATTRIBUTE_UNUSED)
size_t size ATTRIBUTE_UNUSED;
{ {
} }
size_t size_t
ggc_pch_total_size (d) ggc_pch_total_size (struct ggc_pch_data *d ATTRIBUTE_UNUSED)
struct ggc_pch_data *d ATTRIBUTE_UNUSED;
{ {
return 0; return 0;
} }
void void
ggc_pch_this_base (d, base) ggc_pch_this_base (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data *d ATTRIBUTE_UNUSED; void *base ATTRIBUTE_UNUSED)
void *base ATTRIBUTE_UNUSED;
{ {
} }
char * char *
ggc_pch_alloc_object (d, x, size) ggc_pch_alloc_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data *d ATTRIBUTE_UNUSED; void *x ATTRIBUTE_UNUSED,
void *x ATTRIBUTE_UNUSED; size_t size ATTRIBUTE_UNUSED)
size_t size ATTRIBUTE_UNUSED;
{ {
return NULL; return NULL;
} }
void void
ggc_pch_prepare_write (d, f) ggc_pch_prepare_write (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data * d ATTRIBUTE_UNUSED; FILE * f ATTRIBUTE_UNUSED)
FILE * f ATTRIBUTE_UNUSED;
{ {
} }
void void
ggc_pch_write_object (d, f, x, newx, size) ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data * d ATTRIBUTE_UNUSED; FILE *f ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED,
FILE *f ATTRIBUTE_UNUSED; void *newx ATTRIBUTE_UNUSED,
void *x ATTRIBUTE_UNUSED; size_t size ATTRIBUTE_UNUSED)
void *newx ATTRIBUTE_UNUSED;
size_t size ATTRIBUTE_UNUSED;
{ {
} }
void void
ggc_pch_finish (d, f) ggc_pch_finish (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
struct ggc_pch_data * d ATTRIBUTE_UNUSED; FILE *f ATTRIBUTE_UNUSED)
FILE *f ATTRIBUTE_UNUSED;
{ {
} }
void void
ggc_pch_read (f, addr) ggc_pch_read (FILE *f ATTRIBUTE_UNUSED, void *addr ATTRIBUTE_UNUSED)
FILE *f ATTRIBUTE_UNUSED;
void *addr ATTRIBUTE_UNUSED;
{ {
/* This should be impossible, since we won't generate any valid PCH /* This should be impossible, since we won't generate any valid PCH
files for this configuration. */ files for this configuration. */
......
/* Garbage collection for the GNU compiler. /* Garbage collection for the GNU compiler.
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -30,35 +31,33 @@ extern const char digit_vector[]; /* "0" .. "9" */ ...@@ -30,35 +31,33 @@ extern const char digit_vector[]; /* "0" .. "9" */
machinery. */ machinery. */
/* The first parameter is a pointer to a pointer, the second a cookie. */ /* The first parameter is a pointer to a pointer, the second a cookie. */
typedef void (*gt_pointer_operator) PARAMS ((void *, void *)); typedef void (*gt_pointer_operator) (void *, void *);
#include "gtype-desc.h" #include "gtype-desc.h"
/* One of these applies its third parameter (with cookie in the fourth /* One of these applies its third parameter (with cookie in the fourth
parameter) to each pointer in the object pointed to by the first parameter) to each pointer in the object pointed to by the first
parameter, using the second parameter. */ parameter, using the second parameter. */
typedef void (*gt_note_pointers) typedef void (*gt_note_pointers) (void *, void *, gt_pointer_operator,
PARAMS ((void *, void *, gt_pointer_operator, void *)); void *);
/* One of these is called before objects are re-ordered in memory. /* One of these is called before objects are re-ordered in memory.
The first parameter is the original object, the second is the The first parameter is the original object, the second is the
subobject that has had its pointers reordered, the third parameter subobject that has had its pointers reordered, the third parameter
can compute the new values of a pointer when given the cookie in can compute the new values of a pointer when given the cookie in
the fourth parameter. */ the fourth parameter. */
typedef void (*gt_handle_reorder) typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator,
PARAMS ((void *, void *, gt_pointer_operator, void *)); void *);
/* Used by the gt_pch_n_* routines. Register an object in the hash table. */ /* Used by the gt_pch_n_* routines. Register an object in the hash table. */
extern int gt_pch_note_object extern int gt_pch_note_object (void *, void *, gt_note_pointers);
PARAMS ((void *, void *, gt_note_pointers));
/* Used by the gt_pch_n_* routines. Register that an object has a reorder /* Used by the gt_pch_n_* routines. Register that an object has a reorder
function. */ function. */
extern void gt_pch_note_reorder extern void gt_pch_note_reorder (void *, void *, gt_handle_reorder);
PARAMS ((void *, void *, gt_handle_reorder));
/* Mark the object in the first parameter and anything it points to. */ /* Mark the object in the first parameter and anything it points to. */
typedef void (*gt_pointer_walker) PARAMS ((void *)); typedef void (*gt_pointer_walker) (void *);
/* Structures for the easy way to mark roots. /* Structures for the easy way to mark roots.
In an array, terminated by having base == NULL.*/ In an array, terminated by having base == NULL.*/
...@@ -84,7 +83,7 @@ struct ggc_cache_tab { ...@@ -84,7 +83,7 @@ struct ggc_cache_tab {
size_t stride; size_t stride;
gt_pointer_walker cb; gt_pointer_walker cb;
gt_pointer_walker pchw; gt_pointer_walker pchw;
int (*marked_p) PARAMS ((const void *)); int (*marked_p) (const void *);
}; };
#define LAST_GGC_CACHE_TAB { NULL, 0, 0, NULL, NULL, NULL } #define LAST_GGC_CACHE_TAB { NULL, 0, 0, NULL, NULL, NULL }
/* Pointers to arrays of ggc_cache_tab, terminated by NULL. */ /* Pointers to arrays of ggc_cache_tab, terminated by NULL. */
...@@ -107,102 +106,95 @@ extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[]; ...@@ -107,102 +106,95 @@ extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[];
returns zero if the object was not previously marked; non-zero if returns zero if the object was not previously marked; non-zero if
the object was already marked, or if, for any other reason, the object was already marked, or if, for any other reason,
pointers in this data structure should not be traversed. */ pointers in this data structure should not be traversed. */
extern int ggc_set_mark PARAMS ((const void *)); extern int ggc_set_mark (const void *);
/* Return 1 if P has been marked, zero otherwise. /* Return 1 if P has been marked, zero otherwise.
P must have been allocated by the GC allocator; it mustn't point to P must have been allocated by the GC allocator; it mustn't point to
static objects, stack variables, or memory allocated with malloc. */ static objects, stack variables, or memory allocated with malloc. */
extern int ggc_marked_p PARAMS ((const void *)); extern int ggc_marked_p (const void *);
/* Mark the entries in the string pool. */ /* Mark the entries in the string pool. */
extern void ggc_mark_stringpool PARAMS ((void)); extern void ggc_mark_stringpool (void);
/* Call ggc_set_mark on all the roots. */ /* Call ggc_set_mark on all the roots. */
extern void ggc_mark_roots PARAMS ((void)); extern void ggc_mark_roots (void);
/* Save and restore the string pool entries for PCH. */ /* Save and restore the string pool entries for PCH. */
extern void gt_pch_save_stringpool PARAMS ((void)); extern void gt_pch_save_stringpool (void);
extern void gt_pch_fixup_stringpool PARAMS ((void)); extern void gt_pch_fixup_stringpool (void);
extern void gt_pch_restore_stringpool PARAMS ((void)); extern void gt_pch_restore_stringpool (void);
/* PCH and GGC handling for strings, mostly trivial. */ /* PCH and GGC handling for strings, mostly trivial. */
extern void gt_pch_p_S PARAMS ((void *, void *, extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
gt_pointer_operator, void *)); extern void gt_pch_n_S (const void *);
extern void gt_pch_n_S PARAMS ((const void *)); extern void gt_ggc_m_S (void *);
extern void gt_ggc_m_S PARAMS ((void *));
/* Initialise the string pool. */ /* Initialise the string pool. */
extern void init_stringpool PARAMS ((void)); extern void init_stringpool (void);
/* A GC implementation must provide these functions. They are internal /* A GC implementation must provide these functions. They are internal
to the GC system. */ to the GC system. */
/* Initialize the garbage collector. */ /* Initialize the garbage collector. */
extern void init_ggc PARAMS ((void)); extern void init_ggc (void);
/* Start a new GGC context. Memory allocated in previous contexts /* Start a new GGC context. Memory allocated in previous contexts
will not be collected while the new context is active. */ will not be collected while the new context is active. */
extern void ggc_push_context PARAMS ((void)); extern void ggc_push_context (void);
/* Finish a GC context. Any uncollected memory in the new context /* Finish a GC context. Any uncollected memory in the new context
will be merged with the old context. */ will be merged with the old context. */
extern void ggc_pop_context PARAMS ((void)); extern void ggc_pop_context (void);
struct ggc_pch_data; struct ggc_pch_data;
/* Return a new ggc_pch_data structure. */ /* Return a new ggc_pch_data structure. */
extern struct ggc_pch_data *init_ggc_pch PARAMS ((void)); extern struct ggc_pch_data *init_ggc_pch (void);
/* The second parameter and third parameters give the address and size /* The second parameter and third parameters give the address and size
of an object. Update the ggc_pch_data structure with as much of of an object. Update the ggc_pch_data structure with as much of
that information as is necessary. */ that information as is necessary. */
extern void ggc_pch_count_object PARAMS ((struct ggc_pch_data *, extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t);
void *, size_t));
/* Return the total size of the data to be written to hold all /* Return the total size of the data to be written to hold all
the objects previously passed to ggc_pch_count_object. */ the objects previously passed to ggc_pch_count_object. */
extern size_t ggc_pch_total_size PARAMS ((struct ggc_pch_data *)); extern size_t ggc_pch_total_size (struct ggc_pch_data *);
/* The objects, when read, will most likely be at the address /* The objects, when read, will most likely be at the address
in the second parameter. */ in the second parameter. */
extern void ggc_pch_this_base PARAMS ((struct ggc_pch_data *, extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
void *));
/* Assuming that the objects really do end up at the address /* Assuming that the objects really do end up at the address
passed to ggc_pch_this_base, return the address of this object. */ passed to ggc_pch_this_base, return the address of this object. */
extern char *ggc_pch_alloc_object PARAMS ((struct ggc_pch_data *, extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t);
void *, size_t));
/* Write out any initial information required. */ /* Write out any initial information required. */
extern void ggc_pch_prepare_write PARAMS ((struct ggc_pch_data *, extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
FILE *));
/* Write out this object, including any padding. */ /* Write out this object, including any padding. */
extern void ggc_pch_write_object PARAMS ((struct ggc_pch_data *, extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
FILE *, void *, void *, void *, size_t);
size_t));
/* All objects have been written, write out any final information /* All objects have been written, write out any final information
required. */ required. */
extern void ggc_pch_finish PARAMS ((struct ggc_pch_data *, extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
FILE *));
/* A PCH file has just been read in at the address specified second /* A PCH file has just been read in at the address specified second
parameter. Set up the GC implementation for the new objects. */ parameter. Set up the GC implementation for the new objects. */
extern void ggc_pch_read PARAMS ((FILE *, void *)); extern void ggc_pch_read (FILE *, void *);
/* Allocation. */ /* Allocation. */
/* The internal primitive. */ /* The internal primitive. */
extern void *ggc_alloc PARAMS ((size_t)); extern void *ggc_alloc (size_t);
/* Like ggc_alloc, but allocates cleared memory. */ /* Like ggc_alloc, but allocates cleared memory. */
extern void *ggc_alloc_cleared PARAMS ((size_t)); extern void *ggc_alloc_cleared (size_t);
/* Resize a block. */ /* Resize a block. */
extern void *ggc_realloc PARAMS ((void *, size_t)); extern void *ggc_realloc (void *, size_t);
/* Like ggc_alloc_cleared, but performs a multiplication. */ /* Like ggc_alloc_cleared, but performs a multiplication. */
extern void *ggc_calloc PARAMS ((size_t, size_t)); extern void *ggc_calloc (size_t, size_t);
#define ggc_alloc_rtx(NSLOTS) \ #define ggc_alloc_rtx(NSLOTS) \
((struct rtx_def *) ggc_alloc (sizeof (struct rtx_def) \ ((struct rtx_def *) ggc_alloc (sizeof (struct rtx_def) \
...@@ -221,8 +213,8 @@ extern void *ggc_calloc PARAMS ((size_t, size_t)); ...@@ -221,8 +213,8 @@ extern void *ggc_calloc PARAMS ((size_t, size_t));
splay_tree_new_with_allocator (COMPARE, NULL, NULL, \ splay_tree_new_with_allocator (COMPARE, NULL, NULL, \
&ggc_splay_alloc, &ggc_splay_dont_free, \ &ggc_splay_alloc, &ggc_splay_dont_free, \
NULL) NULL)
extern PTR ggc_splay_alloc PARAMS ((int, void *)); extern void *ggc_splay_alloc (int, void *);
extern void ggc_splay_dont_free PARAMS ((void *, void *)); extern void ggc_splay_dont_free (void *, void *);
/* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS. /* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS.
If LENGTH is -1, then CONTENTS is assumed to be a If LENGTH is -1, then CONTENTS is assumed to be a
...@@ -235,16 +227,16 @@ extern const char *ggc_alloc_string PARAMS ((const char *contents, ...@@ -235,16 +227,16 @@ extern const char *ggc_alloc_string PARAMS ((const char *contents,
/* Invoke the collector. Garbage collection occurs only when this /* Invoke the collector. Garbage collection occurs only when this
function is called, not during allocations. */ function is called, not during allocations. */
extern void ggc_collect PARAMS ((void)); extern void ggc_collect (void);
/* Return the number of bytes allocated at the indicated address. */ /* Return the number of bytes allocated at the indicated address. */
extern size_t ggc_get_size PARAMS ((const void *)); extern size_t ggc_get_size (const void *);
/* Write out all GCed objects to F. */ /* Write out all GCed objects to F. */
extern void gt_pch_save PARAMS ((FILE *f)); extern void gt_pch_save (FILE *f);
/* Read objects previously saved with gt_pch_save from F. */ /* Read objects previously saved with gt_pch_save from F. */
extern void gt_pch_restore PARAMS ((FILE *f)); extern void gt_pch_restore (FILE *f);
/* Statistics. */ /* Statistics. */
...@@ -258,13 +250,13 @@ typedef struct ggc_statistics ...@@ -258,13 +250,13 @@ typedef struct ggc_statistics
/* Used by the various collectors to gather and print statistics that /* Used by the various collectors to gather and print statistics that
do not depend on the collector in use. */ do not depend on the collector in use. */
extern void ggc_print_common_statistics PARAMS ((FILE *, ggc_statistics *)); extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
/* Print allocation statistics. */ /* Print allocation statistics. */
extern void ggc_print_statistics PARAMS ((void)); extern void ggc_print_statistics (void);
extern void stringpool_statistics PARAMS ((void)); extern void stringpool_statistics (void);
/* Heuristics. */ /* Heuristics. */
extern int ggc_min_expand_heuristic PARAMS ((void)); extern int ggc_min_expand_heuristic (void);
extern int ggc_min_heapsize_heuristic PARAMS ((void)); extern int ggc_min_heapsize_heuristic (void);
extern void init_ggc_heuristics PARAMS ((void)); extern void init_ggc_heuristics (void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment