From: Ivan Maidanski Date: Wed, 28 Feb 2018 06:12:54 +0000 (+0300) Subject: Declare all internal functions in private headers instead of .c files X-Git-Tag: v8.0.0~320 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a1f78a27e56b47e64c976548630ffc48193eb10;p=gc Declare all internal functions in private headers instead of .c files (code refactoring) Issue #206 (bdwgc). * include/private/darwin_stop_world.h [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Declare function. * include/private/gc_priv.h [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * include/private/gc_priv.h [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * include/private/gc_priv.h (GC_collect_or_expand): Likewise. * include/private/gc_priv.h [MPROTECT_VDB && USE_MUNMAP] (GC_mprotect_dirty_init, GC_has_unmapped_memory): Likewise. * include/private/gc_priv.h [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * include/private/gc_priv.h [CHECKSUMS] (GC_check_dirty): Likewise. * include/private/gc_priv.h [GC_WIN32_THREADS && WRAP_MARK_SOME && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * include/private/gc_priv.h [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * include/private/gc_priv.h [NEED_PROC_MAPS && (IA64 || INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Likewise. * include/private/pthread_support.h (GC_inner_start_routine): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS] (GC_is_thread_tsd_valid, GC_check_tls_for): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * include/private/gc_priv.h [HEURISTIC2 || SEARCH_FOR_DATA_START || !STACKBOTTOM && HEURISTIC2 || (SVR4 || AIX || DGUX || LINUX && SPARC) && !PCR] (NEED_FIND_LIMIT): Collapse multiple definitions. * malloc.c (GC_collect_or_expand): Remove prototype. * mark.c [CHECKSUMS] (GC_check_dirty): Likewise. * mark.c [GC_WIN32_THREADS && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * mark_rts.c [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * os_dep.c [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * os_dep.c [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory, GC_mprotect_dirty_init): Likewise. * os_dep.c [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Likewise. * pthread_support.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * pthread_support.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * pthread_support.c [INCLUDE_LINUX_THREAD_DESCR] (GC_enclosing_mapping): Likewise. * pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_inner_start_routine): Likewise. * thread_local_alloc.c [GC_ASSERTIONS] (GC_is_thread_tsd_valid): Likewise. * win32_threads.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * win32_threads.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. --- diff --git a/include/private/darwin_stop_world.h b/include/private/darwin_stop_world.h index 8f69d9d0..ca8ef9ed 100644 --- a/include/private/darwin_stop_world.h +++ b/include/private/darwin_stop_world.h @@ -41,6 +41,9 @@ struct thread_stop_info { #ifdef MPROTECT_VDB GC_INNER void GC_mprotect_stop(void); GC_INNER void GC_mprotect_resume(void); +# ifndef GC_NO_THREADS_DISCOVERY + GC_INNER void GC_darwin_register_mach_handler_thread(mach_port_t thread); +# endif #endif #if defined(PARALLEL_MARK) && !defined(GC_NO_THREADS_DISCOVERY) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 2062cc03..393aec52 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1742,6 +1742,13 @@ GC_INNER void GC_push_all_stack(ptr_t b, ptr_t t); /* As GC_push_all but consider */ /* interior pointers as valid. */ +#if defined(WRAP_MARK_SOME) && defined(PARALLEL_MARK) + /* GC_mark_local does not handle memory protection faults yet. So, */ + /* the static data regions are scanned immediately by GC_push_roots. */ + GC_INNER void GC_push_conditional_eager(void *bottom, void *top, + GC_bool all); +#endif + /* In the threads case, we push part of the current thread stack */ /* with GC_push_all_eager when we push the registers. This gets the */ /* callee-save registers that may disappear. The remainder of the */ @@ -1836,7 +1843,10 @@ void GC_register_data_segments(void); GC_INNER GC_bool GC_is_static_root(void *p); /* Is the address p in one of the registered static */ /* root sections? */ -#endif +# ifdef TRACE_BUF + void GC_add_trace_entry(char *kind, word arg1, word arg2); +# endif +#endif /* !THREADS */ /* Black listing: */ #ifdef PRINT_BLACK_LIST @@ -1993,6 +2003,9 @@ GC_INNER void * GC_generic_malloc_inner(size_t lb, int k); /* object is live. */ #endif +GC_INNER GC_bool GC_collect_or_expand(word needed_blocks, + GC_bool ignore_off_page, GC_bool retry); + GC_INNER ptr_t GC_allocobj(size_t sz, int kind); /* Make the indicated */ /* free list nonempty, and return its */ @@ -2357,17 +2370,30 @@ GC_EXTERN signed_word GC_bytes_found; GC_EXTERN ptr_t * GC_gcjobjfreelist; #endif -#if defined(GWW_VDB) && defined(MPROTECT_VDB) - GC_INNER GC_bool GC_gww_dirty_init(void); - /* Defined in os_dep.c. Returns TRUE if GetWriteWatch is available. */ - /* May be called repeatedly. */ -#endif +#ifdef MPROTECT_VDB +# ifdef GWW_VDB + GC_INNER GC_bool GC_gww_dirty_init(void); + /* Returns TRUE if GetWriteWatch is available. */ + /* May be called repeatedly. */ +# endif +# ifdef USE_MUNMAP + GC_INNER GC_bool GC_mprotect_dirty_init(void); + GC_INNER GC_bool GC_has_unmapped_memory(void); +# endif +#endif /* MPROTECT_VDB */ #if defined(CHECKSUMS) || defined(PROC_VDB) GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h); /* Could the page contain valid heap pointers? */ #endif +#ifdef CHECKSUMS +# if defined(MPROTECT_VDB) && !defined(DARWIN) + void GC_record_fault(struct hblk * h); +# endif + void GC_check_dirty(void); +#endif + GC_INNER void GC_default_print_heap_obj_proc(ptr_t p); GC_INNER void GC_setpagesize(void); @@ -2415,6 +2441,10 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, # ifdef MPROTECT_VDB GC_INNER void GC_set_write_fault_handler(void); # endif +# if defined(WRAP_MARK_SOME) && !defined(GC_PTHREADS) + GC_INNER GC_bool GC_started_thread_while_stopped(void); + /* Did we invalidate mark phase with an unexpected thread start? */ +# endif #endif /* GC_WIN32_THREADS */ #ifdef THREADS @@ -2439,10 +2469,12 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, #ifdef SEARCH_FOR_DATA_START GC_INNER void GC_init_linux_data_start(void); + ptr_t GC_find_limit(ptr_t, GC_bool); #endif #if defined(NETBSD) && defined(__ELF__) GC_INNER void GC_init_netbsd_elf(void); + ptr_t GC_find_limit(ptr_t, GC_bool); #endif #ifdef UNIX_LIKE @@ -2454,6 +2486,10 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, GC_INNER char *GC_parse_map_entry(char *buf_ptr, ptr_t *start, ptr_t *end, char **prot, unsigned int *maj_dev, char **mapping_name); +# endif +# if defined(IA64) || defined(INCLUDE_LINUX_THREAD_DESCR) + GC_INNER GC_bool GC_enclosing_mapping(ptr_t addr, + ptr_t *startp, ptr_t *endp); # endif GC_INNER char *GC_get_maps(void); /* from os_dep.c */ #endif /* NEED_PROC_MAPS */ @@ -2616,16 +2652,10 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, /* Do we need the GC_find_limit machinery to find the end of a */ /* data segment. */ -#if defined(HEURISTIC2) || defined(SEARCH_FOR_DATA_START) -# define NEED_FIND_LIMIT -#endif - -#if !defined(STACKBOTTOM) && defined(HEURISTIC2) -# define NEED_FIND_LIMIT -#endif - -#if (defined(SVR4) || defined(AIX) || defined(DGUX) \ - || (defined(LINUX) && defined(SPARC))) && !defined(PCR) +#if defined(HEURISTIC2) || defined(SEARCH_FOR_DATA_START) \ + || (!defined(STACKBOTTOM) && defined(HEURISTIC2)) \ + || ((defined(SVR4) || defined(AIX) || defined(DGUX) \ + || (defined(LINUX) && defined(SPARC))) && !defined(PCR)) # define NEED_FIND_LIMIT #endif diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h index c9f99761..57a6cd90 100644 --- a/include/private/pthread_support.h +++ b/include/private/pthread_support.h @@ -175,6 +175,9 @@ GC_EXTERN GC_bool GC_in_thread_creation; # define GC_INNER_PTHRSTART GC_INNER #endif +GC_INNER_PTHRSTART void * GC_CALLBACK GC_inner_start_routine( + struct GC_stack_base *sb, void *arg); + GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread( void *(**pstart)(void *), void **pstart_arg, diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h index 16fc555e..268e3ec2 100644 --- a/include/private/thread_local_alloc.h +++ b/include/private/thread_local_alloc.h @@ -185,6 +185,14 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p); /* we take care of an individual thread freelist structure. */ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p); +#ifdef GC_ASSERTIONS + GC_bool GC_is_thread_tsd_valid(void *tsd); + void GC_check_tls_for(GC_tlfs p); +# if defined(USE_CUSTOM_SPECIFIC) + void GC_check_tsd_marks(tsd *key); +# endif +#endif /* GC_ASSERTIONS */ + #ifndef GC_ATTR_TLS_FAST # define GC_ATTR_TLS_FAST /* empty */ #endif diff --git a/malloc.c b/malloc.c index 0155fa5a..df734852 100644 --- a/malloc.c +++ b/malloc.c @@ -31,10 +31,6 @@ STATIC GC_bool GC_alloc_reclaim_list(struct obj_kind *kind) return(TRUE); } -GC_INNER GC_bool GC_collect_or_expand(word needed_blocks, - GC_bool ignore_off_page, - GC_bool retry); /* from alloc.c */ - /* Allocate a large block of size lb bytes. */ /* The block is not cleared. */ /* Flags is 0 or IGNORE_OFF_PAGE. */ diff --git a/mark.c b/mark.c index 8347bfc5..d8b69e5f 100644 --- a/mark.c +++ b/mark.c @@ -255,10 +255,6 @@ GC_INNER void GC_clear_marks(void) scan_ptr = 0; } -#ifdef CHECKSUMS - void GC_check_dirty(void); -#endif - /* Initiate a garbage collection. Initiates a full collection if the */ /* mark state is invalid. */ GC_INNER void GC_initiate_gc(void) @@ -486,12 +482,6 @@ static void alloc_mark_stack(size_t); } # endif /* __GNUC__ && MSWIN32 */ -#if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) - GC_INNER GC_bool GC_started_thread_while_stopped(void); - /* In win32_threads.c. Did we invalidate mark phase with an */ - /* unexpected thread start? */ -#endif - GC_INNER GC_bool GC_mark_some(ptr_t cold_gc_frame) { GC_bool ret_val; diff --git a/mark_rts.c b/mark_rts.c index 3f0b6f16..6e297abd 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -499,10 +499,6 @@ GC_API void GC_CALL GC_exclude_static_roots(void *b, void *e) } #if defined(WRAP_MARK_SOME) && defined(PARALLEL_MARK) - /* GC_mark_local does not handle memory protection faults yet. So, */ - /* the static data regions are scanned immediately by GC_push_roots. */ - GC_INNER void GC_push_conditional_eager(void *bottom, void *top, - GC_bool all); # define GC_PUSH_CONDITIONAL(b, t, all) \ (GC_parallel \ ? GC_push_conditional_eager(b, t, all) \ @@ -586,11 +582,6 @@ GC_INNER void GC_push_all_stack_sections(ptr_t lo, ptr_t hi, #else /* !THREADS */ -# ifdef TRACE_BUF - /* Defined in mark.c. */ - void GC_add_trace_entry(char *kind, word arg1, word arg2); -# endif - /* Similar to GC_push_all_eager, but only the */ /* part hotter than cold_gc_frame is scanned */ /* immediately. Needed to ensure that callee- */ diff --git a/os_dep.c b/os_dep.c index ea887728..f7369ac2 100644 --- a/os_dep.c +++ b/os_dep.c @@ -424,8 +424,6 @@ GC_INNER char * GC_get_maps(void) ptr_t GC_data_start = NULL; - ptr_t GC_find_limit(ptr_t, GC_bool); - GC_INNER void GC_init_linux_data_start(void) { ptr_t data_end = DATAEND; @@ -498,7 +496,6 @@ GC_INNER char * GC_get_maps(void) #if defined(NETBSD) && defined(__ELF__) ptr_t GC_data_start = NULL; - ptr_t GC_find_limit(ptr_t, GC_bool); extern char **environ; @@ -3231,10 +3228,6 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) #ifndef DARWIN -# ifdef CHECKSUMS - void GC_record_fault(struct hblk * h); /* from checksums.c */ -# endif - # if !defined(MSWIN32) && !defined(MSWINCE) # include # if defined(FREEBSD) || defined(HURD) || defined(HPUX) @@ -3446,9 +3439,6 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, } #ifdef USE_MUNMAP - GC_INNER GC_bool GC_has_unmapped_memory(void); /* from allchblk.c */ - GC_INNER GC_bool GC_mprotect_dirty_init(void); - /* MPROTECT_VDB cannot deal with address space holes (for now), */ /* so if the collector is configured with both MPROTECT_VDB and */ /* USE_MUNMAP then, as a work around, select only one of them */ @@ -4104,10 +4094,6 @@ typedef enum { GC_mprotect_thread_notify(ID_RESUME); } -# ifndef GC_NO_THREADS_DISCOVERY - GC_INNER void GC_darwin_register_mach_handler_thread(mach_port_t thread); -# endif - #else /* The compiler should optimize away any GC_mprotect_state computations */ # define GC_mprotect_state GC_MP_NORMAL diff --git a/pthread_support.c b/pthread_support.c index f42b5dff..7705e1f1 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -287,11 +287,6 @@ STATIC int GC_nprocs = 1; } # if defined(GC_ASSERTIONS) - void GC_check_tls_for(GC_tlfs p); -# if defined(USE_CUSTOM_SPECIFIC) - void GC_check_tsd_marks(tsd *key); -# endif - /* Check that all thread-local free-lists are completely marked. */ /* Also check that thread-specific-data structures are marked. */ void GC_check_tls(void) @@ -1170,8 +1165,6 @@ static void fork_child_proc(void) #ifdef INCLUDE_LINUX_THREAD_DESCR __thread int GC_dummy_thread_local; - GC_INNER GC_bool GC_enclosing_mapping(ptr_t addr, - ptr_t *startp, ptr_t *endp); #endif #ifdef PARALLEL_MARK @@ -1787,10 +1780,6 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread( } #if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2) - GC_INNER_PTHRSTART void * GC_CALLBACK GC_inner_start_routine( - struct GC_stack_base *sb, void *arg); - /* defined in pthread_start.c */ - STATIC void * GC_start_routine(void * arg) { # ifdef INCLUDE_LINUX_THREAD_DESCR diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 4a6624dd..66ea876a 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -141,11 +141,6 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p) # endif } -#ifdef GC_ASSERTIONS - /* Defined in pthread_support.c or win32_threads.c. */ - GC_bool GC_is_thread_tsd_valid(void *tsd); -#endif - GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_kind(size_t bytes, int knd) { size_t granules; diff --git a/win32_threads.c b/win32_threads.c index f8fa1449..ccf44c96 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2897,10 +2897,6 @@ GC_INNER void GC_init_parallel(void) } # if defined(GC_ASSERTIONS) - void GC_check_tls_for(GC_tlfs p); -# if defined(USE_CUSTOM_SPECIFIC) - void GC_check_tsd_marks(tsd *key); -# endif /* Check that all thread-local free-lists are completely marked. */ /* also check that thread-specific-data structures are marked. */ void GC_check_tls(void)