From: ivmai Date: Sun, 27 Sep 2009 21:19:59 +0000 (+0000) Subject: 2009-09-27 Ivan Maidanski X-Git-Tag: gc7_2alpha4~81 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6084d4dc6dc87c854824e5bfb982e8c8cd5229b;p=gc 2009-09-27 Ivan Maidanski * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder, GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Use "extern" (for the global variable declaration) again. * 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/gcconfig.h (GC_register_stackbottom): Ditto. * include/private/pthread_support.h (GC_threads, GC_thr_initialized, GC_in_thread_creation): Ditto. * include/private/gc_priv.h: Ditto (for all global variables). --- diff --git a/ChangeLog b/ChangeLog index 3f677e73..bb48a3e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-09-27 Ivan Maidanski + + * include/private/gc_locks.h (GC_allocate_ml, GC_lock_holder, + GC_collecting, GC_mark_lock_holder, GC_need_to_lock): Use "extern" + (for the global variable declaration) again. + * 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/gcconfig.h (GC_register_stackbottom): Ditto. + * include/private/pthread_support.h (GC_threads, + GC_thr_initialized, GC_in_thread_creation): Ditto. + * include/private/gc_priv.h: Ditto (for all global variables). + 2009-09-27 Ivan Maidanski * real_malloc.c: Include private/config.h if HAVE_CONFIG_H. diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index d3bd193b..d1eefd3c 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -36,7 +36,7 @@ # ifdef PCR # include # include - PCR_Th_ML GC_allocate_ml; + 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 # define NO_THREAD (DWORD)(-1) - DWORD GC_lock_holder; - CRITICAL_SECTION GC_allocate_ml; + extern DWORD GC_lock_holder; + extern CRITICAL_SECTION GC_allocate_ml; # ifdef GC_ASSERTIONS # define UNCOND_LOCK() \ { EnterCriticalSection(&GC_allocate_ml); \ @@ -114,7 +114,7 @@ /* and sleeping for fixed periods are likely to result in */ /* significant wasted time. We thus rely mostly on queued locks. */ # define USE_SPIN_LOCK - volatile AO_TS_t GC_allocate_lock; + 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. */ @@ -140,7 +140,7 @@ # endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCK */ # ifdef USE_PTHREAD_LOCKS # include - pthread_mutex_t GC_allocate_ml; + extern 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 - volatile GC_bool GC_collecting; + extern volatile GC_bool GC_collecting; # define ENTER_GC() GC_collecting = 1; # define EXIT_GC() GC_collecting = 0; void GC_lock(void); - unsigned long GC_lock_holder; + extern unsigned long GC_lock_holder; # ifdef GC_ASSERTIONS - unsigned long GC_mark_lock_holder; + extern 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) - GC_bool GC_need_to_lock; + 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(); } diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 4f4f4ce4..31b5340f 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -65,8 +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) - -unsigned GC_n_mark_procs; +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) @@ -77,17 +76,17 @@ typedef struct GC_ms_entry { /* as described in gc_mark.h. */ } mse; -size_t GC_mark_stack_size; +extern size_t GC_mark_stack_size; -mse * GC_mark_stack_limit; +extern mse * GC_mark_stack_limit; #ifdef PARALLEL_MARK - mse * volatile GC_mark_stack_top; + extern mse * volatile GC_mark_stack_top; #else - mse * GC_mark_stack_top; + extern mse * GC_mark_stack_top; #endif -mse * GC_mark_stack; +extern mse * GC_mark_stack; #ifdef PARALLEL_MARK /* @@ -451,7 +450,7 @@ mse * GC_mark_from(mse * top, mse * bottom, mse *limit); } \ } -GC_bool GC_mark_stack_too_small; +extern GC_bool GC_mark_stack_too_small; /* We need a larger mark stack. May be */ /* set by client supplied mark routines.*/ @@ -495,6 +494,6 @@ typedef int mark_state_t; /* Current state of marking, as follows:*/ # define MS_INVALID 5 /* I may not hold. */ -mark_state_t GC_mark_state; +extern 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 8b64f7f6..4e9dbdb1 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)) -GC_warn_proc GC_current_warn_proc; +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 +1180,7 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays; /* Object kinds: */ # define MAXOBJKINDS 16 -struct obj_kind { +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 +1206,14 @@ struct obj_kind { /* introduce maintenance problems. */ #ifdef SEPARATE_GLOBALS - word GC_bytes_allocd; + extern word GC_bytes_allocd; /* Number of words allocated during this collection cycle */ - ptr_t GC_objfreelist[MAXOBJGRANULES+1]; + 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)) - ptr_t GC_aobjfreelist[MAXOBJGRANULES+1]; + 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 +1232,37 @@ struct obj_kind { # define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE) # endif -unsigned GC_n_kinds; +extern unsigned GC_n_kinds; -word GC_fo_entries; +extern word GC_fo_entries; -word GC_n_heap_sects; /* Number of separately added heap */ +extern word GC_n_heap_sects; /* Number of separately added heap */ /* sections. */ #ifdef USE_PROC_FOR_LIBRARIES - word GC_n_memory; /* Number of GET_MEM allocated memory */ + extern word GC_n_memory; /* Number of GET_MEM allocated memory */ /* sections. */ #endif -word GC_page_size; +extern word GC_page_size; #if defined(MSWIN32) || defined(MSWINCE) struct _SYSTEM_INFO; - struct _SYSTEM_INFO GC_sysinfo; + extern struct _SYSTEM_INFO GC_sysinfo; #endif -word GC_black_list_spacing; +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. */ -GC_bool GC_objects_are_marked; /* There are marked objects in */ +extern GC_bool GC_objects_are_marked; /* There are marked objects in */ /* the heap. */ #ifndef SMALL_CONFIG - GC_bool GC_incremental; + extern GC_bool GC_incremental; /* Using incremental/generational collection. */ # define TRUE_INCREMENTAL \ (GC_incremental && GC_time_limit != GC_TIME_UNLIMITED) @@ -1273,19 +1273,19 @@ GC_bool GC_objects_are_marked; /* There are marked objects in */ # define TRUE_INCREMENTAL FALSE #endif -GC_bool GC_dirty_maintained; +extern GC_bool GC_dirty_maintained; /* Dirty bits are being maintained, */ /* either for incremental collection, */ /* or to limit the root set. */ -word GC_root_size; /* Total size of registered root sections. */ +extern word GC_root_size; /* Total size of registered root sections. */ -GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ +extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called */ -long GC_large_alloc_warn_interval; +extern long GC_large_alloc_warn_interval; /* Interval between unsuppressed warnings. */ -long GC_large_alloc_warn_suppressed; +extern long GC_large_alloc_warn_suppressed; /* Number of warnings suppressed so far. */ /* This is used by GC_do_blocking[_inner](). */ @@ -1310,8 +1310,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 - ptr_t GC_blocked_sp; - struct GC_activation_frame_s *GC_activation_frame; + extern ptr_t GC_blocked_sp; + 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. */ @@ -1384,7 +1384,7 @@ ptr_t GC_approx_sp(void); GC_bool GC_should_collect(void); -void GC_apply_to_all_blocks(void (*fn) (struct hblk *h, word client_data), +void GC_apply_to_all_blocks(void (*fn)(struct hblk *h, word client_data), word client_data); /* Invoke fn(hbp, client_data) for each */ /* allocated heap block. */ @@ -1395,7 +1395,7 @@ struct hblk * GC_prev_block(struct hblk * h); /* is managed by GC, but may or may not be in */ /* use. */ void GC_mark_init(void); -void GC_clear_marks(void); /* Clear mark bits for all heap objects. */ +void GC_clear_marks(void); /* Clear mark bits for all heap objects. */ void GC_invalidate_mark_state(void); /* Tell the marker that marked */ /* objects may point to unmarked */ @@ -1418,20 +1418,20 @@ void GC_push_all(ptr_t bottom, ptr_t top); /* onto mark stack. */ void GC_push_selected(ptr_t bottom, ptr_t top, int (*dirty_fn) (struct hblk *h), - void (*push_fn) (ptr_t bottom, ptr_t top) ); + void (*push_fn) (ptr_t bottom, ptr_t top)); /* Push all pages h in [b,t) s.t. */ /* select_fn(h) != 0 onto mark stack. */ #ifndef SMALL_CONFIG - void GC_push_conditional (ptr_t b, ptr_t t, GC_bool all); + void GC_push_conditional(ptr_t b, ptr_t t, GC_bool all); #else # define GC_push_conditional(b, t, all) GC_push_all(b, t) #endif /* Do either of the above, depending */ /* on the third arg. */ -void GC_push_all_stack (ptr_t b, ptr_t t); +void GC_push_all_stack(ptr_t b, ptr_t t); /* As above, but consider */ /* interior pointers as valid */ -void GC_push_all_eager (ptr_t b, ptr_t t); +void GC_push_all_eager(ptr_t b, ptr_t t); /* Same as GC_push_all_stack, but */ /* ensures that stack is scanned */ /* immediately, not just scheduled */ @@ -1445,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. */ -void (*GC_push_other_roots)(void); +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 */ @@ -1457,10 +1457,10 @@ void GC_push_finalizer_structures(void); #ifdef THREADS void GC_push_thread_structures(void); #endif -void (*GC_push_typed_structures)(void); +extern void (*GC_push_typed_structures)(void); /* A pointer such that we can avoid linking in */ /* the typed allocation support if unused. */ -void (*GC_start_call_back)(void); +extern void (*GC_start_call_back)(void); /* Called at start of full collections. */ /* Not called if 0. Called with allocation */ /* lock held. */ @@ -1468,8 +1468,7 @@ void (*GC_start_call_back)(void); void GC_push_regs(void); -void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), - ptr_t arg); +void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), ptr_t arg); # if defined(SPARC) || defined(IA64) /* Cause all stacked registers to be saved in memory. Return a */ @@ -1539,7 +1538,7 @@ GC_bool GC_register_main_static_data(void); /* dynamic library registration. */ /* Machine dependent startup routines */ -ptr_t GC_get_main_stack_base(void); /* Cold end of stack */ +ptr_t GC_get_main_stack_base(void); /* Cold end of stack. */ #ifdef IA64 ptr_t GC_get_register_stack_base(void); /* Cold end of register stack. */ @@ -1626,13 +1625,12 @@ ptr_t GC_build_fl(struct hblk *h, size_t words, GC_bool clear, ptr_t list); /* called by GC_new_hblk, but also */ /* called explicitly without GC lock. */ -struct hblk * GC_allochblk (size_t size_in_bytes, int kind, - unsigned flags); +struct hblk * GC_allochblk(size_t size_in_bytes, int kind, unsigned flags); /* Allocate a heap block, inform */ /* the marker that block is valid */ /* for objects of indicated size. */ -ptr_t GC_alloc_large (size_t lb, int k, unsigned flags); +ptr_t GC_alloc_large(size_t lb, int k, unsigned flags); /* Allocate a large block of size lb bytes. */ /* The block is not cleared. */ /* Flags is 0 or IGNORE_OFF_PAGE. */ @@ -1696,7 +1694,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. */ -GC_bool GC_is_initialized; /* GC_init() has been run. */ +extern GC_bool GC_is_initialized; /* GC_init() has been run. */ #if defined(MSWIN32) || defined(MSWINCE) void GC_deinit(void); @@ -1778,7 +1776,7 @@ void GC_remove_header(struct hblk * h); /* Remove the header for block h. */ void GC_remove_counts(struct hblk * h, size_t sz); /* Remove forwarding counts for h. */ -hdr * GC_find_header(ptr_t h); /* Debugging only. */ +hdr * GC_find_header(ptr_t h); /* Debugging only. */ void GC_finalize(void); /* Perform all indicated finalization actions */ @@ -1815,31 +1813,31 @@ 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. */ -void (*GC_check_heap)(void); +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. */ -void (*GC_print_all_smashed)(void); +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. */ -void (*GC_print_heap_obj)(ptr_t p); +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. */ #if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG) - void GC_print_address_map (void); + void GC_print_address_map(void); /* Print an address map of the process. */ #endif -GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ +extern GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ /* Call error printing routine */ /* occasionally. */ #ifndef SMALL_CONFIG - int GC_print_stats; /* Nonzero generates basic GC log. */ + extern int GC_print_stats; /* Nonzero generates basic GC log. */ /* VERBOSE generates add'l messages. */ #else # define GC_print_stats 0 @@ -1849,18 +1847,18 @@ GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ #define VERBOSE 2 #ifndef NO_DEBUGGING - GC_bool GC_dump_regularly; /* Generate regular debugging dumps. */ + 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 - long GC_backtraces; + extern long GC_backtraces; void GC_generate_random_backtrace_no_gc(void); #endif -GC_bool GC_print_back_height; +extern GC_bool GC_print_back_height; #ifdef MAKE_BACK_GRAPH void GC_print_back_graph_stats(void); @@ -1907,8 +1905,7 @@ GC_bool GC_page_was_dirty(struct hblk *h); /* Read retrieved dirty bits. */ GC_bool GC_page_was_ever_dirty(struct hblk *h); /* Could the page contain valid heap pointers? */ -void GC_remove_protection(struct hblk *h, word nblocks, - GC_bool pointerfree); +void GC_remove_protection(struct hblk *h, word nblocks, GC_bool pointerfree); /* h is about to be written or allocated. Ensure */ /* that it's not write protected by the virtual */ /* dirty bit implementation. */ @@ -1921,7 +1918,7 @@ void GC_clear_mark_bit(ptr_t p); void GC_set_mark_bit(ptr_t p); /* Stubborn objects: */ -void GC_read_changed(void); /* Analogous to GC_read_dirty */ +void GC_read_changed(void); /* Analogous to GC_read_dirty */ GC_bool GC_page_was_changed(struct hblk * h); /* Analogous to GC_page_was_dirty */ void GC_clean_changing_list(void); @@ -2031,11 +2028,11 @@ void GC_err_puts(const char *s); void GC_notify_all_builder(void); void GC_wait_for_reclaim(void); - word GC_fl_builder_count; /* Protected by mark lock. */ + extern word GC_fl_builder_count; /* Protected by mark lock. */ void GC_notify_all_marker(void); void GC_wait_marker(void); - word GC_mark_no; /* Protected by mark lock. */ + 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 */ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 5dacf216..d582255d 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -1599,7 +1599,7 @@ /* address minus one page. */ # define BACKING_STORE_DISPLACEMENT 0x1000000 # define BACKING_STORE_ALIGNMENT 0x1000 - ptr_t GC_register_stackbottom; + extern 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 - ptr_t GC_register_stackbottom; + extern ptr_t GC_register_stackbottom; # define BACKING_STORE_BASE GC_register_stackbottom # define SEARCH_FOR_DATA_START # ifdef __GNUC__ @@ -1647,7 +1647,7 @@ __lfetch(__lfhint_nta, (x)) # define CLEAR_DOUBLE(x) \ __stf_spill((void *)(x), 0) -# endif // __INTEL_COMPILER +# endif /* __INTEL_COMPILER */ # endif # endif # ifdef MSWIN32 diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h index be97ad39..1d75f3e6 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 */ -volatile GC_thread GC_threads[THREAD_TABLE_SZ]; +extern volatile GC_thread GC_threads[THREAD_TABLE_SZ]; -GC_bool GC_thr_initialized; +extern GC_bool GC_thr_initialized; GC_thread GC_lookup_thread(pthread_t id); void GC_stop_init(void); -GC_bool GC_in_thread_creation; +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. */