summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog66
-rw-r--r--allchblk.c5
-rw-r--r--alloc.c9
-rw-r--r--backgraph.c8
-rw-r--r--blacklst.c10
-rw-r--r--checksums.c19
-rw-r--r--dbg_mlc.c8
-rw-r--r--finalize.c6
-rw-r--r--gcj_mlc.c13
-rw-r--r--include/private/gc_priv.h9
-rw-r--r--mach_dep.c4
-rw-r--r--mallocx.c2
-rw-r--r--mark.c11
-rw-r--r--mark_rts.c9
-rw-r--r--misc.c27
-rw-r--r--os_dep.c66
-rw-r--r--pthread_stop_world.c7
-rw-r--r--pthread_support.c14
-rw-r--r--reclaim.c2
-rw-r--r--thread_local_alloc.c8
-rw-r--r--typd_mlc.c23
-rw-r--r--win32_threads.c17
22 files changed, 200 insertions, 143 deletions
diff --git a/ChangeLog b/ChangeLog
index afab8fe4..43e01011 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,69 @@
+2009-09-30 Ivan Maidanski <ivmai@mail.ru>
+
+ * allchblk.c (GC_large_alloc_warn_interval): Move declaration from
+ gc_priv.h.
+ * allchblk.c (GC_large_alloc_warn_suppressed): Move definition
+ from misc.c; define as STATIC.
+ * include/private/gc_priv.h (GC_large_alloc_warn_interval,
+ GC_large_alloc_warn_suppressed): Remove declaration.
+ * alloc.c (GC_bytes_found): Add "defined in" comment.
+ * mallocx.c (GC_bytes_found): Ditto.
+ * misc.c (GC_unmap_threshold): Ditto.
+ * os_dep.c (GC_old_allocator): Ditto.
+ * pthread_support.c (GC_markers): Ditto.
+ * thread_local_alloc.c (GC_gcjobjfreelist,
+ GC_gcj_malloc_initialized, GC_gcj_kind): Ditto.
+ * win32_threads.c (GC_markers): Ditto.
+ * alloc.c (GC_start_time): Explicitly initialize to 0 or NULL (to
+ be distinctive from a variable declaration).
+ * backgraph.c (GC_max_height, GC_deepest_obj): Ditto.
+ * blacklst.c (GC_old_normal_bl, GC_incomplete_normal_bl,
+ GC_old_stack_bl, GC_incomplete_stack_bl): Ditto.
+ * checksums.c (GC_faulted, GC_n_dirty_errors,
+ GC_n_faulted_dirty_errors, GC_n_changed_errors, GC_n_clean,
+ GC_n_dirty, GC_bytes_in_used_blocks): Ditto.
+ * dbg_mlc.c (GC_smashed): Ditto.
+ * finalize.c (GC_old_dl_entries): Ditto.
+ * gcj_mlc.c (GC_gcj_kind, GC_gcj_debug_kind, GC_gcjobjfreelist,
+ GC_gcjdebugobjfreelist): Ditto.
+ * mach_dep.c (GC_save_regs_ret_val): Ditto.
+ * mark.c (GC_n_rescuing_pages, GC_mark_stack, GC_mark_stack_limit,
+ GC_mark_stack_top): Ditto.
+ * misc.c (GC_min_sp, GC_high_water, GC_bytes_allocd_at_reset):
+ Ditto.
+ * os_dep.c (GC_data_start, GC_page_size, GC_sysinfo,
+ GC_old_segv_handler, GC_old_bus_handler,
+ GC_old_bus_handler_used_si, GC_old_segv_handler_used_si,
+ GC_proc_buf, GC_proc_fd, GC_vd_base): Ditto.
+ * pthread_stop_world.c (GC_stop_count, GC_stopping_pid): Ditto.
+ * reclaim.c (GC_leaked): Ditto.
+ * typd_mlc.c (GC_explicit_kind, GC_array_kind, GC_ext_descriptors,
+ GC_typed_mark_proc_index, GC_array_mark_proc_index,
+ GC_eobjfreelist, GC_arobjfreelist): Ditto.
+ * win32_threads.c (GC_pthread_map_cache, GC_marker_cv,
+ GC_marker_Id): Ditto.
+ * dbg_mlc.c (GC_smashed, GC_n_smashed): Define as STATIC.
+ * gcj_mlc.c (GC_gcjdebugobjfreelist): Ditto.
+ * os_dep.c (GC_vd_base): Ditto.
+ * pthread_support.c (GC_mark_threads): Ditto.
+ * reclaim.c (GC_leaked): Ditto.
+ * typd_mlc.c (GC_bm_table): Ditto.
+ * mark_rts.c (GC_save_regs_ret_val): Change declaration type to
+ that of definition; add "defined in" comment.
+ * mark_rts.c (GC_push_current_stack): Remove unnecessary cast for
+ GC_save_regs_ret_val.
+ * misc.c (GC_check_heap, GC_print_all_smashed,
+ GC_start_call_back): Remove unnecessary cast (of 0).
+ * misc.c (GC_LARGE_ALLOC_WARN_INTERVAL): New tuning macro.
+ * misc.c (GC_large_alloc_warn_interval): Initialize to
+ GC_LARGE_ALLOC_WARN_INTERVAL value.
+ * misc.c (GC_tmp): Change to "static".
+ * os_dep.c (GC_setpagesize): Reformat the code (collapse multiple
+ function definitions).
+ * os_dep.c (GC_mprotect_state): Define as static.
+ * pthread_support.c (dummy_thread_local): Prefix with "GC_".
+ * win32_threads.c (WinMain): Remove FIXME for WinCE.
+
2009-09-30 Ivan Maidanski <ivmai@mail.ru> (really Hans Boehm)
* os_dep.c (PROTECT, UNPROTECT): Use distinct ABORT messages.
diff --git a/allchblk.c b/allchblk.c
index 656ac33a..6446adef 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -630,6 +630,11 @@ GC_allochblk(size_t sz, int kind, unsigned flags/* IGNORE_OFF_PAGE or 0 */)
unsigned GC_fail_count; /* defined in alloc.c */
+long GC_large_alloc_warn_interval; /* defined in misc.c */
+
+STATIC long GC_large_alloc_warn_suppressed = 0;
+ /* Number of warnings suppressed so far. */
+
/*
* The same, but with search restricted to nth free list.
* Flags is IGNORE_OFF_PAGE or zero.
diff --git a/alloc.c b/alloc.c
index a1b11309..350b043a 100644
--- a/alloc.c
+++ b/alloc.c
@@ -15,7 +15,6 @@
*
*/
-
# include "private/gc_priv.h"
# include <stdio.h>
@@ -107,7 +106,8 @@ GC_API unsigned GC_CALL GC_get_version(void)
/* some more variables */
signed_word GC_bytes_found; /* Number of reclaimed bytes */
- /* after garbage collection */
+ /* after garbage collection; */
+ /* defined in reclaim.c. */
#ifdef GC_DONT_EXPAND
GC_bool GC_dont_expand = TRUE;
@@ -134,7 +134,8 @@ int GC_CALLBACK GC_never_stop_func (void) { return(0); }
unsigned long GC_time_limit = GC_TIME_LIMIT;
#ifndef NO_CLOCK
-STATIC CLOCK_TYPE GC_start_time;/* Time at which we stopped world. */
+STATIC CLOCK_TYPE GC_start_time = 0;
+ /* Time at which we stopped world. */
/* used only in GC_timeout_stop_func. */
#endif
@@ -438,8 +439,6 @@ GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
return(TRUE);
}
-
-
/*
* Perform n units of garbage collection work. A unit is intended to touch
* roughly GC_RATE pages. Every once in a while, we do more than that.
diff --git a/backgraph.c b/backgraph.c
index 1243c3ce..92a4135e 100644
--- a/backgraph.c
+++ b/backgraph.c
@@ -216,7 +216,7 @@ static void ensure_struct(ptr_t p)
/* Add the (forward) edge from p to q to the backward graph. Both p */
/* q are pointers to the object base, i.e. pointers to an oh. */
-static void add_edge(ptr_t p, ptr_t q)
+static void add_edge(ptr_t p, ptr_t q)
{
ptr_t old_back_ptr = GET_OH_BG_PTR(q);
back_edges * be, *be_cont;
@@ -393,10 +393,10 @@ static word backwards_height(ptr_t p)
return result;
}
-STATIC word GC_max_height;
-STATIC ptr_t GC_deepest_obj;
+STATIC word GC_max_height = 0;
+STATIC ptr_t GC_deepest_obj = NULL;
-/* Compute the maximum height of every unreachable predecessor p of a */
+/* Compute the maximum height of every unreachable predecessor p of a */
/* reachable object. Arrange to save the heights of all such objects p */
/* so that they can be used in calculating the height of objects in the */
/* next GC. */
diff --git a/blacklst.c b/blacklst.c
index 5bd479d3..e93b7bd1 100644
--- a/blacklst.c
+++ b/blacklst.c
@@ -37,16 +37,16 @@
/* Pointers to individual tables. We replace one table by another by */
/* switching these pointers. */
-STATIC word * GC_old_normal_bl;
+STATIC word * GC_old_normal_bl = NULL;
/* Nonstack false references seen at last full */
/* collection. */
-STATIC word * GC_incomplete_normal_bl;
+STATIC word * GC_incomplete_normal_bl = NULL;
/* Nonstack false references seen since last */
/* full collection. */
-STATIC word * GC_old_stack_bl;
-STATIC word * GC_incomplete_stack_bl;
+STATIC word * GC_old_stack_bl = NULL;
+STATIC word * GC_incomplete_stack_bl = NULL;
-STATIC word GC_total_stack_black_listed;
+STATIC word GC_total_stack_black_listed = 0;
/* Number of bytes on stack blacklist. */
word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */
diff --git a/checksums.c b/checksums.c
index 41bec06c..d9b26d0d 100644
--- a/checksums.c
+++ b/checksums.c
@@ -33,10 +33,11 @@ typedef struct {
/* to hide it from collector. */
} page_entry;
-page_entry GC_sums [NSUMS];
+page_entry GC_sums[NSUMS];
+
+STATIC word GC_faulted[NSUMS] = { 0 };
+ /* Record of pages on which we saw a write fault. */
-STATIC word GC_faulted[NSUMS]; /* Record of pages on which we saw a write */
- /* fault. */
STATIC size_t GC_n_faulted = 0;
void GC_record_fault(struct hblk * h)
@@ -91,11 +92,11 @@ STATIC GC_bool GC_on_free_list(struct hblk *h)
}
# endif
-int GC_n_dirty_errors;
-int GC_n_faulted_dirty_errors;
-int GC_n_changed_errors;
-int GC_n_clean;
-int GC_n_dirty;
+int GC_n_dirty_errors = 0;
+int GC_n_faulted_dirty_errors = 0;
+int GC_n_changed_errors = 0;
+int GC_n_clean = 0;
+int GC_n_dirty = 0;
STATIC void GC_update_check_page(struct hblk *h, int index)
{
@@ -144,7 +145,7 @@ STATIC void GC_update_check_page(struct hblk *h, int index)
pe -> block = h + OFFSET;
}
-word GC_bytes_in_used_blocks;
+word GC_bytes_in_used_blocks = 0;
/*ARGSUSED*/
STATIC void GC_add_block(struct hblk *h, word dummy)
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 0558913c..af0b509f 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -377,8 +377,6 @@ STATIC void GC_print_type(ptr_t p)
}
}
-
-
void GC_print_obj(ptr_t p)
{
oh * ohdr = (oh *)GC_base(p);
@@ -844,7 +842,7 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
# endif
if (old_sz < copy_sz) copy_sz = old_sz;
if (result == 0) return(0);
- BCOPY(p, result, copy_sz);
+ BCOPY(p, result, copy_sz);
GC_debug_free(p);
return(result);
}
@@ -856,8 +854,8 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
/* We put them here instead of in GC_arrays, since it may be useful to */
/* be able to look at them with the debugger. */
#define MAX_SMASHED 20
-ptr_t GC_smashed[MAX_SMASHED];
-unsigned GC_n_smashed = 0;
+STATIC ptr_t GC_smashed[MAX_SMASHED] = {0};
+STATIC unsigned GC_n_smashed = 0;
STATIC void GC_add_smashed(ptr_t smashed)
{
diff --git a/finalize.c b/finalize.c
index 71687dde..bda054e4 100644
--- a/finalize.c
+++ b/finalize.c
@@ -145,7 +145,7 @@ GC_API int GC_CALL GC_register_disappearing_link(void * * link)
}
GC_API int GC_CALL GC_general_register_disappearing_link(void * * link,
- void * obj)
+ void * obj)
{
struct disappearing_link *curr_dl;
size_t index;
@@ -296,8 +296,6 @@ STATIC void GC_unreachable_finalize_mark_proc(ptr_t p)
GC_normal_finalize_mark_proc(p);
}
-
-
/* Register a finalization function. See gc.h for details. */
/* The last parameter is a procedure that determines */
/* marking for finalization ordering. Any objects marked */
@@ -492,7 +490,7 @@ void GC_dump_finalization(void)
#endif
#ifndef SMALL_CONFIG
- STATIC word GC_old_dl_entries; /* for stats printing */
+ STATIC word GC_old_dl_entries = 0; /* for stats printing */
#endif
unsigned GC_fail_count;
diff --git a/gcj_mlc.c b/gcj_mlc.c
index 189c25aa..265252d5 100644
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -42,13 +42,14 @@
GC_bool GC_gcj_malloc_initialized = FALSE;
-int GC_gcj_kind; /* Object kind for objects with descriptors */
+int GC_gcj_kind = 0; /* Object kind for objects with descriptors */
/* in "vtable". */
-int GC_gcj_debug_kind; /* The kind of objects that is always marked */
+int GC_gcj_debug_kind = 0;
+ /* The kind of objects that is always marked */
/* with a mark proc call. */
-ptr_t * GC_gcjobjfreelist;
-ptr_t * GC_gcjdebugobjfreelist;
+ptr_t * GC_gcjobjfreelist = NULL;
+STATIC ptr_t * GC_gcjdebugobjfreelist = NULL;
/*ARGSUSED*/
STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr,
@@ -62,7 +63,7 @@ STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr,
/* Caller does not hold allocation lock. */
GC_API void GC_CALL GC_init_gcj_malloc(int mp_index,
- void * /* really GC_mark_proc */mp)
+ void * /* really GC_mark_proc */mp)
{
GC_bool ignore_gcj_info;
DCL_LOCK_STATE;
@@ -153,7 +154,7 @@ static void maybe_finalize(void)
void * GC_core_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr)
#else
GC_API void * GC_CALL GC_gcj_malloc(size_t lb,
- void * ptr_to_struct_containing_descr)
+ void * ptr_to_struct_containing_descr)
#endif
{
ptr_t op;
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 4e9dbdb1..1eed0694 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -275,7 +275,7 @@ void GC_print_callers(struct callinfo info[NFRAMES]);
* CLOCKS_PER_SEC be defined. But at least under SunOS4.1.1, it isn't.
* Also note that the combination of ANSI C and POSIX is incredibly gross
* here. The type clock_t is used by both clock() and times(). But on
- * some machines these use different notions of a clock tick, CLOCKS_PER_SEC
+ * some machines these use different notions of a clock tick, CLOCKS_PER_SEC
* seems to apply only to clock. Hence we use it here. On many machines,
* including SunOS, clock actually uses units of microseconds (which are
* not really clock ticks).
@@ -691,7 +691,6 @@ typedef word page_hash_table[PHT_SIZE];
(bl)[divWORDSZ(index)] = ONES
-
/********************************************/
/* */
/* H e a p B l o c k s */
@@ -1282,12 +1281,6 @@ extern word GC_root_size; /* Total size of registered root sections. */
extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called */
-extern long GC_large_alloc_warn_interval;
- /* Interval between unsuppressed warnings. */
-
-extern long GC_large_alloc_warn_suppressed;
- /* Number of warnings suppressed so far. */
-
/* This is used by GC_do_blocking[_inner](). */
struct blocking_data {
GC_fn_type fn;
diff --git a/mach_dep.c b/mach_dep.c
index 990da351..56e3ed22 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -64,8 +64,8 @@ asm static void PushMacRegisters()
# if defined(SPARC) || defined(IA64)
/* Value returned from register flushing routine; either sp (SPARC) */
- /* or ar.bsp (IA64) */
- ptr_t GC_save_regs_ret_val;
+ /* or ar.bsp (IA64). */
+ ptr_t GC_save_regs_ret_val = NULL;
# endif
/* Routine to mark from registers that are preserved by the C compiler. */
diff --git a/mallocx.c b/mallocx.c
index fce51c05..f46395c1 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -234,7 +234,7 @@ GC_API void GC_CALL GC_incr_bytes_freed(size_t n)
#if defined(THREADS)
-signed_word GC_bytes_found; /* Protected by GC lock. */
+signed_word GC_bytes_found; /* protected by GC lock; defined in reclaim.c */
#ifdef PARALLEL_MARK
volatile signed_word GC_bytes_allocd_tmp = 0;
diff --git a/mark.c b/mark.c
index 35aca8e2..e0b1fef4 100644
--- a/mark.c
+++ b/mark.c
@@ -101,17 +101,18 @@ struct obj_kind GC_obj_kinds[MAXOBJKINDS] = {
* need to be marked from.
*/
-STATIC word GC_n_rescuing_pages;/* Number of dirty pages we marked from */
+STATIC word GC_n_rescuing_pages = 0;
+ /* Number of dirty pages we marked from */
/* excludes ptrfree pages, etc. */
-mse * GC_mark_stack;
+mse * GC_mark_stack = NULL;
-mse * GC_mark_stack_limit;
+mse * GC_mark_stack_limit = NULL;
size_t GC_mark_stack_size = 0;
#ifdef PARALLEL_MARK
- mse * volatile GC_mark_stack_top;
+ mse * volatile GC_mark_stack_top = NULL;
/* Updated only with mark lock held, but read asynchronously. */
volatile AO_t GC_first_nonempty;
/* Lowest entry on mark stack */
@@ -119,7 +120,7 @@ size_t GC_mark_stack_size = 0;
/* Updated only by initiating */
/* thread. */
#else
- mse * GC_mark_stack_top;
+ mse * GC_mark_stack_top = NULL;
#endif
static struct hblk * scan_ptr;
diff --git a/mark_rts.c b/mark_rts.c
index 64b1b5db..1326d39e 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -132,9 +132,6 @@ static void add_roots_to_index(struct roots *p)
# endif
-
-
-
word GC_root_size = 0;
GC_API void GC_CALL GC_add_roots(void *b, void *e)
@@ -611,7 +608,7 @@ STATIC void GC_push_all_stack_part_eager_frames(ptr_t lo, ptr_t hi,
}
# ifdef IA64
- word GC_save_regs_ret_val;
+ ptr_t GC_save_regs_ret_val; /* defined in mach_dep.c. */
/* Previously set to backing store pointer. */
# endif
@@ -655,7 +652,7 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void * context)
/* Note that the backing store grows up, so we can't use */
/* GC_push_all_stack_partially_eager. */
{
- ptr_t bsp = (ptr_t) GC_save_regs_ret_val;
+ ptr_t bsp = GC_save_regs_ret_val;
ptr_t cold_gc_bs_pointer = bsp - 2048;
if (GC_all_interior_pointers &&
cold_gc_bs_pointer > BACKING_STORE_BASE) {
@@ -678,7 +675,7 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void * context)
# endif /* !THREADS */
}
-void (*GC_push_typed_structures) (void) = NULL;
+void (*GC_push_typed_structures) (void) = 0;
/* Push GC internal roots. These are normally */
/* included in the static data segment, and */
diff --git a/misc.c b/misc.c
index 359276cc..54709b0c 100644
--- a/misc.c
+++ b/misc.c
@@ -72,10 +72,10 @@ GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */;
GC_bool GC_debugging_started = FALSE;
/* defined here so we don't have to load debug_malloc.o */
-void (*GC_check_heap) (void) = (void (*) (void))0;
-void (*GC_print_all_smashed) (void) = (void (*) (void))0;
+void (*GC_check_heap) (void) = 0;
+void (*GC_print_all_smashed) (void) = 0;
-void (*GC_start_call_back) (void) = (void (*) (void))0;
+void (*GC_start_call_back) (void) = 0;
ptr_t GC_stackbottom = 0;
@@ -124,12 +124,12 @@ GC_bool GC_print_back_height = 0;
GC_bool GC_force_unmap_on_gcollect = FALSE;
#endif
-long GC_large_alloc_warn_interval = 5;
+#ifndef GC_LARGE_ALLOC_WARN_INTERVAL
+# define GC_LARGE_ALLOC_WARN_INTERVAL 5
+#endif
+long GC_large_alloc_warn_interval = GC_LARGE_ALLOC_WARN_INTERVAL;
/* Interval between unsuppressed warnings. */
-long GC_large_alloc_warn_suppressed = 0;
- /* Number of warnings suppressed so far. */
-
/*ARGSUSED*/
STATIC void * GC_CALLBACK GC_default_oom_fn(size_t bytes_requested)
{
@@ -226,12 +226,13 @@ void GC_extend_size_map(size_t i)
# define SMALL_CLEAR_SIZE 256 /* Clear this much every time. */
# else
STATIC word GC_stack_last_cleared = 0; /* GC_no when we last did this */
- STATIC ptr_t GC_min_sp; /* Coolest stack pointer value from which */
- /* we've already cleared the stack. */
- STATIC ptr_t GC_high_water;
+ STATIC ptr_t GC_min_sp = NULL;
+ /* Coolest stack pointer value from which */
+ /* we've already cleared the stack. */
+ STATIC ptr_t GC_high_water = NULL;
/* "hottest" stack pointer value we have seen */
/* recently. Degrades over time. */
- STATIC word GC_bytes_allocd_at_reset;
+ STATIC word GC_bytes_allocd_at_reset = 0;
# define DEGRADE_RATE 50
# endif
@@ -512,7 +513,7 @@ static void maybe_install_looping_handler(void)
#endif
#ifdef USE_MUNMAP
- int GC_unmap_threshold;
+ int GC_unmap_threshold; /* defined in allchblk.c */
#endif
#ifdef LINT
@@ -1022,7 +1023,7 @@ out:
STATIC FILE * GC_stdout = NULL;
STATIC FILE * GC_stderr = NULL;
STATIC FILE * GC_log = NULL;
-STATIC int GC_tmp; /* Should really be local ... */
+static int GC_tmp; /* Should really be local ... */
STATIC void GC_set_files(void)
{
diff --git a/os_dep.c b/os_dep.c
index 56e901fc..20f06153 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -450,7 +450,7 @@ static ptr_t backing_store_base_from_proc(void)
# endif /* LINUX */
extern int _end[];
- ptr_t GC_data_start;
+ ptr_t GC_data_start = NULL;
ptr_t GC_find_limit(ptr_t, GC_bool);
@@ -503,7 +503,7 @@ static void *tiny_sbrk(ptrdiff_t increment)
# endif /* ECOS */
#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
- ptr_t GC_data_start;
+ ptr_t GC_data_start = NULL;
ptr_t GC_find_limit(ptr_t, GC_bool);
extern char **environ;
@@ -599,28 +599,25 @@ struct o32_obj {
# endif /* OS/2 */
/* Find the page size */
-word GC_page_size;
+word GC_page_size = 0;
# if defined(MSWIN32) || defined(MSWINCE)
- void GC_setpagesize(void)
- {
- GetSystemInfo(&GC_sysinfo);
- GC_page_size = GC_sysinfo.dwPageSize;
- }
+ void GC_setpagesize(void)
+ {
+ GetSystemInfo(&GC_sysinfo);
+ GC_page_size = GC_sysinfo.dwPageSize;
+ }
# else
-# if defined(MPROTECT_VDB) || defined(PROC_VDB) || defined(USE_MMAP)
- void GC_setpagesize(void)
- {
- GC_page_size = GETPAGESIZE();
- }
-# else
+ void GC_setpagesize(void)
+ {
+# if defined(MPROTECT_VDB) || defined(PROC_VDB) || defined(USE_MMAP)
+ GC_page_size = GETPAGESIZE();
+# else
/* It's acceptable to fake it. */
- void GC_setpagesize(void)
- {
- GC_page_size = HBLKSIZE;
- }
-# endif
+ GC_page_size = HBLKSIZE;
+# endif
+ }
# endif
# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
@@ -1751,7 +1748,7 @@ STATIC ptr_t GC_unix_mmap_get_mem(word bytes)
}
# endif
- if (bytes & (GC_page_size -1)) ABORT("Bad GET_MEM arg");
+ if (bytes & (GC_page_size - 1)) ABORT("Bad GET_MEM arg");
result = mmap(last_addr, bytes, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
GC_MMAP_FLAGS | OPT_MAP_ANON, zero_fd, 0/* offset */);
if (result == MAP_FAILED) return(0);
@@ -1876,7 +1873,7 @@ void * os2_alloc(size_t bytes)
# if defined(MSWIN32) || defined(MSWINCE)
-SYSTEM_INFO GC_sysinfo;
+SYSTEM_INFO GC_sysinfo = {0};
# endif
# ifdef MSWIN32
@@ -2221,7 +2218,7 @@ PCR_ERes GC_push_old_obj(void *p, size_t size, PCR_Any data)
return(PCR_ERes_okay);
}
-struct PCR_MM_ProcsRep * GC_old_allocator;
+struct PCR_MM_ProcsRep * GC_old_allocator; /* defined in pcr_interface.c */
void GC_default_push_other_roots(void)
{
@@ -2258,7 +2255,7 @@ void (*GC_push_other_roots)(void) = GC_default_push_other_roots;
#endif /* THREADS */
/*
- * Routines for accessing dirty bits on virtual pages.
+ * Routines for accessing dirty bits on virtual pages.
* There are six ways to maintain this information:
* DEFAULT_VDB: A simple dummy implementation that treats every page
* as possibly dirty. This makes incremental collection
@@ -2648,12 +2645,12 @@ void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
#endif
#ifndef DARWIN
-STATIC SIG_HNDLR_PTR GC_old_segv_handler;
+STATIC SIG_HNDLR_PTR GC_old_segv_handler = 0;
/* Also old MSWIN32 ACCESS_VIOLATION filter */
#if !defined(MSWIN32) && !defined(MSWINCE)
-STATIC SIG_HNDLR_PTR GC_old_bus_handler;
-STATIC GC_bool GC_old_bus_handler_used_si;
-STATIC GC_bool GC_old_segv_handler_used_si;
+STATIC SIG_HNDLR_PTR GC_old_bus_handler = 0;
+STATIC GC_bool GC_old_bus_handler_used_si = FALSE;
+STATIC GC_bool GC_old_segv_handler_used_si = FALSE;
#endif
#endif /* !DARWIN */
@@ -3253,9 +3250,9 @@ GC_bool GC_page_was_ever_dirty(struct hblk *h)
#define INITIAL_BUF_SZ 16384
STATIC word GC_proc_buf_size = INITIAL_BUF_SZ;
-STATIC char *GC_proc_buf;
+STATIC char *GC_proc_buf = NULL;
-STATIC int GC_proc_fd;
+STATIC int GC_proc_fd = 0;
void GC_dirty_init(void)
{
@@ -3388,9 +3385,10 @@ GC_bool GC_page_was_ever_dirty(struct hblk *h)
# define NPAGES (32*1024) /* 128 MB */
-PCR_VD_DB GC_grungy_bits[NPAGES];
+PCR_VD_DB GC_grungy_bits[NPAGES];
-ptr_t GC_vd_base; /* Address corresponding to GC_grungy_bits[0] */
+STATIC ptr_t GC_vd_base = NULL;
+ /* Address corresponding to GC_grungy_bits[0] */
/* HBLKSIZE aligned. */
void GC_dirty_init(void)
@@ -3517,7 +3515,7 @@ typedef enum {
} GC_mprotect_state_t;
/* FIXME: 1 and 2 seem to be safe to use in the msgh_id field,
- but it isn't documented. Use the source and see if they
+ but it isn't documented. Use the source and see if they
should be ok. */
#define ID_STOP 1
#define ID_RESUME 2
@@ -3527,7 +3525,7 @@ typedef enum {
#if defined(THREADS)
-GC_mprotect_state_t GC_mprotect_state;
+static GC_mprotect_state_t GC_mprotect_state;
/* The following should ONLY be called when the world is stopped */
static void GC_mprotect_thread_notify(mach_msg_id_t id)
@@ -4306,8 +4304,6 @@ void GC_print_callers (struct callinfo info[NFRAMES])
#endif /* NEED_CALLINFO */
-
-
#if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG)
/* Dump /proc/self/maps to GC_stderr, to enable looking up names for
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 08363ffb..424e90fa 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -82,7 +82,7 @@ STATIC void GC_remove_allowed_signals(sigset_t *set)
static sigset_t suspend_handler_mask;
-volatile AO_t GC_stop_count;
+volatile AO_t GC_stop_count = 0;
/* Incremented at the beginning of GC_stop_world. */
volatile AO_t GC_world_is_stopped = FALSE;
@@ -343,7 +343,7 @@ void GC_push_all_stacks(void)
/* debug that, we save the ids of the stopping thread. */
#if DEBUG_THREADS
pthread_t GC_stopping_thread;
-int GC_stopping_pid;
+int GC_stopping_pid = 0;
#endif
/* We hold the allocation lock. Suspend all threads that might */
@@ -523,7 +523,8 @@ void GC_start_world(void)
# endif
}
-void GC_stop_init(void) {
+void GC_stop_init(void)
+{
struct sigaction act;
if (sem_init(&GC_suspend_ack_sem, 0, 0) != 0)
diff --git a/pthread_support.c b/pthread_support.c
index 6691c26c..bf3269a6 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -97,7 +97,7 @@ unsigned long GC_lock_holder = NO_THREAD;
# include <sys/dg_sys_info.h>
# include <sys/_int_psem.h>
/* sem_t is an uint in DG/UX */
- typedef unsigned int sem_t;
+ typedef unsigned int sem_t;
#endif /* GC_DGUX386_THREADS */
/* Undefine macros used to redirect pthread primitives. */
@@ -309,11 +309,11 @@ STATIC void * GC_mark_thread(void * id)
}
}
-long GC_markers; /* Number of mark threads we would */
- /* like to have. Includes the */
- /* initiating thread. */
+long GC_markers; /* Number of mark threads we would like to */
+ /* have. Includes the initiating thread. */
+ /* Defined in mark.c. */
-pthread_t GC_mark_threads[MAX_MARKERS];
+STATIC pthread_t GC_mark_threads[MAX_MARKERS];
#define PTHREAD_CREATE REAL_FUNC(pthread_create)
@@ -772,7 +772,7 @@ static int get_ncpu(void)
#endif /* GC_NETBSD_THREADS */
# if defined(GC_LINUX_THREADS) && defined(INCLUDE_LINUX_THREAD_DESCR)
-__thread int dummy_thread_local;
+__thread int GC_dummy_thread_local;
# endif
/* We hold the allocation lock. */
@@ -797,7 +797,7 @@ void GC_thr_init(void)
/* locals for the main thread, except for those allocated */
/* in response to dlopen calls. */
{
- ptr_t thread_local_addr = (ptr_t)(&dummy_thread_local);
+ ptr_t thread_local_addr = (ptr_t)(&GC_dummy_thread_local);
ptr_t main_thread_start, main_thread_end;
if (!GC_enclosing_mapping(thread_local_addr, &main_thread_start,
&main_thread_end)) {
diff --git a/reclaim.c b/reclaim.c
index 159315f8..555c99c1 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -33,7 +33,7 @@ signed_word GC_bytes_found = 0;
/* cycle, since the routine for printing objects needs to run outside */
/* the collector, e.g. without the allocation lock. */
#define MAX_LEAKED 40
-ptr_t GC_leaked[MAX_LEAKED];
+STATIC ptr_t GC_leaked[MAX_LEAKED] = { NULL };
STATIC unsigned GC_n_leaked = 0;
GC_bool GC_have_errors = FALSE;
diff --git a/thread_local_alloc.c b/thread_local_alloc.c
index f377eaac..03a82d84 100644
--- a/thread_local_alloc.c
+++ b/thread_local_alloc.c
@@ -111,7 +111,7 @@ void GC_init_thread_local(GC_tlfs p)
}
#ifdef GC_GCJ_SUPPORT
- ptr_t * GC_gcjobjfreelist;
+ ptr_t * GC_gcjobjfreelist; /* defined in gcj_mlc.c. */
#endif
/* We hold the allocator lock. */
@@ -208,10 +208,10 @@ GC_API void * GC_CALL GC_malloc_atomic(size_t bytes)
#include "include/gc_gcj.h"
#ifdef GC_ASSERTIONS
- GC_bool GC_gcj_malloc_initialized;
+ GC_bool GC_gcj_malloc_initialized; /* defined in gcj_mlc.c. */
#endif
-int GC_gcj_kind;
+int GC_gcj_kind; /* defined in gcj_mlc.c. */
/* Gcj-style allocation without locks is extremely tricky. The */
/* fundamental issue is that we may end up marking a free list, which */
@@ -234,7 +234,7 @@ int GC_gcj_kind;
/* Unlike the other thread local allocation calls, we assume that the */
/* collector has been explicitly initialized. */
GC_API void * GC_CALL GC_gcj_malloc(size_t bytes,
- void * ptr_to_struct_containing_descr)
+ void * ptr_to_struct_containing_descr)
{
if (GC_EXPECT(GC_incremental, 0)) {
return GC_core_gcj_malloc(bytes, ptr_to_struct_containing_descr);
diff --git a/typd_mlc.c b/typd_mlc.c
index 82bd92dc..ce49419d 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -43,11 +43,11 @@
STATIC GC_bool GC_explicit_typing_initialized = FALSE;
-STATIC int GC_explicit_kind;
+STATIC int GC_explicit_kind = 0;
/* Object kind for objects with indirect */
/* (possibly extended) descriptors. */
-STATIC int GC_array_kind;
+STATIC int GC_array_kind = 0;
/* Object kind for objects with complex */
/* descriptors and GC_array_mark_proc. */
@@ -88,7 +88,8 @@ typedef union ComplexDescriptor {
} complex_descriptor;
#define TAG ld.ld_tag
-STATIC ext_descr * GC_ext_descriptors; /* Points to array of extended */
+STATIC ext_descr * GC_ext_descriptors = NULL;
+ /* Points to array of extended */
/* descriptors. */
STATIC size_t GC_ed_size = 0; /* Current size of above arrays. */
@@ -96,8 +97,8 @@ STATIC size_t GC_ed_size = 0; /* Current size of above arrays. */
STATIC size_t GC_avail_descr = 0; /* Next available slot. */
-STATIC int GC_typed_mark_proc_index; /* Indices of my mark */
-STATIC int GC_array_mark_proc_index; /* procedures. */
+STATIC int GC_typed_mark_proc_index = 0; /* Indices of my mark */
+STATIC int GC_array_mark_proc_index = 0; /* procedures. */
static void GC_push_typed_structures_proc (void)
{
@@ -162,7 +163,7 @@ STATIC signed_word GC_add_ext_descriptor(GC_bitmap bm, word nbits)
}
/* Table of bitmap descriptors for n word long all pointer objects. */
-GC_descr GC_bm_table[WORDSZ/2];
+STATIC GC_descr GC_bm_table[WORDSZ/2];
/* Return a descriptor for the concatenation of 2 nwords long objects, */
/* each of which is described by descriptor. */
@@ -316,7 +317,7 @@ GC_make_sequence_descriptor(complex_descriptor *first,
#ifdef UNDEFINED
complex_descriptor * GC_make_complex_array_descriptor(word nelements,
- complex_descriptor *descr)
+ complex_descriptor *descr)
{
struct ComplexArrayDescriptor * result =
(struct ComplexArrayDescriptor *)
@@ -331,9 +332,9 @@ complex_descriptor * GC_make_complex_array_descriptor(word nelements,
}
#endif
-STATIC ptr_t * GC_eobjfreelist;
+STATIC ptr_t * GC_eobjfreelist = NULL;
-STATIC ptr_t * GC_arobjfreelist;
+STATIC ptr_t * GC_arobjfreelist = NULL;
STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
mse * mark_stack_limit, word env);
@@ -612,7 +613,7 @@ GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
}
GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb,
- GC_descr d)
+ GC_descr d)
{
ptr_t op;
ptr_t * opp;
@@ -647,7 +648,7 @@ GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb,
}
GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t n, size_t lb,
- GC_descr d)
+ GC_descr d)
{
ptr_t op;
ptr_t * opp;
diff --git a/win32_threads.c b/win32_threads.c
index 3e2662d6..6bd88936 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -775,7 +775,7 @@ void GC_do_blocking_inner(ptr_t data, void * context)
/* GC_do_blocking() to temporarily back allow calling any GC function */
/* and/or manipulating pointers to the garbage collected heap. */
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
- void * client_data)
+ void * client_data)
{
struct GC_activation_frame_s frame;
GC_thread me;
@@ -829,7 +829,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
/* A quick-and-dirty cache of the mapping between pthread_t */
/* and win32 thread id. */
# define PTHREAD_MAP_SIZE 512
- DWORD GC_pthread_map_cache[PTHREAD_MAP_SIZE];
+ DWORD GC_pthread_map_cache[PTHREAD_MAP_SIZE] = {0};
# define HASH(pthread_id) ((NUMERIC_THREAD_ID(pthread_id) >> 5) % \
PTHREAD_MAP_SIZE)
/* It appears pthread_t is really a pointer type ... */
@@ -1314,9 +1314,9 @@ void GC_push_all_stacks(void)
# define MAX_MARKERS 16
# endif
- long GC_markers; /* Number of mark threads we would */
- /* like to have. Includes the */
- /* initiating thread. */
+ long GC_markers; /* Number of mark threads we would like to */
+ /* have. Includes the initiating thread. */
+ /* Defined in mark.c. */
static ptr_t marker_sp[MAX_MARKERS - 1]; /* The cold end of the stack */
/* for markers. */
@@ -1616,11 +1616,11 @@ void GC_get_next_stack(char *start, char *limit,
# else /* ! GC_PTHREADS_PARAMARK */
# ifdef DONT_USE_SIGNALANDWAIT
- STATIC HANDLE GC_marker_cv[MAX_MARKERS - 1];
+ STATIC HANDLE GC_marker_cv[MAX_MARKERS - 1] = {0};
/* Events with manual reset (one for each */
/* mark helper). */
- STATIC DWORD GC_marker_Id[MAX_MARKERS - 1];
+ STATIC DWORD GC_marker_Id[MAX_MARKERS - 1] = {0};
/* This table is used for mapping helper */
/* threads ID to mark helper index (linear */
/* search is used since the mapping contains */
@@ -1854,7 +1854,7 @@ void GC_get_next_stack(char *start, char *limit,
/* a signal loosing between checking for a particular condition */
/* and calling WaitForSingleObject. So, we use PulseEvent() and */
/* NT SignalObjectAndWait() (which atomically sets mutex event to */
- /* signaled state and starts waiting on condvar). A special */
+ /* signaled state and starts waiting on condvar). A special */
/* case here is GC_mark_mutex_waitcnt == 1 (i.e. nobody waits for */
/* mark lock at this moment) - we don't change it (otherwise we */
/* may loose a signal sent between decrementing */
@@ -2152,7 +2152,6 @@ void GC_get_next_stack(char *start, char *limit,
}
# ifdef MSWINCE
- /* FIXME: Is this really obligatory on WinCE? */
GC_deinit();
DeleteCriticalSection(&GC_allocate_ml);
# endif