2009-10-18 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sun, 18 Oct 2009 10:47:44 +0000 (10:47 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:50 +0000 (21:06 +0400)
* allchblk.c (GC_fail_count, GC_large_alloc_warn_interval): Move
the variable declaration to gc_priv.h.
* alloc.c (GC_bytes_found, GC_unmap_threshold,
GC_force_unmap_on_gcollect): Ditto.
* dyn_load.c (GC_no_win32_dlls, GC_wnt): Ditto.
* finalize.c (GC_fail_count): Ditto.
* include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder,
GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Ditto.
* include/private/gc_pmark.h (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/pthread_support.h (GC_threads,
GC_thr_initialized, GC_in_thread_creation): Ditto.
* mallocx.c (GC_bytes_found): Ditto.
* mark_rts.c (GC_save_regs_ret_val, GC_world_stopped): Ditto.
* misc.c (GC_unmap_threshold): Ditto.
* os_dep.c (GC_unmap_threshold): 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_fault_handler_lock, GC_write_cs,
GC_dont_query_stack_min, GC_markers, GC_wnt): Ditto.
* include/private/gc_priv.h (GC_EXTERN): New macro (used mostly as
a tag for now); defined after "gcconfig.h" inclusion.
* include/private/gc_priv.h: Use GC_EXTERN instead of "extern"
keyword for most global variables.
* alloc.c (GC_copyright): Add the comment about the symbol
visibility.
* finalize.c (GC_fo_entries): Ditto.
* include/private/gc_priv.h (GC_print_stats): Ditto.
* misc.c (GC_quiet): Ditto.
* mallocx.c (GC_bytes_allocd_tmp): Make the volatile variable
STATIC.
* pthread_support.c (GC_threads): Add explicit zero initializer
(to make the variable definition differ from the declaration).

16 files changed:
ChangeLog
allchblk.c
alloc.c
dyn_load.c
finalize.c
include/private/gc_locks.h
include/private/gc_pmark.h
include/private/gc_priv.h
include/private/pthread_support.h
mallocx.c
mark_rts.c
misc.c
os_dep.c
pthread_support.c
thread_local_alloc.c
win32_threads.c

index c640691..8d9b737 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,43 @@
 2009-10-18  Ivan Maidanski <ivmai@mail.ru>
 
+       * allchblk.c (GC_fail_count, GC_large_alloc_warn_interval): Move
+       the variable declaration to gc_priv.h.
+       * alloc.c (GC_bytes_found, GC_unmap_threshold,
+       GC_force_unmap_on_gcollect): Ditto.
+       * dyn_load.c (GC_no_win32_dlls, GC_wnt): Ditto.
+       * finalize.c (GC_fail_count): Ditto.
+       * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder,
+       GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Ditto.
+       * include/private/gc_pmark.h (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/pthread_support.h (GC_threads,
+       GC_thr_initialized, GC_in_thread_creation): Ditto.
+       * mallocx.c (GC_bytes_found): Ditto.
+       * mark_rts.c (GC_save_regs_ret_val, GC_world_stopped): Ditto.
+       * misc.c (GC_unmap_threshold): Ditto.
+       * os_dep.c (GC_unmap_threshold): 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_fault_handler_lock, GC_write_cs,
+       GC_dont_query_stack_min, GC_markers, GC_wnt): Ditto.
+       * include/private/gc_priv.h (GC_EXTERN): New macro (used mostly as
+       a tag for now); defined after "gcconfig.h" inclusion.
+       * include/private/gc_priv.h: Use GC_EXTERN instead of "extern"
+       keyword for most global variables.
+       * alloc.c (GC_copyright): Add the comment about the symbol
+       visibility.
+       * finalize.c (GC_fo_entries): Ditto.
+       * include/private/gc_priv.h (GC_print_stats): Ditto.
+       * misc.c (GC_quiet): Ditto.
+       * mallocx.c (GC_bytes_allocd_tmp): Make the volatile variable
+       STATIC.
+       * pthread_support.c (GC_threads): Add explicit zero initializer
+       (to make the variable definition differ from the declaration).
+
+2009-10-18  Ivan Maidanski <ivmai@mail.ru>
+
        * backgraph.c (GC_quiet): Remove the declaration (not needed
        anymore since gc_priv.h is always included).
        * checksums.c (GC_quiet): Ditto.
index 03d494a..67a4be6 100644 (file)
@@ -628,10 +628,6 @@ GC_allochblk(size_t sz, int kind, unsigned flags/* IGNORE_OFF_PAGE or 0 */)
     return 0;
 }
 
