diff options
author | ivmai <ivmai> | 2009-09-27 15:06:46 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:48 +0400 |
commit | 91d5df5ba60368c9a5371f73539dc8189d265668 (patch) | |
tree | ea11c7b648139a922bc33bdaaea7865f36e0b1b6 | |
parent | e7f7aa2d5a2a63e3fa4676616ae904454f67019e (diff) | |
download | bdwgc-91d5df5ba60368c9a5371f73539dc8189d265668.tar.gz |
2009-09-27 Ivan Maidanski <ivmai@mail.ru>
* allchblk.c (GC_hblkfreelist): Define as STATIC.
* blacklst.c (GC_total_stack_black_listed): Ditto.
* include/private/gc_priv.h (GC_hblkfreelist, GC_stopped_mark,
GC_total_stack_black_listed, GC_push_stubborn_structures): Remove
declaration.
* mark_rts.c (GC_stopped_mark): Add declaration (only if
THREAD_LOCAL_ALLOC).
* allchblk.c (GC_fail_count): Move the declaration out of
GC_allochblk_nth(); remove "extern".
* alloc.c (IF_THREADS): Remove unused macro.
* alloc.c (GC_world_stopped): Define only if THREAD_LOCAL_ALLOC.
* alloc.c (GC_stopped_mark): Set GC_world_stopped value only if
THREAD_LOCAL_ALLOC.
* alloc.c (GC_bytes_found, GC_collection_in_progress,
GC_check_tls, GC_unmap_threshold, GC_force_unmap_on_gcollect):
Remove K&R-style "extern" for the declaration.
* dbg_mlc.c (GC_free_inner): Ditto.
* dyn_load.c (GC_repeat_read, GC_roots_present, GC_is_heap_base,
GC_get_next_stack, GC_no_win32_dlls, GC_wnt): Ditto.
* finalize.c (GC_fail_count): Ditto.
* include/private/gc_hdrs.h (GC_hdr_cache_hits,
GC_hdr_cache_misses): Ditto.
* include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder,
GC_lock, GC_collecting, GC_mark_lock_holder, GC_need_to_lock):
Ditto.
* include/private/gc_pmark.h (GC_mark_procs, GC_n_mark_procs,
GC_mark_stack_size, GC_mark_stack_limit, GC_mark_stack_top,
GC_mark_stack, GC_mark_stack_too_small, GC_mark_state): Ditto.
* include/private/gc_priv.h (GC_current_warn_proc, GC_obj_kinds,
GC_n_kinds, GC_fo_entries, GC_n_heap_sects, GC_n_memory,
GC_page_size, GC_sysinfo, GC_black_list_spacing,
GC_objects_are_marked, GC_incremental, GC_dirty_maintained,
GC_root_size, GC_debugging_started, GC_large_alloc_warn_interval,
GC_large_alloc_warn_suppressed, GC_blocked_sp,
GC_activation_frame, GC_push_other_roots,
GC_push_finalizer_structures, GC_push_thread_structures,
GC_push_typed_structures, GC_start_call_back, GC_is_initialized,
GC_check_heap, GC_print_all_smashed, GC_print_all_errors,
GC_print_heap_obj, GC_have_errors, GC_print_stats,
GC_dump_regularly, GC_backtraces, GC_print_back_height,
GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page,
GC_fl_builder_count, GC_mark_no, GC_help_marker,
GC_setup_temporary_fault_handler, GC_reset_fault_handler): Ditto.
* include/private/gcconfig.h (GC_SysVGetDataStart,
GC_FreeBSDGetDataStart, GC_register_stackbottom,
GC_MacTemporaryNewPtr, GC_amiga_get_mem): Ditto.
* include/private/pthread_support.h (GC_threads,
GC_thr_initialized, GC_in_thread_creation): Ditto.
* malloc.c (GC_text_mapping): Ditto.
* mallocx.c (GC_bytes_found): Ditto.
* mark.c (GC_check_dirty, GC_started_thread_while_stopped): Ditto.
* mark_rts.c (GC_save_regs_ret_val): Ditto.
* misc.c (GC_clear_stack_inner, GC_init_parallel, GC_init_win32,
GC_setpagesize, GC_init_linux_data_start,
GC_set_and_save_fault_handler, GC_unmap_threshold): Ditto.
* os_dep.c (GC_unmap_threshold, GC_push_all_stacks,
GC_darwin_register_mach_handler_thread): Ditto.
* pthread_support.c (GC_markers, GC_collection_in_progress):
Ditto.
* tests/test.c (GC_amiga_free_all_mem): Ditto.
* thread_local_alloc.c (GC_gcjobjfreelist,
GC_gcj_malloc_initialized, GC_gcj_kind): Ditto.
* win32_threads.c (GC_write_fault_handler, GC_gww_dirty_init,
GC_fault_handler_lock, GC_write_cs, GC_markers): Ditto.
* misc.c (GC_read, GC_register_finalizer_no_order, GC_init_dyld):
Move the declaration out of GC_init(); remove "extern".
* os_dep.c (GC_abort): Add the comment; add workaround to suppress
compiler "unreachable code" warnings for ABORT callers (where
ABORT is followed by a dummy return statement).
* os_dep.c (GC_old_allocator): Move the declaration out of
GC_default_push_other_roots(); remove "extern".
* darwin_stop_world.c (GC_mprotect_stop, GC_mprotect_resume):
Move the declaration out of GC_stop_world() and GC_start_world()
(only if MPROTECT_VDB); remove "extern".
-rw-r--r-- | ChangeLog | 78 | ||||
-rw-r--r-- | allchblk.c | 15 | ||||
-rw-r--r-- | alloc.c | 29 | ||||
-rw-r--r-- | blacklst.c | 3 | ||||
-rw-r--r-- | darwin_stop_world.c | 6 | ||||
-rw-r--r-- | dbg_mlc.c | 2 | ||||
-rw-r--r-- | dyn_load.c | 33 | ||||
-rw-r--r-- | finalize.c | 2 | ||||
-rw-r--r-- | include/private/gc_hdrs.h | 6 | ||||
-rw-r--r-- | include/private/gc_locks.h | 22 | ||||
-rw-r--r-- | include/private/gc_pmark.h | 18 | ||||
-rw-r--r-- | include/private/gc_priv.h | 107 | ||||
-rw-r--r-- | include/private/gcconfig.h | 26 | ||||
-rw-r--r-- | include/private/pthread_support.h | 6 | ||||
-rw-r--r-- | malloc.c | 2 | ||||
-rw-r--r-- | mallocx.c | 2 | ||||
-rw-r--r-- | mark.c | 4 | ||||
-rw-r--r-- | mark_rts.c | 6 | ||||
-rw-r--r-- | misc.c | 41 | ||||
-rw-r--r-- | os_dep.c | 11 | ||||
-rw-r--r-- | pthread_support.c | 4 | ||||
-rw-r--r-- | tests/test.c | 2 | ||||
-rw-r--r-- | thread_local_alloc.c | 6 | ||||
-rw-r--r-- | win32_threads.c | 12 |
24 files changed, 259 insertions, 184 deletions
@@ -1,5 +1,83 @@ 2009-09-27 Ivan Maidanski <ivmai@mail.ru> + * allchblk.c (GC_hblkfreelist): Define as STATIC. + * blacklst.c (GC_total_stack_black_listed): Ditto. + * include/private/gc_priv.h (GC_hblkfreelist, GC_stopped_mark, + GC_total_stack_black_listed, GC_push_stubborn_structures): Remove + declaration. + * mark_rts.c (GC_stopped_mark): Add declaration (only if + THREAD_LOCAL_ALLOC). + * allchblk.c (GC_fail_count): Move the declaration out of + GC_allochblk_nth(); remove "extern". + * alloc.c (IF_THREADS): Remove unused macro. + * alloc.c (GC_world_stopped): Define only if THREAD_LOCAL_ALLOC. + * alloc.c (GC_stopped_mark): Set GC_world_stopped value only if + THREAD_LOCAL_ALLOC. + * alloc.c (GC_bytes_found, GC_collection_in_progress, + GC_check_tls, GC_unmap_threshold, GC_force_unmap_on_gcollect): + Remove K&R-style "extern" for the declaration. + * dbg_mlc.c (GC_free_inner): Ditto. + * dyn_load.c (GC_repeat_read, GC_roots_present, GC_is_heap_base, + GC_get_next_stack, GC_no_win32_dlls, GC_wnt): Ditto. + * finalize.c (GC_fail_count): Ditto. + * include/private/gc_hdrs.h (GC_hdr_cache_hits, + GC_hdr_cache_misses): Ditto. + * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder, + GC_lock, GC_collecting, GC_mark_lock_holder, GC_need_to_lock): + Ditto. + * include/private/gc_pmark.h (GC_mark_procs, GC_n_mark_procs, + GC_mark_stack_size, GC_mark_stack_limit, GC_mark_stack_top, + GC_mark_stack, GC_mark_stack_too_small, GC_mark_state): Ditto. + * include/private/gc_priv.h (GC_current_warn_proc, GC_obj_kinds, + GC_n_kinds, GC_fo_entries, GC_n_heap_sects, GC_n_memory, + GC_page_size, GC_sysinfo, GC_black_list_spacing, + GC_objects_are_marked, GC_incremental, GC_dirty_maintained, + GC_root_size, GC_debugging_started, GC_large_alloc_warn_interval, + GC_large_alloc_warn_suppressed, GC_blocked_sp, + GC_activation_frame, GC_push_other_roots, + GC_push_finalizer_structures, GC_push_thread_structures, + GC_push_typed_structures, GC_start_call_back, GC_is_initialized, + GC_check_heap, GC_print_all_smashed, GC_print_all_errors, + GC_print_heap_obj, GC_have_errors, GC_print_stats, + GC_dump_regularly, GC_backtraces, GC_print_back_height, + GC_debug_generic_malloc_inner, + GC_debug_generic_malloc_inner_ignore_off_page, + GC_fl_builder_count, GC_mark_no, GC_help_marker, + GC_setup_temporary_fault_handler, GC_reset_fault_handler): Ditto. + * include/private/gcconfig.h (GC_SysVGetDataStart, + GC_FreeBSDGetDataStart, GC_register_stackbottom, + GC_MacTemporaryNewPtr, GC_amiga_get_mem): Ditto. + * include/private/pthread_support.h (GC_threads, + GC_thr_initialized, GC_in_thread_creation): Ditto. + * malloc.c (GC_text_mapping): Ditto. + * mallocx.c (GC_bytes_found): Ditto. + * mark.c (GC_check_dirty, GC_started_thread_while_stopped): Ditto. + * mark_rts.c (GC_save_regs_ret_val): Ditto. + * misc.c (GC_clear_stack_inner, GC_init_parallel, GC_init_win32, + GC_setpagesize, GC_init_linux_data_start, + GC_set_and_save_fault_handler, GC_unmap_threshold): Ditto. + * os_dep.c (GC_unmap_threshold, GC_push_all_stacks, + GC_darwin_register_mach_handler_thread): Ditto. + * pthread_support.c (GC_markers, GC_collection_in_progress): + Ditto. + * tests/test.c (GC_amiga_free_all_mem): Ditto. + * thread_local_alloc.c (GC_gcjobjfreelist, + GC_gcj_malloc_initialized, GC_gcj_kind): Ditto. + * win32_threads.c (GC_write_fault_handler, GC_gww_dirty_init, + GC_fault_handler_lock, GC_write_cs, GC_markers): Ditto. + * misc.c (GC_read, GC_register_finalizer_no_order, GC_init_dyld): + Move the declaration out of GC_init(); remove "extern". + * os_dep.c (GC_abort): Add the comment; add workaround to suppress + compiler "unreachable code" warnings for ABORT callers (where + ABORT is followed by a dummy return statement). + * os_dep.c (GC_old_allocator): Move the declaration out of + GC_default_push_other_roots(); remove "extern". + * darwin_stop_world.c (GC_mprotect_stop, GC_mprotect_resume): + Move the declaration out of GC_stop_world() and GC_start_world() + (only if MPROTECT_VDB); remove "extern". + +2009-09-27 Ivan Maidanski <ivmai@mail.ru> + * win32_threads.c (GC_get_stack_min, GC_push_stack_for, GC_get_next_stack): Recognize _WIN32_WCE_EMULATION macro (used for WinCE emulation and for custom WinCE 6 devices); add the comment. @@ -44,7 +44,11 @@ GC_bool GC_use_entire_heap = 0; # define N_HBLK_FLS (HUGE_THRESHOLD - UNIQUE_THRESHOLD)/FL_COMPRESSION \ + UNIQUE_THRESHOLD -struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 }; +STATIC struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 }; + /* List of completely empty heap blocks */ + /* Linked through hb_next field of */ + /* header structure associated with */ + /* block. */ #ifndef USE_MUNMAP @@ -623,6 +627,9 @@ GC_allochblk(size_t sz, int kind, unsigned flags/* IGNORE_OFF_PAGE or 0 */) } return 0; } + +unsigned GC_fail_count; /* defined in alloc.c */ + /* * The same, but with search restricted to nth free list. * Flags is IGNORE_OFF_PAGE or zero. @@ -796,11 +803,7 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, GC_bool may_split) /* We just successfully allocated a block. Restart count of */ /* consecutive failures. */ - { - extern unsigned GC_fail_count; - - GC_fail_count = 0; - } + GC_fail_count = 0; GC_large_free_bytes -= size_needed; @@ -76,11 +76,8 @@ int GC_full_freq = GC_FULL_FREQ; STATIC GC_bool GC_need_full_gc = FALSE; /* Need full GC do to heap growth. */ -#ifdef THREADS +#ifdef THREAD_LOCAL_ALLOC GC_bool GC_world_stopped = FALSE; -# define IF_THREADS(x) x -#else -# define IF_THREADS(x) #endif STATIC word GC_used_heap_size_after_full = 0; @@ -105,8 +102,8 @@ unsigned GC_version = ((GC_VERSION_MAJOR << 16) | (GC_VERSION_MINOR << 8) | GC_T /* some more variables */ -extern signed_word GC_bytes_found; /* Number of reclaimed bytes */ - /* after garbage collection */ +signed_word GC_bytes_found; /* Number of reclaimed bytes */ + /* after garbage collection */ #ifdef GC_DONT_EXPAND GC_bool GC_dont_expand = TRUE; @@ -120,7 +117,7 @@ extern signed_word GC_bytes_found; /* Number of reclaimed bytes */ word GC_free_space_divisor = GC_FREE_SPACE_DIVISOR; -extern GC_bool GC_collection_in_progress(void); +GC_bool GC_collection_in_progress(void); /* Collection is in progress, or was abandoned. */ int GC_CALLBACK GC_never_stop_func (void) { return(0); } @@ -565,7 +562,9 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) # endif STOP_WORLD(); - IF_THREADS(GC_world_stopped = TRUE); +# ifdef THREAD_LOCAL_ALLOC + GC_world_stopped = TRUE; +# endif if (GC_print_stats) { /* Output blank line for convenience here */ GC_log_printf( @@ -590,7 +589,9 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) "%u iterations\n", i); } GC_deficit = i; /* Give the mutator a chance. */ - IF_THREADS(GC_world_stopped = FALSE); +# ifdef THREAD_LOCAL_ALLOC + GC_world_stopped = FALSE; +# endif START_WORLD(); return(FALSE); } @@ -610,7 +611,9 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) (*GC_check_heap)(); } - IF_THREADS(GC_world_stopped = FALSE); +# ifdef THREAD_LOCAL_ALLOC + GC_world_stopped = FALSE; +# endif START_WORLD(); # ifndef SMALL_CONFIG if (GC_print_stats) { @@ -739,7 +742,7 @@ STATIC void GC_clear_fl_marks(ptr_t q) } #if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC) -extern void GC_check_tls(void); +void GC_check_tls(void); #endif #ifdef MAKE_BACK_GRAPH @@ -898,8 +901,8 @@ STATIC void GC_finish_collection(void) } #ifdef USE_MUNMAP - extern int GC_unmap_threshold; /* defined in allchblk.c */ - extern GC_bool GC_force_unmap_on_gcollect; /* defined in misc.c */ + int GC_unmap_threshold; /* defined in allchblk.c */ + GC_bool GC_force_unmap_on_gcollect; /* defined in misc.c */ #endif /* Externally callable routine to invoke full, stop-world collection */ @@ -46,7 +46,8 @@ STATIC word * GC_incomplete_normal_bl; STATIC word * GC_old_stack_bl; STATIC word * GC_incomplete_stack_bl; -word GC_total_stack_black_listed; +STATIC word GC_total_stack_black_listed; + /* Number of bytes on stack blacklist. */ word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */ diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 7c8c3ca1..90c7bda8 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -511,6 +511,10 @@ STATIC int GC_suspend_thread_list(thread_act_array_t act_list, int count, return changed; } +#ifdef MPROTECT_VDB + void GC_mprotect_stop(void); + void GC_mprotect_resume(void); +#endif /* Caller holds allocation lock. */ void GC_stop_world(void) @@ -584,7 +588,6 @@ void GC_stop_world(void) # ifdef MPROTECT_VDB if(GC_incremental) { - extern void GC_mprotect_stop(); GC_mprotect_stop(); } # endif @@ -620,7 +623,6 @@ void GC_start_world(void) # ifdef MPROTECT_VDB if(GC_incremental) { - extern void GC_mprotect_resume(); GC_mprotect_resume(); } # endif @@ -769,7 +769,7 @@ GC_API void GC_CALL GC_debug_free(void * p) #ifdef THREADS -extern void GC_free_inner(void * p); +void GC_free_inner(void * p); /* Used internally; we assume it's called correctly. */ void GC_debug_free_inner(void * p) @@ -231,7 +231,7 @@ void GC_register_dynamic_libraries(void) #define MAPS_BUF_SIZE (32*1024) -extern ssize_t GC_repeat_read(int fd, char *buf, size_t count); +ssize_t GC_repeat_read(int fd, char *buf, size_t count); /* Repeatedly read until buffer is filled, or EOF is encountered */ /* Defined in os_dep.c. */ @@ -663,7 +663,7 @@ void GC_register_dynamic_libraries(void) # define IRIX6 #endif -extern void * GC_roots_present(ptr_t); +void * GC_roots_present(ptr_t); /* The type is a lie, since the real type doesn't make sense here, */ /* and we only test for NULL. */ @@ -792,11 +792,10 @@ void GC_register_dynamic_libraries(void) /* We traverse the entire address space and register all segments */ /* that could possibly have been written to. */ - extern GC_bool GC_is_heap_base (ptr_t p); + GC_bool GC_is_heap_base(ptr_t p); # ifdef GC_WIN32_THREADS - extern void GC_get_next_stack(char *start, char * limit, char **lo, - char **hi); + void GC_get_next_stack(char *start, char * limit, char **lo, char **hi); STATIC void GC_cond_add_roots(char *base, char * limit) { @@ -830,18 +829,18 @@ void GC_register_dynamic_libraries(void) # endif # ifdef MSWINCE - /* Do we need to separately register the main static data segment? */ - GC_bool GC_register_main_static_data(void) - { - return FALSE; - } + /* Do we need to separately register the main static data segment? */ + GC_bool GC_register_main_static_data(void) + { + return FALSE; + } # else /* win32 */ - extern GC_bool GC_no_win32_dlls; + GC_bool GC_no_win32_dlls; - GC_bool GC_register_main_static_data(void) - { - return GC_no_win32_dlls; - } + GC_bool GC_register_main_static_data(void) + { + return GC_no_win32_dlls; + } # endif /* win32 */ # define HAVE_REGISTER_MAIN_STATIC_DATA @@ -868,8 +867,8 @@ void GC_register_dynamic_libraries(void) /* To workaround that, use -DGC_REGISTER_MEM_PRIVATE. */ # define GC_wnt TRUE # else - extern GC_bool GC_wnt; /* Is Windows NT derivative. */ - /* Defined and set in os_dep.c. */ + GC_bool GC_wnt; /* Is Windows NT derivative. */ + /* Defined and set in os_dep.c. */ # endif void GC_register_dynamic_libraries(void) @@ -495,7 +495,7 @@ void GC_dump_finalization(void) STATIC word GC_old_dl_entries; /* for stats printing */ #endif -extern unsigned GC_fail_count; +unsigned GC_fail_count; /* How many consecutive GC/expansion failures? */ /* Reset by GC_allochblk(); defined in alloc.c. */ diff --git a/include/private/gc_hdrs.h b/include/private/gc_hdrs.h index 40dbe5b8..4ed3c26b 100644 --- a/include/private/gc_hdrs.h +++ b/include/private/gc_hdrs.h @@ -57,8 +57,8 @@ typedef struct hblkhdr hdr; /* #define COUNT_HDR_CACHE_HITS */ # ifdef COUNT_HDR_CACHE_HITS - extern word GC_hdr_cache_hits; - extern word GC_hdr_cache_misses; + word GC_hdr_cache_hits; + word GC_hdr_cache_misses; # define HC_HIT() ++GC_hdr_cache_hits # define HC_MISS() ++GC_hdr_cache_misses # else @@ -132,7 +132,7 @@ typedef struct bi { # endif } bottom_index; -/* extern bottom_index GC_all_nils; - really part of GC_arrays */ +/* bottom_index GC_all_nils; - really part of GC_arrays */ /* extern bottom_index * GC_top_index []; - really part of GC_arrays */ /* Each entry points to a bottom_index. */ diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index f7038f8f..d3bd193b 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -36,7 +36,7 @@ # ifdef PCR # include <base/PCR_Base.h> # include <th/PCR_Th.h> - extern PCR_Th_ML GC_allocate_ml; + PCR_Th_ML GC_allocate_ml; # define DCL_LOCK_STATE \ PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask # define UNCOND_LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml) @@ -54,8 +54,8 @@ # if defined(GC_WIN32_THREADS) && !defined(USE_PTHREAD_LOCKS) # include <windows.h> # define NO_THREAD (DWORD)(-1) - extern DWORD GC_lock_holder; - extern CRITICAL_SECTION GC_allocate_ml; + DWORD GC_lock_holder; + CRITICAL_SECTION GC_allocate_ml; # ifdef GC_ASSERTIONS # define UNCOND_LOCK() \ { EnterCriticalSection(&GC_allocate_ml); \ @@ -114,8 +114,8 @@ /* and sleeping for fixed periods are likely to result in */ /* significant wasted time. We thus rely mostly on queued locks. */ # define USE_SPIN_LOCK - extern volatile AO_TS_t GC_allocate_lock; - extern void GC_lock(void); + volatile AO_TS_t GC_allocate_lock; + void GC_lock(void); /* Allocation lock holder. Only set if acquired by client through */ /* GC_call_with_alloc_lock. */ # ifdef GC_ASSERTIONS @@ -140,7 +140,7 @@ # endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCK */ # ifdef USE_PTHREAD_LOCKS # include <pthread.h> - extern pthread_mutex_t GC_allocate_ml; + pthread_mutex_t GC_allocate_ml; # ifdef GC_ASSERTIONS # define UNCOND_LOCK() \ { GC_lock(); \ @@ -171,13 +171,13 @@ (!GC_need_to_lock \ || GC_lock_holder != NUMERIC_THREAD_ID(pthread_self())) # endif - extern volatile GC_bool GC_collecting; + volatile GC_bool GC_collecting; # define ENTER_GC() GC_collecting = 1; # define EXIT_GC() GC_collecting = 0; - extern void GC_lock(void); - extern unsigned long GC_lock_holder; + void GC_lock(void); + unsigned long GC_lock_holder; # ifdef GC_ASSERTIONS - extern unsigned long GC_mark_lock_holder; + unsigned long GC_mark_lock_holder; # endif # endif /* GC_PTHREADS with linux_threads.c implementation */ @@ -195,7 +195,7 @@ # endif /* !THREADS */ #if defined(UNCOND_LOCK) && !defined(LOCK) - extern GC_bool GC_need_to_lock; + GC_bool GC_need_to_lock; /* At least two thread running; need to lock. */ # define LOCK() if (GC_need_to_lock) { UNCOND_LOCK(); } # define UNLOCK() if (GC_need_to_lock) { UNCOND_UNLOCK(); } diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index dd371b1b..4f4f4ce4 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -46,7 +46,7 @@ /* The real declarations of the following is in gc_priv.h, so that */ /* we can avoid scanning the following table. */ /* -extern mark_proc GC_mark_procs[MAX_MARK_PROCS]; +mark_proc GC_mark_procs[MAX_MARK_PROCS]; */ #ifndef MARK_DESCR_OFFSET @@ -66,7 +66,7 @@ extern mark_proc GC_mark_procs[MAX_MARK_PROCS]; (((word)1 << (WORDSZ - GC_DS_TAG_BITS - GC_LOG_MAX_MARK_PROCS)) - 1) -extern unsigned GC_n_mark_procs; +unsigned GC_n_mark_procs; /* Number of mark stack entries to discard on overflow. */ #define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8) @@ -77,17 +77,17 @@ typedef struct GC_ms_entry { /* as described in gc_mark.h. */ } mse; -extern size_t GC_mark_stack_size; +size_t GC_mark_stack_size; -extern mse * GC_mark_stack_limit; +mse * GC_mark_stack_limit; #ifdef PARALLEL_MARK - extern mse * volatile GC_mark_stack_top; + mse * volatile GC_mark_stack_top; #else - extern mse * GC_mark_stack_top; + mse * GC_mark_stack_top; #endif -extern mse * GC_mark_stack; +mse * GC_mark_stack; #ifdef PARALLEL_MARK /* @@ -451,7 +451,7 @@ mse * GC_mark_from(mse * top, mse * bottom, mse *limit); } \ } -extern GC_bool GC_mark_stack_too_small; +GC_bool GC_mark_stack_too_small; /* We need a larger mark stack. May be */ /* set by client supplied mark routines.*/ @@ -495,6 +495,6 @@ typedef int mark_state_t; /* Current state of marking, as follows:*/ # define MS_INVALID 5 /* I may not hold. */ -extern mark_state_t GC_mark_state; +mark_state_t GC_mark_state; #endif /* GC_PMARK_H */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index cda6fe8c..8b64f7f6 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -376,7 +376,7 @@ void GC_print_callers(struct callinfo info[NFRAMES]); /* Print warning message, e.g. almost out of memory. */ # define WARN(msg,arg) (*GC_current_warn_proc)("GC Warning: " msg, (GC_word)(arg)) -extern GC_warn_proc GC_current_warn_proc; +GC_warn_proc GC_current_warn_proc; /* Print format type macro for signed_word. Currently used for WARN() */ /* only. This could be of use on Win64 but commented out since Win64 */ @@ -1180,7 +1180,7 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays; /* Object kinds: */ # define MAXOBJKINDS 16 -extern struct obj_kind { +struct obj_kind { void **ok_freelist; /* Array of free listheaders for this kind of object */ /* Point either to GC_arrays or to storage allocated */ /* with GC_scratch_alloc. */ @@ -1232,46 +1232,37 @@ extern struct obj_kind { # define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE) # endif -extern unsigned GC_n_kinds; +unsigned GC_n_kinds; -extern word GC_fo_entries; +word GC_fo_entries; -extern word GC_n_heap_sects; /* Number of separately added heap */ +word GC_n_heap_sects; /* Number of separately added heap */ /* sections. */ #ifdef USE_PROC_FOR_LIBRARIES - extern word GC_n_memory; /* Number of GET_MEM allocated memory */ + word GC_n_memory; /* Number of GET_MEM allocated memory */ /* sections. */ #endif -extern word GC_page_size; +word GC_page_size; -# if defined(MSWIN32) || defined(MSWINCE) +#if defined(MSWIN32) || defined(MSWINCE) struct _SYSTEM_INFO; - extern struct _SYSTEM_INFO GC_sysinfo; -# endif - -extern word GC_total_stack_black_listed; - /* Number of bytes on stack blacklist. */ + struct _SYSTEM_INFO GC_sysinfo; +#endif -extern word GC_black_list_spacing; +word GC_black_list_spacing; /* Average number of bytes between blacklisted */ /* blocks. Approximate. */ /* Counts only blocks that are */ /* "stack-blacklisted", i.e. that are */ /* problematic in the interior of an object. */ -extern struct hblk * GC_hblkfreelist[]; - /* List of completely empty heap blocks */ - /* Linked through hb_next field of */ - /* header structure associated with */ - /* block. */ - -extern GC_bool GC_objects_are_marked; /* There are marked objects in */ +GC_bool GC_objects_are_marked; /* There are marked objects in */ /* the heap. */ #ifndef SMALL_CONFIG - extern GC_bool GC_incremental; + GC_bool GC_incremental; /* Using incremental/generational collection. */ # define TRUE_INCREMENTAL \ (GC_incremental && GC_time_limit != GC_TIME_UNLIMITED) @@ -1282,19 +1273,19 @@ extern GC_bool GC_objects_are_marked; /* There are marked objects in */ # define TRUE_INCREMENTAL FALSE #endif -extern GC_bool GC_dirty_maintained; +GC_bool GC_dirty_maintained; /* Dirty bits are being maintained, */ /* either for incremental collection, */ /* or to limit the root set. */ -extern word GC_root_size; /* Total size of registered root sections */ +word GC_root_size; /* Total size of registered root sections. */ -extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ +GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ -extern long GC_large_alloc_warn_interval; +long GC_large_alloc_warn_interval; /* Interval between unsuppressed warnings. */ -extern long GC_large_alloc_warn_suppressed; +long GC_large_alloc_warn_suppressed; /* Number of warnings suppressed so far. */ /* This is used by GC_do_blocking[_inner](). */ @@ -1316,13 +1307,11 @@ struct GC_activation_frame_s { #ifdef THREADS /* Process all activation "frames" - scan entire stack except for */ /* frames belonging to the user functions invoked by GC_do_blocking(). */ -void GC_push_all_stack_frames(ptr_t lo, ptr_t hi, + void GC_push_all_stack_frames(ptr_t lo, ptr_t hi, struct GC_activation_frame_s *activation_frame); - - extern GC_bool GC_world_stopped; #else - extern ptr_t GC_blocked_sp; - extern struct GC_activation_frame_s *GC_activation_frame; + ptr_t GC_blocked_sp; + struct GC_activation_frame_s *GC_activation_frame; /* Points to the "frame" data held in stack by */ /* the innermost GC_call_with_gc_active(). */ /* NULL if no such "frame" active. */ @@ -1456,7 +1445,7 @@ void GC_push_all_eager (ptr_t b, ptr_t t); void GC_push_roots(GC_bool all, ptr_t cold_gc_frame); /* Push all or dirty roots. */ -extern void (*GC_push_other_roots)(void); +void (*GC_push_other_roots)(void); /* Push system or application specific roots */ /* onto the mark stack. In some environments */ /* (e.g. threads environments) this is */ @@ -1464,15 +1453,14 @@ extern void (*GC_push_other_roots)(void); /* supplied replacement should also call the */ /* original function. */ - extern void GC_push_finalizer_structures(void); - extern void GC_push_stubborn_structures (void); -# ifdef THREADS - extern void GC_push_thread_structures (void); -# endif - extern void (*GC_push_typed_structures) (void); +void GC_push_finalizer_structures(void); +#ifdef THREADS + void GC_push_thread_structures(void); +#endif +void (*GC_push_typed_structures)(void); /* A pointer such that we can avoid linking in */ /* the typed allocation support if unused. */ -extern void (*GC_start_call_back) (void); +void (*GC_start_call_back)(void); /* Called at start of full collections. */ /* Not called if 0. Called with allocation */ /* lock held. */ @@ -1708,7 +1696,7 @@ GC_bool GC_collect_or_expand(word needed_blocks, GC_bool ignore_off_page); /* until the blocks are available or */ /* until it fails by returning FALSE. */ -extern GC_bool GC_is_initialized; /* GC_init() has been run. */ +GC_bool GC_is_initialized; /* GC_init() has been run. */ #if defined(MSWIN32) || defined(MSWINCE) void GC_deinit(void); @@ -1827,17 +1815,17 @@ void GC_print_obj(ptr_t p); /* P points to somewhere inside an object with */ /* debugging info. Print a human readable */ /* description of the object to stderr. */ -extern void (*GC_check_heap)(void); +void (*GC_check_heap)(void); /* Check that all objects in the heap with */ /* debugging info are intact. */ /* Add any that are not to GC_smashed list. */ -extern void (*GC_print_all_smashed) (void); +void (*GC_print_all_smashed)(void); /* Print GC_smashed if it's not empty. */ /* Clear GC_smashed list. */ -extern void GC_print_all_errors (void); +void GC_print_all_errors(void); /* Print smashed and leaked objects, if any. */ /* Clear the lists of such objects. */ -extern void (*GC_print_heap_obj) (ptr_t p); +void (*GC_print_heap_obj)(ptr_t p); /* If possible print s followed by a more */ /* detailed description of the object */ /* referred to by p. */ @@ -1846,33 +1834,33 @@ extern void (*GC_print_heap_obj) (ptr_t p); /* Print an address map of the process. */ #endif -extern GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ +GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ /* Call error printing routine */ /* occasionally. */ #ifndef SMALL_CONFIG - extern int GC_print_stats; /* Nonzero generates basic GC log. */ + int GC_print_stats; /* Nonzero generates basic GC log. */ /* VERBOSE generates add'l messages. */ #else # define GC_print_stats 0 - /* Will this keep the message character strings from the executable? */ - /* It should ... */ + /* Will this keep the message character strings from the executable? */ + /* It should ... */ #endif #define VERBOSE 2 #ifndef NO_DEBUGGING - extern GC_bool GC_dump_regularly; /* Generate regular debugging dumps. */ + GC_bool GC_dump_regularly; /* Generate regular debugging dumps. */ # define COND_DUMP if (GC_dump_regularly) GC_dump(); #else # define COND_DUMP #endif #ifdef KEEP_BACK_PTRS - extern long GC_backtraces; + long GC_backtraces; void GC_generate_random_backtrace_no_gc(void); #endif -extern GC_bool GC_print_back_height; +GC_bool GC_print_back_height; #ifdef MAKE_BACK_GRAPH void GC_print_back_graph_stats(void); @@ -1881,9 +1869,8 @@ extern GC_bool GC_print_back_height; /* Macros used for collector internal allocation. */ /* These assume the collector lock is held. */ #ifdef DBG_HDRS_ALL - extern void * GC_debug_generic_malloc_inner(size_t lb, int k); - extern void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, - int k); + void * GC_debug_generic_malloc_inner(size_t lb, int k); + void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k); # define GC_INTERNAL_MALLOC GC_debug_generic_malloc_inner # define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \ GC_debug_generic_malloc_inner_ignore_off_page @@ -2044,13 +2031,13 @@ void GC_err_puts(const char *s); void GC_notify_all_builder(void); void GC_wait_for_reclaim(void); - extern word GC_fl_builder_count; /* Protected by mark lock. */ + word GC_fl_builder_count; /* Protected by mark lock. */ void GC_notify_all_marker(void); void GC_wait_marker(void); - extern word GC_mark_no; /* Protected by mark lock. */ + word GC_mark_no; /* Protected by mark lock. */ - extern void GC_help_marker(word my_mark_no); + void GC_help_marker(word my_mark_no); /* Try to help out parallel marker for mark cycle */ /* my_mark_no. Returns if the mark cycle finishes or */ /* was already done, or there was nothing to do for */ @@ -2149,10 +2136,10 @@ JMP_BUF GC_jmp_buf; /* Set up a handler for address faults which will longjmp to */ /* GC_jmp_buf; */ -extern void GC_setup_temporary_fault_handler(void); +void GC_setup_temporary_fault_handler(void); /* Undo the effect of GC_setup_temporary_fault_handler. */ -extern void GC_reset_fault_handler(void); +void GC_reset_fault_handler(void); # endif /* Need to handle address faults. */ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index f9db8837..5dacf216 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -902,7 +902,7 @@ # define OS_TYPE "SOLARIS" extern int _etext[]; extern int _end[]; - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext) # define DATAEND (ptr_t)(_end) # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) @@ -938,7 +938,7 @@ # endif # ifdef DRSNX # define OS_TYPE "DRSNX" - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); extern int etext[]; # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext) # define MPROTECT_VDB @@ -956,7 +956,7 @@ extern int _etext[]; # define DATAEND (ptr_t)(_end) # define SVR4 - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # ifdef __arch64__ # define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext) # else @@ -1028,7 +1028,7 @@ # ifdef SOLARIS # define OS_TYPE "SOLARIS" extern int _etext[], _end[]; - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext) # define DATAEND (ptr_t)(_end) /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */ @@ -1076,7 +1076,7 @@ # ifdef DGUX # define OS_TYPE "DGUX" extern int _etext, _end; - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)(&_etext)) # define DATAEND (ptr_t)(&_end) # define STACK_GROWS_DOWN @@ -1232,7 +1232,7 @@ # define DYNAMIC_LOADING # endif extern char etext[]; - extern char * GC_FreeBSDGetDataStart(size_t, ptr_t); + char * GC_FreeBSDGetDataStart(size_t, ptr_t); # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext) # endif # ifdef NETBSD @@ -1599,7 +1599,7 @@ /* address minus one page. */ # define BACKING_STORE_DISPLACEMENT 0x1000000 # define BACKING_STORE_ALIGNMENT 0x1000 - extern ptr_t GC_register_stackbottom; + ptr_t GC_register_stackbottom; # define BACKING_STORE_BASE GC_register_stackbottom /* Known to be wrong for recent HP/UX versions!!! */ # endif @@ -1617,7 +1617,7 @@ /* constants: */ # define BACKING_STORE_ALIGNMENT 0x100000 # define BACKING_STORE_DISPLACEMENT 0x80000000 - extern ptr_t GC_register_stackbottom; + ptr_t GC_register_stackbottom; # define BACKING_STORE_BASE GC_register_stackbottom # define SEARCH_FOR_DATA_START # ifdef __GNUC__ @@ -1675,7 +1675,7 @@ # endif # ifdef DGUX # define OS_TYPE "DGUX" - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext) # endif # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */ @@ -1691,7 +1691,7 @@ extern int etext[]; extern int _etext[]; extern int _end[]; - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext) # define DATAEND (ptr_t)(_end) # define HEURISTIC2 @@ -1942,7 +1942,7 @@ # define OS_TYPE "SOLARIS" # define ELF_CLASS ELFCLASS64 extern int _etext[], _end[]; - extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); + ptr_t GC_SysVGetDataStart(size_t, ptr_t); # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext) # define DATAEND (ptr_t)(_end) /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */ @@ -2400,7 +2400,7 @@ # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes) # elif defined(MACOS) # if defined(USE_TEMPORARY_MEMORY) - extern Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory); + Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory); # define GET_MEM(bytes) HBLKPTR( \ GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \ + GC_page_size-1) @@ -2412,7 +2412,7 @@ ptr_t GC_wince_get_mem(GC_word bytes); # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes) # elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC) - extern void *GC_amiga_get_mem(size_t size); + void *GC_amiga_get_mem(size_t size); # define GET_MEM(bytes) HBLKPTR((size_t) \ GC_amiga_get_mem((size_t)bytes + GC_page_size) \ + GC_page_size-1) diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h index 1d75f3e6..be97ad39 100644 --- a/include/private/pthread_support.h +++ b/include/private/pthread_support.h @@ -98,15 +98,15 @@ typedef struct GC_Thread_Rep { } * GC_thread; # define THREAD_TABLE_SZ 256 /* Must be power of 2 */ -extern volatile GC_thread GC_threads[THREAD_TABLE_SZ]; +volatile GC_thread GC_threads[THREAD_TABLE_SZ]; -extern GC_bool GC_thr_initialized; +GC_bool GC_thr_initialized; GC_thread GC_lookup_thread(pthread_t id); void GC_stop_init(void); -extern GC_bool GC_in_thread_creation; +GC_bool GC_in_thread_creation; /* We may currently be in thread creation or destruction. */ /* Only set to TRUE while allocation lock is held. */ /* When set, it is OK to run GC from unknown thread. */ @@ -322,7 +322,7 @@ void * malloc(size_t lb) static ptr_t GC_libpthread_end = 0; static ptr_t GC_libld_start = 0; static ptr_t GC_libld_end = 0; - extern GC_bool GC_text_mapping(char *nm, ptr_t *startp, ptr_t *endp); + GC_bool GC_text_mapping(char *nm, ptr_t *startp, ptr_t *endp); /* From os_dep.c */ STATIC void GC_init_lib_bounds(void) @@ -234,7 +234,7 @@ GC_API void GC_CALL GC_incr_bytes_freed(size_t n) #if defined(THREADS) -extern signed_word GC_bytes_found; /* Protected by GC lock. */ +signed_word GC_bytes_found; /* Protected by GC lock. */ #ifdef PARALLEL_MARK volatile signed_word GC_bytes_allocd_tmp = 0; @@ -251,7 +251,7 @@ void GC_clear_marks(void) } #ifdef CHECKSUMS -extern void GC_check_dirty(void); + void GC_check_dirty(void); #endif /* Initiate a garbage collection. Initiates a full collection if the */ @@ -473,7 +473,7 @@ static void alloc_mark_stack(size_t); # endif /* __GNUC__ && MSWIN32 */ #ifdef GC_WIN32_THREADS - extern GC_bool GC_started_thread_while_stopped(void); + GC_bool GC_started_thread_while_stopped(void); /* In win32_threads.c. Did we invalidate mark phase with an */ /* unexpected thread start? */ #endif @@ -611,7 +611,7 @@ STATIC void GC_push_all_stack_part_eager_frames(ptr_t lo, ptr_t hi, } # ifdef IA64 - extern word GC_save_regs_ret_val; + word GC_save_regs_ret_val; /* Previously set to backing store pointer. */ # endif @@ -719,6 +719,10 @@ STATIC void GC_push_regs_and_stack(ptr_t cold_gc_frame) GC_with_callee_saves_pushed(GC_push_current_stack, cold_gc_frame); } +#ifdef THREAD_LOCAL_ALLOC + GC_bool GC_world_stopped; /* defined in alloc.c */ +#endif + /* * Call the mark routines (GC_tl_push for a single pointer, GC_push_conditional * on groups of pointers) on every top level accessible pointer. @@ -238,7 +238,7 @@ void GC_extend_size_map(size_t i) # define CLEAR_SIZE 213 /* Granularity for GC_clear_stack_inner */ #if defined(ASM_CLEAR_CODE) - extern void *GC_clear_stack_inner(void *, ptr_t); + void *GC_clear_stack_inner(void *, ptr_t); #else /* Clear the stack up to about limit. Return arg. */ /*ARGSUSED*/ @@ -457,7 +457,7 @@ GC_API size_t GC_CALL GC_get_total_bytes(void) GC_bool GC_is_initialized = FALSE; # if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC) - extern void GC_init_parallel(void); + void GC_init_parallel(void); # endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */ #if (defined(MSWIN32) || defined(MSWINCE)) && defined(THREADS) @@ -465,10 +465,10 @@ GC_bool GC_is_initialized = FALSE; #endif #ifdef MSWIN32 - extern void GC_init_win32(void); + void GC_init_win32(void); #endif -extern void GC_setpagesize(void); +void GC_setpagesize(void); STATIC void GC_exit_check(void) { @@ -476,12 +476,12 @@ STATIC void GC_exit_check(void) } #ifdef SEARCH_FOR_DATA_START - extern void GC_init_linux_data_start(void); + void GC_init_linux_data_start(void); #endif #ifdef UNIX_LIKE -extern void GC_set_and_save_fault_handler(void (*handler)(int)); +void GC_set_and_save_fault_handler(void (*handler)(int)); static void looping_handler(int sig) { @@ -512,7 +512,16 @@ static void maybe_install_looping_handler(void) #endif #ifdef USE_MUNMAP - extern int GC_unmap_threshold; + int GC_unmap_threshold; +#endif + +#ifdef LINT + int GC_read(void); + void GC_register_finalizer_no_order(void); +#endif + +#if defined(DYNAMIC_LOADING) && defined(DARWIN) + void GC_init_dyld(void); #endif GC_API void GC_CALL GC_init(void) @@ -838,9 +847,6 @@ GC_API void GC_CALL GC_init(void) # ifdef LINT { extern char * GC_copyright[]; - extern int GC_read(); - extern void GC_register_finalizer_no_order(); - GC_noop(GC_copyright, GC_find_header, GC_push_one, GC_call_with_alloc_lock, GC_read, GC_dont_expand, @@ -857,18 +863,13 @@ GC_API void GC_CALL GC_init(void) /* Make sure marker threads are started and thread local */ /* allocation is initialized, in case we didn't get */ /* called from GC_init_parallel(); */ - { - GC_init_parallel(); - } + GC_init_parallel(); # endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */ # if defined(DYNAMIC_LOADING) && defined(DARWIN) - { - /* This must be called WITHOUT the allocation lock held - and before any threads are created */ - extern void GC_init_dyld(); + /* This must be called WITHOUT the allocation lock held */ + /* and before any threads are created. */ GC_init_dyld(); - } # endif RESTORE_CANCEL(cancel_state); } @@ -1211,6 +1212,7 @@ GC_API GC_warn_proc GC_CALL GC_get_warn_proc(void) } #if !defined(PCR) && !defined(SMALL_CONFIG) +/* Abort the program with a message. msg must not be NULL. */ void GC_abort(const char *msg) { # if defined(MSWIN32) @@ -1245,7 +1247,8 @@ void GC_abort(const char *msg) for(;;) {} } # if defined(MSWIN32) && defined(NO_DEBUGGING) - /* A more user-friendly abort after showing fatal message. */ + /* A more user-friendly abort after showing fatal message. */ + if (msg) /* to suppress compiler warnings in ABORT callers. */ _exit(-1); /* exit on error without running "at-exit" callbacks */ # elif defined(MSWIN32) || defined(MSWINCE) DebugBreak(); @@ -1387,7 +1387,7 @@ void GC_register_data_segments(void) /* This is a Windows NT derivative, i.e. NT, W2K, XP or later. */ # ifdef USE_MUNMAP - extern int GC_unmap_threshold; /* defined in allchblk.c */ + int GC_unmap_threshold; /* defined in allchblk.c */ # endif void GC_init_win32(void) @@ -2221,19 +2221,16 @@ 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; void GC_default_push_other_roots(void) { /* Traverse data allocated by previous memory managers. */ - { - extern struct PCR_MM_ProcsRep * GC_old_allocator; - if ((*(GC_old_allocator->mmp_enumerate))(PCR_Bool_false, GC_push_old_obj, 0) != PCR_ERes_okay) { ABORT("Old object enumeration failed"); } - } /* Traverse all thread stacks. */ if (PCR_ERes_IsErr( PCR_ThCtl_ApplyToAllOtherThreads(GC_push_thread_stack,0)) @@ -2247,7 +2244,7 @@ void GC_default_push_other_roots(void) # if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) -extern void GC_push_all_stacks(void); +void GC_push_all_stacks(void); STATIC void GC_default_push_other_roots(void) { @@ -3469,7 +3466,7 @@ void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree) #include <mach/task.h> #include <pthread.h> -extern void GC_darwin_register_mach_handler_thread(mach_port_t); +void GC_darwin_register_mach_handler_thread(mach_port_t); /* These are not defined in any header, although they are documented */ extern boolean_t diff --git a/pthread_support.c b/pthread_support.c index b2d9518a..6691c26c 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -309,7 +309,7 @@ STATIC void * GC_mark_thread(void * id) } } -extern long GC_markers; /* Number of mark threads we would */ +long GC_markers; /* Number of mark threads we would */ /* like to have. Includes the */ /* initiating thread. */ @@ -643,7 +643,7 @@ STATIC int GC_get_nprocs(void) /* If wait_for_all is true, then we exit with the GC lock held and no */ /* collection in progress; otherwise we just wait for the current GC */ /* to finish. */ -extern GC_bool GC_collection_in_progress(void); +GC_bool GC_collection_in_progress(void); STATIC void GC_wait_for_gc_completion(GC_bool wait_for_all) { GC_ASSERT(I_HOLD_LOCK()); diff --git a/tests/test.c b/tests/test.c index 5621db8f..ace1be51 100644 --- a/tests/test.c +++ b/tests/test.c @@ -99,7 +99,7 @@ int realloc_count = 0; #if defined(GC_AMIGA_FASTALLOC) && defined(AMIGA) - extern void GC_amiga_free_all_mem(void); + void GC_amiga_free_all_mem(void); void Amiga_Fail(void){GC_amiga_free_all_mem();abort();} # define FAIL (void)Amiga_Fail() void *GC_amiga_gctest_malloc_explicitly_typed(size_t lb, GC_descr d){ diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 0045e1ed..f377eaac 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 - extern ptr_t * GC_gcjobjfreelist; + ptr_t * GC_gcjobjfreelist; #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 - extern GC_bool GC_gcj_malloc_initialized; + GC_bool GC_gcj_malloc_initialized; #endif -extern int GC_gcj_kind; +int GC_gcj_kind; /* Gcj-style allocation without locks is extremely tricky. The */ /* fundamental issue is that we may end up marking a free list, which */ diff --git a/win32_threads.c b/win32_threads.c index 3392755f..3e2662d6 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -354,11 +354,10 @@ STATIC GC_thread GC_new_thread(DWORD id) return(result); } -extern LONG WINAPI GC_write_fault_handler( - struct _EXCEPTION_POINTERS *exc_info); +LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info); #if defined(GWW_VDB) && defined(MPROTECT_VDB) - extern GC_bool GC_gww_dirty_init(void); + GC_bool GC_gww_dirty_init(void); /* Defined in os_dep.c. Returns TRUE if GetWriteWatch is available. */ /* may be called repeatedly. */ #endif @@ -924,7 +923,7 @@ void GC_push_thread_structures(void) #if defined(MPROTECT_VDB) # include "atomic_ops.h" - extern volatile AO_TS_t GC_fault_handler_lock; /* from os_dep.c */ + volatile AO_TS_t GC_fault_handler_lock; /* from os_dep.c */ #endif /* Suspend the given thread, if it's still active. */ @@ -976,9 +975,8 @@ STATIC void GC_suspend(GC_thread t) # endif } -/* Defined in misc.c */ #ifndef CYGWIN32 - extern CRITICAL_SECTION GC_write_cs; + CRITICAL_SECTION GC_write_cs; /* defined in misc.c */ #endif void GC_stop_world(void) @@ -1316,7 +1314,7 @@ void GC_push_all_stacks(void) # define MAX_MARKERS 16 # endif - extern long GC_markers; /* Number of mark threads we would */ + long GC_markers; /* Number of mark threads we would */ /* like to have. Includes the */ /* initiating thread. */ |