]> granicus.if.org Git - gc/commitdiff
Declare all internal functions in private headers instead of .c files
authorIvan Maidanski <ivmai@mail.ru>
Wed, 28 Feb 2018 06:12:54 +0000 (09:12 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 28 Feb 2018 06:12:54 +0000 (09:12 +0300)
(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.

include/private/darwin_stop_world.h
include/private/gc_priv.h
include/private/pthread_support.h
include/private/thread_local_alloc.h
malloc.c
mark.c
mark_rts.c
os_dep.c
pthread_support.c
thread_local_alloc.c
win32_threads.c

index 8f69d9d085feb8f3fce218187dfa699f11670657..ca8ef9edadf14dfc91354e8db0bc97d7d38140aa 100644 (file)
@@ -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)
index 2062cc039fcad337d70c3ff8dc7c1ab34a804ffb..393aec525c1bdf7a13a7eff8d6f7ac4c5e923b5a 100644 (file)
@@ -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
 
index c9f9976127561d88f16517f7a1b47c25d5f27558..57a6cd90606a1a177ef2dc2f621562138dedb037 100644 (file)
@@ -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,
index 16fc555e59e150b32226f550e4bc33c6567ddcfb..268e3ec2e7c0fc2e28176625fac201bab07ab685 100644 (file)
@@ -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
index 0155fa5a8780de2a2fece9026a52adfe22ec3d94..df73485219ace3da0376aa55e5d25a21df9cb185 100644 (file)
--- 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 8347bfc52fc6a1b0c5439c586245fa68a4151810..d8b69e5f845114354c5855e2cf96166a5fcb0d01 100644 (file)
--- 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;
index 3f0b6f16b4263566dbb7db4a94429b8f60001eb3..6e297abd23a6ce70e9ba38229ab067cf7eb99f6a 100644 (file)
@@ -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-  */
index ea887728428c49f08e54673152a00ed24c38181e..f7369ac26138e95d5e8deb2e2a63148f29c018f1 100644 (file)
--- 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 <errno.h>
 #   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
index f42b5dff4a549ee557a6d31fdc9da2da3e7a96be..7705e1f1cfbe86395e6928481287c5134633b12b 100644 (file)
@@ -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
index 4a6624ddb338dc1dab65e54f8ce9946a928af4f2..66ea876a5fb267218abd9faa28565b8474902602 100644 (file)
@@ -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;
index f8fa1449e40f2dbae6e32a4b78de28a4957ebd8e..ccf44c969fb2ca00ad7b328d3deae931c92e86aa 100644 (file)
@@ -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)