-extern unsigned GC_fail_count; /* defined in alloc.c */
-
-extern long GC_large_alloc_warn_interval; /* defined in misc.c */
-
 STATIC long GC_large_alloc_warn_suppressed = 0;
                         /* Number of warnings suppressed so far.        */
 
diff --git a/alloc.c b/alloc.c
index 2ceed26..4542f24 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -81,6 +81,7 @@ STATIC GC_bool GC_need_full_gc = FALSE;
 
 STATIC word GC_used_heap_size_after_full = 0;
 
+/* GC_copyright symbol is externally visible. */
 char * const GC_copyright[] =
 {"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ",
 "Copyright (c) 1991-1995 by Xerox Corporation.  All rights reserved. ",
@@ -105,11 +106,6 @@ GC_API unsigned GC_CALL GC_get_version(void)
 
 /* some more variables */
 
-extern signed_word GC_bytes_found;
-                                /* Number of reclaimed bytes    */
-                                /* after garbage collection;    */
-                                /* defined in reclaim.c.        */
-
 #ifdef GC_DONT_EXPAND
   GC_bool GC_dont_expand = TRUE;
 #else
@@ -911,11 +907,6 @@ STATIC void GC_finish_collection(void)
 #   endif
 }
 
-#ifdef USE_MUNMAP
-    extern int GC_unmap_threshold;      /* defined in allchblk.c        */
-    extern GC_bool GC_force_unmap_on_gcollect;  /* defined in misc.c    */
-#endif
-
 /* If stop_func == 0 then GC_default_stop_func is used instead.         */
 STATIC GC_bool GC_try_to_collect_general(GC_stop_func stop_func,
                                          GC_bool force_unmap)
index f7587e6..d7acb2f 100644 (file)
@@ -828,20 +828,15 @@ void GC_register_dynamic_libraries(void)
     }
 # endif
 
+GC_bool GC_register_main_static_data(void)
+{
 # ifdef MSWINCE
     /* 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; /* defined in os_dep.c */
-
-    GC_bool GC_register_main_static_data(void)
-    {
-      return GC_no_win32_dlls;
-    }
-# endif /* win32 */
+    return FALSE;
+# else
+    return GC_no_win32_dlls;
+# endif
+}
 
 # define HAVE_REGISTER_MAIN_STATIC_DATA
 
@@ -866,9 +861,6 @@ void GC_register_dynamic_libraries(void)
     /* a "Data Abort" message to the debugging console).                */
     /* 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. */
 # endif
 
   void GC_register_dynamic_libraries(void)
index ceedad1..51ee3a2 100644 (file)
@@ -82,7 +82,7 @@ STATIC struct finalizable_object * GC_finalize_now = 0;
 
 static signed_word log_fo_table_size = -1;
 
