* alloc.c (GC_copyright): Define as const.
* alloc.c (GC_collect_at_heapsize): Replace "static" with "STATIC"
(since the name starts with "GC_" prefix).
* dbg_mlc.c (GC_describe_type_fns): Ditto.
* dyn_load.c (GC_FirstDLOpenedLinkMap,
GC_register_dynlib_callback, GC_dyld_sections,
GC_dyld_name_for_hdr, GC_dyld_image_add, GC_dyld_image_remove):
Ditto.
* malloc.c (GC_libpthread_start, GC_libpthread_end,
GC_libld_start, GC_libld_end): Ditto.
* mark_rts.c (GC_remove_root_at_pos, GC_rebuild_root_index):
Ditto.
* os_dep.c (GC_gww_read_dirty, GC_gww_page_was_dirty,
GC_gww_page_was_ever_dirty, GC_mprotect_thread_notify,
GC_mprotect_thread_reply, GC_mprotect_thread, GC_darwin_sigbus,
GC_forward_exception): Ditto.
* pthread_support.c (GC_syms_initialized): Ditto.
* typd_mlc.c (GC_push_typed_structures_proc): Ditto.
* win32_threads.c (GC_win32_dll_threads,
GC_register_my_thread_inner, GC_lookup_pthread, GC_get_stack_min,
GC_waitForSingleObjectInfinite): Ditto.
* darwin_stop_world.c (GC_use_mach_handler_thread,
GC_use_mach_handler_thread, GC_mach_threads_count): Replace
"static" with "STATIC" and add zero initializer.
* os_dep.c (GC_task_self, GC_ports, GC_mprotect_state,
GC_sigbus_count): Ditto.
* headers.c (free_hdr): Replace "static" with GC_INLINE.
* misc.c (GC_tmp): Rename static variable to fwrite_gc_res.
* os_dep.c (memory): Rename static variable to ecos_gc_memory.
* os_dep.c (async_set_pht_entry_from_index): Make static (for
MPROTECT_VDB case).
* pthread_support.c (GC_real_pthread_create,
GC_real_pthread_sigmask, GC_real_pthread_join,
GC_real_pthread_detach, GC_init_real_syms): Use REAL_FUNC() macro
for static GC_real_XXX symbols.
* win32_threads.c (GC_may_be_in_stack): Remove "GC_" prefix.
2009-10-17 Ivan Maidanski <ivmai@mail.ru>
+ * alloc.c (GC_copyright): Define as const.
+ * alloc.c (GC_collect_at_heapsize): Replace "static" with "STATIC"
+ (since the name starts with "GC_" prefix).
+ * dbg_mlc.c (GC_describe_type_fns): Ditto.
+ * dyn_load.c (GC_FirstDLOpenedLinkMap,
+ GC_register_dynlib_callback, GC_dyld_sections,
+ GC_dyld_name_for_hdr, GC_dyld_image_add, GC_dyld_image_remove):
+ Ditto.
+ * malloc.c (GC_libpthread_start, GC_libpthread_end,
+ GC_libld_start, GC_libld_end): Ditto.
+ * mark_rts.c (GC_remove_root_at_pos, GC_rebuild_root_index):
+ Ditto.
+ * os_dep.c (GC_gww_read_dirty, GC_gww_page_was_dirty,
+ GC_gww_page_was_ever_dirty, GC_mprotect_thread_notify,
+ GC_mprotect_thread_reply, GC_mprotect_thread, GC_darwin_sigbus,
+ GC_forward_exception): Ditto.
+ * pthread_support.c (GC_syms_initialized): Ditto.
+ * typd_mlc.c (GC_push_typed_structures_proc): Ditto.
+ * win32_threads.c (GC_win32_dll_threads,
+ GC_register_my_thread_inner, GC_lookup_pthread, GC_get_stack_min,
+ GC_waitForSingleObjectInfinite): Ditto.
+ * darwin_stop_world.c (GC_use_mach_handler_thread,
+ GC_use_mach_handler_thread, GC_mach_threads_count): Replace
+ "static" with "STATIC" and add zero initializer.
+ * os_dep.c (GC_task_self, GC_ports, GC_mprotect_state,
+ GC_sigbus_count): Ditto.
+ * headers.c (free_hdr): Replace "static" with GC_INLINE.
+ * misc.c (GC_tmp): Rename static variable to fwrite_gc_res.
+ * os_dep.c (memory): Rename static variable to ecos_gc_memory.
+ * os_dep.c (async_set_pht_entry_from_index): Make static (for
+ MPROTECT_VDB case).
+ * pthread_support.c (GC_real_pthread_create,
+ GC_real_pthread_sigmask, GC_real_pthread_join,
+ GC_real_pthread_detach, GC_init_real_syms): Use REAL_FUNC() macro
+ for static GC_real_XXX symbols.
+ * win32_threads.c (GC_may_be_in_stack): Remove "GC_" prefix.
+
+2009-10-17 Ivan Maidanski <ivmai@mail.ru>
+
* alloc.c (GC_never_stop_func, GC_check_fl_marks,
GC_finish_collection): Reformat the code (make opening bracket
style uniform across the file).
STATIC word GC_used_heap_size_after_full = 0;
-char * GC_copyright[] =
+char * const GC_copyright[] =
{"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ",
"Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. ",
"Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. ",
/* Heap size at which we need a collection to avoid expanding past */
/* limits used by blacklisting. */
-static word GC_collect_at_heapsize = (word)(-1);
+STATIC word GC_collect_at_heapsize = (word)(-1);
/* Have we allocated enough to amortize a collection? */
GC_bool GC_should_collect(void)
}
#endif /* !DARWIN_DONT_PARSE_STACK */
-static mach_port_t GC_mach_handler_thread;
-static int GC_use_mach_handler_thread = 0;
+STATIC mach_port_t GC_mach_handler_thread = 0;
+STATIC int GC_use_mach_handler_thread = 0;
static struct GC_mach_thread GC_mach_threads[THREAD_TABLE_SZ];
-static int GC_mach_threads_count;
+STATIC int GC_mach_threads_count = 0;
void GC_stop_init(void)
{
}
#endif /* !SHORT_DBG_HDRS */
-static GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
+STATIC GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
GC_API void GC_CALL GC_register_describe_type_fn(int kind,
GC_describe_type_fn fn)
Elf32_Dyn _DYNAMIC;
#endif
-static struct link_map *
+STATIC struct link_map *
GC_FirstDLOpenedLinkMap(void)
{
extern ElfW(Dyn) _DYNAMIC;
# endif /* PT_GNU_RELRO */
-static int GC_register_dynlib_callback(struct dl_phdr_info * info,
- size_t size, void * ptr)
+STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info,
+ size_t size, void * ptr)
{
const ElfW(Phdr) * p;
ptr_t start, end;
#endif
extern ElfW(Dyn) _DYNAMIC[];
-static struct link_map *
+STATIC struct link_map *
GC_FirstDLOpenedLinkMap(void)
{
ElfW(Dyn) *dp;
/*#define DARWIN_DEBUG*/
-const static struct {
+STATIC const struct {
const char *seg;
const char *sect;
} GC_dyld_sections[] = {
{ SEG_DATA, SECT_COMMON }
};
-static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr)
+STATIC const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr)
{
unsigned long i, c;
c = _dyld_image_count();
}
/* This should never be called by a thread holding the lock */
-static void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
+STATIC void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
{
unsigned long start,end,i;
const struct GC_MACH_SECTION *sec;
}
/* This should never be called by a thread holding the lock */
-static void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
+STATIC void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
intptr_t slide)
{
unsigned long start,end,i;
return(result);
}
-static void free_hdr(hdr * hhdr)
+GC_INLINE void free_hdr(hdr * hhdr)
{
hhdr -> hb_next = (struct hblk *) hdr_free_list;
hdr_free_list = hhdr;
}
#if defined(GC_LINUX_THREADS) /* && !defined(USE_PROC_FOR_LIBRARIES) */
- static ptr_t GC_libpthread_start = 0;
- static ptr_t GC_libpthread_end = 0;
- static ptr_t GC_libld_start = 0;
- static ptr_t GC_libld_end = 0;
+ STATIC ptr_t GC_libpthread_start = 0;
+ STATIC ptr_t GC_libpthread_end = 0;
+ STATIC ptr_t GC_libld_start = 0;
+ STATIC ptr_t GC_libld_end = 0;
GC_bool GC_text_mapping(char *nm, ptr_t *startp, ptr_t *endp);
/* From os_dep.c */
static GC_bool roots_were_cleared = FALSE;
-GC_API void GC_CALL GC_clear_roots (void)
+GC_API void GC_CALL GC_clear_roots(void)
{
DCL_LOCK_STATE;
}
/* Internal use only; lock held. */
-static void GC_remove_root_at_pos(int i)
+STATIC void GC_remove_root_at_pos(int i)
{
GC_root_size -= (GC_static_roots[i].r_end - GC_static_roots[i].r_start);
GC_static_roots[i].r_start = GC_static_roots[n_root_sets-1].r_start;
}
#if !defined(MSWIN32) && !defined(MSWINCE)
-static void GC_rebuild_root_index(void)
-{
+ STATIC void GC_rebuild_root_index(void)
+ {
int i;
for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0;
for (i = 0; i < n_root_sets; i++)
add_roots_to_index(GC_static_roots + i);
-}
+ }
#endif
#if defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \
/* Convince lint that some things are used */
# ifdef LINT
{
- extern char * GC_copyright[];
+ extern char * const GC_copyright[];
GC_noop(GC_copyright, GC_find_header,
GC_push_one, GC_call_with_alloc_lock, GC_read,
GC_dont_expand,
STATIC FILE * GC_stdout = NULL;
STATIC FILE * GC_stderr = NULL;
STATIC FILE * GC_log = NULL;
-static int GC_tmp; /* Should really be local ... */
STATIC void GC_set_files(void)
{
# define WRITE(f, buf, len) GC_write(buf, len)
#else
# if defined(OS2) || defined(MACOS)
+ static int fwrite_gc_res; /* Should really be local ... */
# define WRITE(f, buf, len) (GC_set_files(), \
- GC_tmp = fwrite((buf), 1, (len), (f)), \
- fflush(f), GC_tmp)
+ fwrite_gc_res = fwrite((buf), 1, (len), (f)), \
+ fflush(f), fwrite_gc_res)
# else
# define WRITE(f, buf, len) GC_write((f), (buf), (len))
# endif
/* compatible with ECOS early releases. Later releases use a more */
/* sophisticated means of allocating memory than this simple static */
/* allocator, but this method is at least bound to work. */
-static char memory[ECOS_GC_MEMORY_SIZE];
-static char *brk = memory;
+static char ecos_gc_memory[ECOS_GC_MEMORY_SIZE];
+static char *brk = ecos_gc_memory;
static void *tiny_sbrk(ptrdiff_t increment)
{
brk += increment;
- if (brk > memory + sizeof memory)
+ if (brk > ecos_gc_memory + sizeof(ecos_gc_memory))
{
brk -= increment;
return NULL;
# endif
# ifdef MPROTECT_VDB
- static void GC_gww_read_dirty(void)
+ STATIC void GC_gww_read_dirty(void)
# else
void GC_read_dirty(void)
# endif
}
# ifdef MPROTECT_VDB
- static GC_bool GC_gww_page_was_dirty(struct hblk * h)
+ STATIC GC_bool GC_gww_page_was_dirty(struct hblk * h)
# else
GC_bool GC_page_was_dirty(struct hblk * h)
# endif
}
# ifdef MPROTECT_VDB
- static GC_bool GC_gww_page_was_ever_dirty(struct hblk * h)
+ STATIC GC_bool GC_gww_page_was_ever_dirty(struct hblk * h)
# else
GC_bool GC_page_was_ever_dirty(struct hblk * h)
# endif
/* Using vm_protect (mach syscall) over mprotect (BSD syscall) seems to
decrease the likelihood of some of the problems described below. */
# include <mach/vm_map.h>
- static mach_port_t GC_task_self;
+ STATIC mach_port_t GC_task_self = 0;
# define PROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
FALSE,VM_PROT_READ) != KERN_SUCCESS) { \
/* correctly. */
#ifdef AO_HAVE_test_and_set_acquire
volatile AO_TS_t GC_fault_handler_lock = 0;
- void async_set_pht_entry_from_index(volatile page_hash_table db, size_t index) {
- while (AO_test_and_set_acquire(&GC_fault_handler_lock) == AO_TS_SET) {}
+ static void async_set_pht_entry_from_index(volatile page_hash_table db,
+ size_t index)
+ {
+ while (AO_test_and_set_acquire(&GC_fault_handler_lock) == AO_TS_SET) {
+ /* empty */
+ }
/* Could also revert to set_pht_entry_from_index_safe if initial */
/* GC_test_and_set fails. */
set_pht_entry_from_index(db, index);
/* leave it this way while we think of something better, or support */
/* GC_test_and_set on the remaining platforms. */
static volatile word currently_updating = 0;
- void async_set_pht_entry_from_index(volatile page_hash_table db, size_t index) {
+ static void async_set_pht_entry_from_index(volatile page_hash_table db,
+ size_t index)
+ {
unsigned int update_dummy;
currently_updating = (word)(&update_dummy);
set_pht_entry_from_index(db, index);
thread_state_flavor_t flavors[MAX_EXCEPTION_PORTS];
} GC_old_exc_ports;
-static struct {
+STATIC struct {
mach_port_t exception;
-#if defined(THREADS)
- mach_port_t reply;
-#endif
-} GC_ports;
+# if defined(THREADS)
+ mach_port_t reply;
+# endif
+} GC_ports = {0};
typedef struct {
mach_msg_header_t head;
#if defined(THREADS)
-static GC_mprotect_state_t GC_mprotect_state;
+STATIC GC_mprotect_state_t GC_mprotect_state = 0;
/* The following should ONLY be called when the world is stopped */
-static void GC_mprotect_thread_notify(mach_msg_id_t id)
+STATIC void GC_mprotect_thread_notify(mach_msg_id_t id)
{
struct {
}
/* Should only be called by the mprotect thread */
-static void GC_mprotect_thread_reply(void)
+STATIC void GC_mprotect_thread_reply(void)
{
-
GC_msg_t msg;
mach_msg_return_t r;
/* remote, local */
#define GC_mprotect_state GC_MP_NORMAL
#endif
-static void *GC_mprotect_thread(void *arg)
+STATIC void *GC_mprotect_thread(void *arg)
{
mach_msg_return_t r;
/* These two structures contain some private kernel data. We don't need to
/* Updates to this aren't atomic, but the SIGBUSs seem pretty rare.
Even if this doesn't get updated property, it isn't really a problem */
-static int GC_sigbus_count;
+STATIC int GC_sigbus_count = 0;
-static void GC_darwin_sigbus(int num, siginfo_t *sip, void *context)
+STATIC void GC_darwin_sigbus(int num, siginfo_t *sip, void *context)
{
if(num != SIGBUS)
ABORT("Got a non-sigbus signal in the sigbus handler");
/* The source code for Apple's GDB was used as a reference for the exception
forwarding code. This code is similar to be GDB code only because there is
only one way to do it. */
-static kern_return_t GC_forward_exception(mach_port_t thread, mach_port_t task,
+STATIC kern_return_t GC_forward_exception(mach_port_t thread, mach_port_t task,
exception_type_t exception,
exception_data_t data,
mach_msg_type_number_t data_count)
/* FIXME: Needs work for DARWIN and True64 (OSF1) */
typedef int (* GC_pthread_create_t)(pthread_t *, const pthread_attr_t *,
void * (*)(void *), void *);
- static GC_pthread_create_t GC_real_pthread_create;
+ static GC_pthread_create_t REAL_FUNC(pthread_create);
typedef int (* GC_pthread_sigmask_t)(int, const sigset_t *, sigset_t *);
- static GC_pthread_sigmask_t GC_real_pthread_sigmask;
+ static GC_pthread_sigmask_t REAL_FUNC(pthread_sigmask);
typedef int (* GC_pthread_join_t)(pthread_t, void **);
- static GC_pthread_join_t GC_real_pthread_join;
+ static GC_pthread_join_t REAL_FUNC(pthread_join);
typedef int (* GC_pthread_detach_t)(pthread_t);
- static GC_pthread_detach_t GC_real_pthread_detach;
+ static GC_pthread_detach_t REAL_FUNC(pthread_detach);
# else
# define WRAP_FUNC(f) GC_##f
# if !defined(GC_DGUX386_THREADS)
#endif /* Linker-based interception. */
#ifdef GC_USE_DLOPEN_WRAP
- static GC_bool GC_syms_initialized = FALSE;
+ STATIC GC_bool GC_syms_initialized = FALSE;
STATIC void GC_init_real_syms(void)
{
}
if (NULL == dl_handle) ABORT("Couldn't open libpthread\n");
# endif
- GC_real_pthread_create = (GC_pthread_create_t)
+ REAL_FUNC(pthread_create) = (GC_pthread_create_t)
dlsym(dl_handle, "pthread_create");
- GC_real_pthread_sigmask = (GC_pthread_sigmask_t)
+ REAL_FUNC(pthread_sigmask) = (GC_pthread_sigmask_t)
dlsym(dl_handle, "pthread_sigmask");
- GC_real_pthread_join = (GC_pthread_join_t)
+ REAL_FUNC(pthread_join) = (GC_pthread_join_t)
dlsym(dl_handle, "pthread_join");
- GC_real_pthread_detach = (GC_pthread_detach_t)
+ REAL_FUNC(pthread_detach) = (GC_pthread_detach_t)
dlsym(dl_handle, "pthread_detach");
GC_syms_initialized = TRUE;
}
STATIC int GC_typed_mark_proc_index = 0; /* Indices of my mark */
STATIC int GC_array_mark_proc_index = 0; /* procedures. */
-static void GC_push_typed_structures_proc (void)
+STATIC void GC_push_typed_structures_proc(void)
{
- GC_push_all((ptr_t)&GC_ext_descriptors, (ptr_t)&GC_ext_descriptors + sizeof(word));
+ GC_push_all((ptr_t)&GC_ext_descriptors,
+ (ptr_t)&GC_ext_descriptors + sizeof(word));
}
/* Add a multiword bitmap to GC_ext_descriptors arrays. Return */
&& !defined(THREAD_LOCAL_ALLOC) && !defined(GC_PTHREADS)
# include "atomic_ops.h"
- static GC_bool GC_win32_dll_threads = FALSE;
+ STATIC GC_bool GC_win32_dll_threads = FALSE;
/* This code operates in two distinct modes, depending on */
/* the setting of GC_win32_dll_threads. If */
/* GC_win32_dll_threads is set, all threads in the process */
* If GC_win32_dll_threads is not set, we already hold the allocation lock,
* except possibly during single-threaded start-up code.
*/
-static GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb,
+STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb,
DWORD thread_id)
{
GC_vthread me;
/* have not yet terminated or are still joinable, and */
/* cannot be concurrently terminated. */
/* Assumes we do NOT hold the allocation lock. */
- static GC_thread GC_lookup_pthread(pthread_t id)
+ STATIC GC_thread GC_lookup_pthread(pthread_t id)
{
# ifndef GC_NO_DLLMAIN
if (GC_win32_dll_threads) {
/* lowest address (i.e. stack top). */
/* S must be a mapped address inside the region, NOT the first */
/* unmapped address. */
-static ptr_t GC_get_stack_min(ptr_t s)
+STATIC ptr_t GC_get_stack_min(ptr_t s)
{
ptr_t bottom;
/* Return true if the page at s has protections appropriate */
/* for a stack page. */
-static GC_bool GC_may_be_in_stack(ptr_t s)
+static GC_bool may_be_in_stack(ptr_t s)
{
GC_ASSERT(I_HOLD_LOCK());
if (s != last_address) {
stack_min = sp;
} else {
/* In the current thread it is always safe to use sp value. */
- if (GC_may_be_in_stack(thread -> id == me &&
- sp < thread -> last_stack_min ?
- sp : thread -> last_stack_min)) {
+ if (may_be_in_stack(thread -> id == me &&
+ sp < thread -> last_stack_min ?
+ sp : thread -> last_stack_min)) {
stack_min = last_info.BaseAddress;
/* Do not probe rest of the stack if sp is correct. */
if (sp < stack_min || sp >= thread->stack_base)
}
# endif
- if (current_min > limit && !GC_may_be_in_stack(limit)) {
+ if (current_min > limit && !may_be_in_stack(limit)) {
/* Skip the rest since the memory region at limit address is */
/* not a stack (so the lowest address of the found stack would */
/* be above the limit value anyway). */
/* Get the minimum address of the found stack by probing its memory */
/* region starting from the recent known minimum (if set). */
if (*plast_stack_min == ADDR_LIMIT
- || !GC_may_be_in_stack(*plast_stack_min)) {
+ || !may_be_in_stack(*plast_stack_min)) {
/* Unsafe to start from last_stack_min value. */
*lo = GC_get_stack_min(current_min);
} else {
args->lpCmdLine, args->nShowCmd);
}
- static void * GC_waitForSingleObjectInfinite(void * handle)
+ STATIC void * GC_waitForSingleObjectInfinite(void * handle)
{
return (void *)(word)WaitForSingleObject((HANDLE)handle, INFINITE);
}