-word GC_fo_entries = 0;
+word GC_fo_entries = 0; /* used also in extra/MacOS.c */
 
 void GC_push_finalizer_structures(void)
 {
@@ -491,10 +491,6 @@ void GC_dump_finalization(void)
   STATIC word GC_old_dl_entries = 0; /* for stats printing */
 #endif
 
-extern unsigned GC_fail_count;
-                        /* How many consecutive GC/expansion failures?  */
-                        /* Reset by GC_allochblk(); defined in alloc.c. */
-
 #ifdef THREADS
   /* Defined in pthread_support.c or win32_threads.c.  Called with the  */
   /* allocation lock held.                                              */
index d1eefd3..c8c593a 100644 (file)
@@ -36,7 +36,7 @@
 #  ifdef PCR
 #    include <base/PCR_Base.h>
 #    include <th/PCR_Th.h>
-     extern PCR_Th_ML GC_allocate_ml;
+     GC_EXTERN 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;
+     GC_EXTERN DWORD GC_lock_holder;
+     GC_EXTERN CRITICAL_SECTION GC_allocate_ml;
 #    ifdef GC_ASSERTIONS
 #        define UNCOND_LOCK() \
                 { EnterCriticalSection(&GC_allocate_ml); \
       /* 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;
+      GC_EXTERN 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.                                        */
 #    endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCK */
 #    ifdef USE_PTHREAD_LOCKS
 #      include <pthread.h>
-       extern pthread_mutex_t GC_allocate_ml;
+       GC_EXTERN pthread_mutex_t GC_allocate_ml;
 #      ifdef GC_ASSERTIONS
 #        define UNCOND_LOCK() \
                 { GC_lock(); \
                 (!GC_need_to_lock \
                  || GC_lock_holder != NUMERIC_THREAD_ID(pthread_self()))
 #    endif
-     extern volatile GC_bool GC_collecting;
+     GC_EXTERN volatile GC_bool GC_collecting;
 #    define ENTER_GC() GC_collecting = 1;
 #    define EXIT_GC() GC_collecting = 0;
      void GC_lock(void);
-     extern unsigned long GC_lock_holder;
+     GC_EXTERN unsigned long GC_lock_holder;
 #    ifdef GC_ASSERTIONS
-       extern unsigned long GC_mark_lock_holder;
+       GC_EXTERN unsigned long GC_mark_lock_holder;
 #    endif
 #  endif /* GC_PTHREADS with linux_threads.c implementation */
 
 # endif /* !THREADS */
 
 #if defined(UNCOND_LOCK) && !defined(LOCK)
-     extern GC_bool GC_need_to_lock;
+     GC_EXTERN 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(); }
index bad456b..12e3a24 100644 (file)
@@ -65,7 +65,7 @@ mark_proc GC_mark_procs[MAX_MARK_PROCS];
 # define MAX_ENV \
         (((word)1 << (WORDSZ - GC_DS_TAG_BITS - GC_LOG_MAX_MARK_PROCS)) - 1)
 
-extern unsigned GC_n_mark_procs;
+GC_EXTERN unsigned GC_n_mark_procs;
 
 /* Number of mark stack entries to discard on overflow. */
 #define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8)
@@ -76,17 +76,17 @@ typedef struct GC_ms_entry {
                         /* as described in gc_mark.h.                   */
 } mse;
 
-extern size_t GC_mark_stack_size;
+GC_EXTERN size_t GC_mark_stack_size;
 
-extern mse * GC_mark_stack_limit;
+GC_EXTERN mse * GC_mark_stack_limit;
 
 #ifdef PARALLEL_MARK
-  extern mse * volatile GC_mark_stack_top;
+  GC_EXTERN mse * volatile GC_mark_stack_top;
 #else
-  extern mse * GC_mark_stack_top;
+  GC_EXTERN mse * GC_mark_stack_top;
 #endif
 
-extern mse * GC_mark_stack;
+GC_EXTERN mse * GC_mark_stack;
 
 #ifdef PARALLEL_MARK
     /*
@@ -450,7 +450,7 @@ mse * GC_mark_from(mse * top, mse * bottom, mse *limit);
     } \
 }
 
-extern GC_bool GC_mark_stack_too_small;
+GC_EXTERN GC_bool GC_mark_stack_too_small;
                                 /* We need a larger mark stack.  May be */
                                 /* set by client supplied mark routines.*/
 
@@ -494,6 +494,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;
+GC_EXTERN mark_state_t GC_mark_state;
 
 #endif  /* GC_PMARK_H */
index 0ea0cd1..5ca40ae 100644 (file)
@@ -15,7 +15,6 @@
  * modified is included with the above copyright notice.
  */
 
-
 # ifndef GC_PRIVATE_H
 # define GC_PRIVATE_H
 
@@ -76,13 +75,34 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
                         /* byte displacements and which can be used     */
                         /* for address comparisons.                     */
 
-# ifndef GCCONFIG_H
-#   include "gcconfig.h"
-# endif
+#ifndef GCCONFIG_H
+# include "gcconfig.h"
+#endif
 
-# ifndef HEADERS_H
-#   include "gc_hdrs.h"
+#ifndef GC_EXTERN
+  /* Used only for the GC-scope variables (prefixed with "GC_")         */
+  /* declared in the header files.  Must not be used for thread-local   */
+  /* variables.  Must not be used in gcconfig.h.  Shouldn't be used for */
+  /* the debugging-only or profiling-only variables.  Currently, not    */
+  /* used for the variables accessed from the "dated" source files      */
+  /* (pcr_interface.c, specific.c/h, and in the "extra" folder).        */
+# if defined(GC_DLL) && defined(__GNUC__) && !defined(MSWIN32) \
+        && !defined(MSWINCE)
+#   if __GNUC__ >= 4
+      /* See the corresponding GC_API definition. */
+#     define GC_EXTERN extern __attribute__((__visibility__("hidden")))
+#   else
+      /* The attribute is unsupported. */
+#     define GC_EXTERN extern
+#   endif
+# else
+#   define GC_EXTERN extern
 # endif
+#endif
+
+#ifndef HEADERS_H
+# include "gc_hdrs.h"
+#endif
 
 #if __GNUC__ >= 3
 # define EXPECT(expr, outcome) __builtin_expect(expr,outcome)
@@ -376,8 +396,9 @@ void GC_print_callers(struct callinfo info[NFRAMES]);
 # endif
 
 /* 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;
+#define WARN(msg, arg) (*GC_current_warn_proc)("GC Warning: " msg, \
+                                               (GC_word)(arg))
+GC_EXTERN 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 +1201,7 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays;
 /* Object kinds: */
 # define MAXOBJKINDS 16
 
-extern struct obj_kind {
+GC_EXTERN 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.                            */
@@ -1206,14 +1227,14 @@ extern struct obj_kind {
 /* introduce maintenance problems.                                      */
 
 #ifdef SEPARATE_GLOBALS
-  extern word GC_bytes_allocd;
+  GC_EXTERN word GC_bytes_allocd;
         /* Number of words allocated during this collection cycle */
-  extern ptr_t GC_objfreelist[MAXOBJGRANULES+1];
+  GC_EXTERN ptr_t GC_objfreelist[MAXOBJGRANULES+1];
                           /* free list for NORMAL objects */
 # define beginGC_objfreelist ((ptr_t)(&GC_objfreelist))
 # define endGC_objfreelist (beginGC_objfreelist + sizeof(GC_objfreelist))
 
-  extern ptr_t GC_aobjfreelist[MAXOBJGRANULES+1];
+  GC_EXTERN ptr_t GC_aobjfreelist[MAXOBJGRANULES+1];
                           /* free list for atomic (PTRFREE) objs        */
 # define beginGC_aobjfreelist ((ptr_t)(&GC_aobjfreelist))
 # define endGC_aobjfreelist (beginGC_aobjfreelist + sizeof(GC_aobjfreelist))
@@ -1232,37 +1253,35 @@ extern struct obj_kind {
 #   define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE)
 # endif
 
-extern unsigned GC_n_kinds;
-
-extern word GC_fo_entries;
+GC_EXTERN unsigned GC_n_kinds;
 
-extern word GC_n_heap_sects;    /* Number of separately added heap      */
+GC_EXTERN 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   */
+  GC_EXTERN word GC_n_memory;   /* Number of GET_MEM allocated memory   */
                                 /* sections.                            */
 #endif
 
-extern word GC_page_size;
+GC_EXTERN word GC_page_size;
 
 #if defined(MSWIN32) || defined(MSWINCE)
   struct _SYSTEM_INFO;
-  extern struct _SYSTEM_INFO GC_sysinfo;
+  GC_EXTERN struct _SYSTEM_INFO GC_sysinfo;
 #endif
 
-extern word GC_black_list_spacing;
+GC_EXTERN 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 GC_bool GC_objects_are_marked;   /* There are marked objects in  */
-                                        /* the heap.                    */
+GC_EXTERN GC_bool GC_objects_are_marked; /* There are marked objects in */
+                                         /* the heap.                   */
 
 #ifndef SMALL_CONFIG
-  extern GC_bool GC_incremental;
+  GC_EXTERN GC_bool GC_incremental;
                         /* Using incremental/generational collection. */
 # define TRUE_INCREMENTAL \
         (GC_incremental && GC_time_limit != GC_TIME_UNLIMITED)
@@ -1273,14 +1292,15 @@ extern GC_bool GC_objects_are_marked;   /* There are marked objects in  */
 # define TRUE_INCREMENTAL FALSE
 #endif
 
-extern GC_bool GC_dirty_maintained;
+GC_EXTERN 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.    */
+GC_EXTERN word GC_root_size; /* Total size of registered root sections. */
 
-extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called */
+GC_EXTERN GC_bool GC_debugging_started;
+                                /* GC_debug_malloc has been called.     */
 
 /* This is used by GC_do_blocking[_inner]().            */
 struct blocking_data {
@@ -1304,8 +1324,8 @@ struct GC_activation_frame_s {
   void GC_push_all_stack_frames(ptr_t lo, ptr_t hi,
                         struct GC_activation_frame_s *activation_frame);
 #else
-  extern ptr_t GC_blocked_sp;
-  extern struct GC_activation_frame_s *GC_activation_frame;
+  GC_EXTERN ptr_t GC_blocked_sp;
+  GC_EXTERN 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.              */
@@ -1439,7 +1459,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);
+GC_EXTERN 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          */
@@ -1451,7 +1471,7 @@ void GC_push_finalizer_structures(void);
 #ifdef THREADS
   void GC_push_thread_structures(void);
 #endif
-extern void (*GC_push_typed_structures)(void);
+GC_EXTERN void (*GC_push_typed_structures)(void);
                         /* A pointer such that we can avoid linking in  */
                         /* the typed allocation support if unused.      */
 
@@ -1677,7 +1697,7 @@ GC_bool GC_try_to_collect_inner(GC_stop_func f);
 # define GC_gcollect_inner() \
         (void) GC_try_to_collect_inner(GC_never_stop_func)
 
-extern GC_bool GC_is_initialized; /* GC_init() has been run. */
+GC_EXTERN GC_bool GC_is_initialized; /* GC_init() has been run. */
 
 #if defined(MSWIN32) || defined(MSWINCE)
   void GC_deinit(void);
@@ -1796,17 +1816,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);
+GC_EXTERN 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);
+GC_EXTERN void (*GC_print_all_smashed)(void);
                         /* Print GC_smashed if it's not empty.          */
                         /* Clear GC_smashed list.                       */
 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);
+GC_EXTERN 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.                            */
@@ -1815,33 +1835,35 @@ 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.   */
-                                /* Call error printing routine          */
-                                /* occasionally.                        */
+GC_EXTERN GC_bool GC_have_errors; /* We saw a smashed or leaked object. */
+                                  /* Call error printing routine        */
+                                  /* occasionally.                      */
 
 #ifndef SMALL_CONFIG
+  /* GC_print_stats should be visible outside the GC in some cases.     */
   extern 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 remove the message character strings from the executable? */
+  /* With a particular level of optimizations, it should...              */
 #endif
 #define VERBOSE 2
 
 #ifndef NO_DEBUGGING
-  extern GC_bool GC_dump_regularly; /* Generate regular debugging dumps */
+  GC_EXTERN 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;
+  GC_EXTERN long GC_backtraces;
   void GC_generate_random_backtrace_no_gc(void);
 #endif
 
-extern GC_bool GC_print_back_height;
+GC_EXTERN GC_bool GC_print_back_height;
 
 #ifdef MAKE_BACK_GRAPH
   void GC_print_back_graph_stats(void);
@@ -1969,6 +1991,55 @@ void GC_err_puts(const char *s);
                         /* newlines, don't ...                          */
 #endif
 
+GC_EXTERN unsigned GC_fail_count;
+                        /* How many consecutive GC/expansion failures?  */
+                        /* Reset by GC_allochblk(); defined in alloc.c. */
+
+GC_EXTERN long GC_large_alloc_warn_interval; /* defined in misc.c */
+
+GC_EXTERN signed_word GC_bytes_found;
+                /* Number of reclaimed bytes after garbage collection;  */
+                /* protected by GC lock; defined in reclaim.c.          */
+
+#ifdef USE_MUNMAP
+  GC_EXTERN int GC_unmap_threshold; /* defined in allchblk.c */
+  GC_EXTERN GC_bool GC_force_unmap_on_gcollect; /* defined in misc.c */
+#endif
+
+#ifdef MSWIN32
+  GC_EXTERN GC_bool GC_no_win32_dlls; /* defined in os_dep.c */
+  GC_EXTERN GC_bool GC_wnt;     /* Is Windows NT derivative;    */
+                                /* defined and set in os_dep.c. */
+#endif
+
+#ifdef THREADS
+  GC_EXTERN long GC_markers;    /* Number of mark threads we would like */
+                                /* to have.  Includes the initiating    */
+                                /* thread.  Defined in mark.c.          */
+# if defined(MSWIN32) || defined(MSWINCE)
+    GC_EXTERN CRITICAL_SECTION GC_write_cs; /* defined in misc.c */
+# endif
+# ifdef MPROTECT_VDB
+    GC_EXTERN volatile AO_TS_t GC_fault_handler_lock;
+                                        /* defined in os_dep.c */
+# endif
+# ifdef MSWINCE
+    GC_EXTERN GC_bool GC_dont_query_stack_min;
+                                /* Defined and set in os_dep.c.         */
+# endif
+#elif defined(IA64)
+  GC_EXTERN ptr_t GC_save_regs_ret_val; /* defined in mach_dep.c. */
+                        /* Previously set to backing store pointer.     */
+#endif /* !THREADS */
+
+#ifdef THREAD_LOCAL_ALLOC
+  GC_EXTERN GC_bool GC_world_stopped; /* defined in alloc.c */
+#endif
+
+#ifdef GC_GCJ_SUPPORT
+  GC_EXTERN GC_bool GC_gcj_malloc_initialized; /* defined in gcj_mlc.c */
+  GC_EXTERN ptr_t * GC_gcjobjfreelist;
+#endif
 
 # ifdef GC_ASSERTIONS
 #       define GC_ASSERT(expr) if(!(expr)) {\
@@ -2011,11 +2082,11 @@ 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.      */
+     GC_EXTERN 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.      */
+     GC_EXTERN word GC_mark_no;            /* Protected by mark lock.   */
 
      void GC_help_marker(word my_mark_no);
                 /* Try to help out parallel marker for mark cycle       */
index 1d75f3e..7ffcb08 100644 (file)
@@ -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];
+GC_EXTERN volatile GC_thread GC_threads[THREAD_TABLE_SZ];
 
-extern GC_bool GC_thr_initialized;
+GC_EXTERN 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_EXTERN 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.            */
index 64bea04..3a9e49f 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -234,11 +234,8 @@ 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; defined in reclaim.c.  */
-
-#ifdef PARALLEL_MARK
-volatile signed_word GC_bytes_allocd_tmp = 0;
+# ifdef PARALLEL_MARK
+    STATIC volatile signed_word GC_bytes_allocd_tmp = 0;
                         /* Number of bytes of memory allocated since    */
                         /* we released the GC lock.  Instead of         */
                         /* reacquiring the GC lock just to add this in, */
@@ -246,8 +243,8 @@ volatile signed_word GC_bytes_allocd_tmp = 0;
                         /* the lock.  (Atomically adding it doesn't     */
                         /* work, since we would have to atomically      */
                         /* update it in GC_malloc, which is too         */
-                        /* expensive.)                                   */
-#endif /* PARALLEL_MARK */
+                        /* expensive.)                                  */
+# endif /* PARALLEL_MARK */
 
 /* Return a list of 1 or more objects of the indicated size, linked     */
 /* through the first word in the object.  This has the advantage that   */
index 69f7fdb..8a55e37 100644 (file)
@@ -606,11 +606,6 @@ STATIC void GC_push_all_stack_part_eager_frames(ptr_t lo, ptr_t hi,
 #   endif
 }
 
-# ifdef IA64
-    extern ptr_t GC_save_regs_ret_val; /* defined in mach_dep.c. */
-                        /* Previously set to backing store pointer.     */
-# endif
-
 #endif /* !THREADS */
 
                         /* Push enough of the current stack eagerly to  */
@@ -715,10 +710,6 @@ 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
-  extern 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.
diff --git a/misc.c b/misc.c
index d7bb80d..d808dbb 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -83,7 +83,7 @@ GC_bool GC_dont_gc = 0;
 
 GC_bool GC_dont_precollect = 0;
 
-GC_bool GC_quiet = 0;
+GC_bool GC_quiet = 0; /* used also in pcr_interface.c */
 
 #ifndef SMALL_CONFIG
   GC_bool GC_print_stats = 0;
@@ -508,10 +508,6 @@ static void maybe_install_looping_handler(void)
   void GC_thr_init(void);
 #endif
 
-#ifdef USE_MUNMAP
-  extern int GC_unmap_threshold; /* defined in allchblk.c */
-#endif
-
 #ifdef LINT
   int GC_read(void);
   void GC_register_finalizer_no_order(void);
index ea266e6..9ec5e68 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1418,10 +1418,6 @@ void GC_register_data_segments(void)
   GC_bool GC_wnt = FALSE;
          /* 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 */
-# endif
-
   void GC_init_win32(void)
   {
     /* Set GC_wnt.                                                       */
index c894401..b4ec1a1 100644 (file)
@@ -317,10 +317,6 @@ STATIC void * GC_mark_thread(void * id)
   }
 }
 
-extern long GC_markers; /* Number of mark threads we would like to      */
-                        /* have.  Includes the initiating thread.       */
-                        /* Defined in mark.c.                           */
-
 STATIC pthread_t GC_mark_threads[MAX_MARKERS];
 
 #define PTHREAD_CREATE REAL_FUNC(pthread_create)
@@ -373,7 +369,7 @@ static void start_mark_threads(void)
 
 GC_bool GC_thr_initialized = FALSE;
 
-volatile GC_thread GC_threads[THREAD_TABLE_SZ];
+volatile GC_thread GC_threads[THREAD_TABLE_SZ] = {0};
 
 void GC_push_thread_structures(void)
 {
@@ -1463,7 +1459,6 @@ STATIC void GC_generic_lock(pthread_mutex_t * lock)
 
 volatile AO_TS_t GC_allocate_lock = 0;
 
-
 void GC_lock(void)
 {
 #   define low_spin_max 30  /* spin cycles if we suspect uniprocessor */
index 3a145cd..4ef1769 100644 (file)
@@ -110,10 +110,6 @@ void GC_init_thread_local(GC_tlfs p)
 #   endif
 }
 
-#ifdef GC_GCJ_SUPPORT
-  extern ptr_t * GC_gcjobjfreelist; /* defined in gcj_mlc.c. */
-#endif
-
 /* We hold the allocator lock.  */
 void GC_destroy_thread_local(GC_tlfs p)
 {
@@ -207,12 +203,6 @@ 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; /* defined in gcj_mlc.c.    */
-#endif
-
-extern 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   */
 /* has freelist links instead of "vtable" pointers.  That is usually    */
index 47b3724..49dc4e9 100644 (file)
@@ -918,7 +918,6 @@ void GC_push_thread_structures(void)
 
 #if defined(MPROTECT_VDB)
 # include "atomic_ops.h"
-  extern volatile AO_TS_t GC_fault_handler_lock; /* defined in os_dep.c */
 #endif
 
 /* Suspend the given thread, if it's still active.      */
@@ -970,10 +969,6 @@ STATIC void GC_suspend(GC_thread t)
 # endif
 }
 
-#ifndef CYGWIN32
-  extern CRITICAL_SECTION GC_write_cs; /* defined in misc.c */
-#endif
-
 void GC_stop_world(void)
 {
   DWORD thread_id = GetCurrentThreadId();
@@ -1072,9 +1067,6 @@ void GC_start_world(void)
 }
 
 #ifdef MSWINCE
-  extern GC_bool GC_dont_query_stack_min;
-                                /* Defined and set in os_dep.c.         */
-
   /* The VirtualQuery calls below won't work properly on some old WinCE */
   /* versions, but since each stack is restricted to an aligned 64 KiB  */
   /* region of virtual memory we can just take the next lowest multiple */
@@ -1322,11 +1314,6 @@ void GC_push_all_stacks(void)
 #   define MAX_MARKERS 16
 # endif
 
-  extern 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.              */
 # ifdef IA64
@@ -1935,10 +1922,6 @@ void GC_get_next_stack(char *start, char *limit,
 
 #   endif /* !DONT_USE_SIGNALANDWAIT */
 
-#   ifndef MSWINCE
-      extern GC_bool GC_wnt; /* defined in os_dep.c */
-#   endif
-
 # endif /* ! GC_PTHREADS_PARAMARK */
 
 #endif /* PARALLEL_MARK */