Skip to content

Commit

Permalink
2009-10-17 Ivan Maidanski <ivmai@mail.ru>
Browse files Browse the repository at this point in the history
	* 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.
  • Loading branch information
ivmai authored and ivmai committed Jul 26, 2011
1 parent 8274f8d commit 340c703
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 73 deletions.
39 changes: 39 additions & 0 deletions ChangeLog
@@ -1,3 +1,42 @@
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,
Expand Down
4 changes: 2 additions & 2 deletions alloc.c
Expand Up @@ -81,7 +81,7 @@ STATIC GC_bool GC_need_full_gc = FALSE;

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. ",
Expand Down Expand Up @@ -279,7 +279,7 @@ STATIC void GC_clear_a_few_frames(void)

/* 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)
Expand Down
6 changes: 3 additions & 3 deletions darwin_stop_world.c
Expand Up @@ -412,11 +412,11 @@ void GC_push_all_stacks(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)
{
Expand Down
2 changes: 1 addition & 1 deletion dbg_mlc.c
Expand Up @@ -329,7 +329,7 @@ STATIC ptr_t GC_check_annotated_obj(oh *ohdr)
}
#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)
Expand Down
16 changes: 8 additions & 8 deletions dyn_load.c
Expand Up @@ -122,7 +122,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
Elf32_Dyn _DYNAMIC;
#endif

static struct link_map *
STATIC struct link_map *
GC_FirstDLOpenedLinkMap(void)
{
extern ElfW(Dyn) _DYNAMIC;
Expand Down Expand Up @@ -420,8 +420,8 @@ static int n_load_segs;

# 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;
Expand Down Expand Up @@ -584,7 +584,7 @@ GC_bool GC_register_main_static_data(void)
#endif
extern ElfW(Dyn) _DYNAMIC[];

static struct link_map *
STATIC struct link_map *
GC_FirstDLOpenedLinkMap(void)
{
ElfW(Dyn) *dp;
Expand Down Expand Up @@ -1145,7 +1145,7 @@ void GC_register_dynamic_libraries(void)

/*#define DARWIN_DEBUG*/

const static struct {
STATIC const struct {
const char *seg;
const char *sect;
} GC_dyld_sections[] = {
Expand All @@ -1154,7 +1154,7 @@ const static struct {
{ 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();
Expand All @@ -1165,7 +1165,7 @@ static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr)
}

/* 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;
Expand Down Expand Up @@ -1201,7 +1201,7 @@ static void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
}

/* 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;
Expand Down
2 changes: 1 addition & 1 deletion headers.c
Expand Up @@ -178,7 +178,7 @@ static hdr * alloc_hdr(void)
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;
Expand Down
8 changes: 4 additions & 4 deletions malloc.c
Expand Up @@ -323,10 +323,10 @@ void * malloc(size_t lb)
}

#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 */

Expand Down
10 changes: 5 additions & 5 deletions mark_rts.c
Expand Up @@ -240,7 +240,7 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)

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;

Expand All @@ -259,7 +259,7 @@ GC_API void GC_CALL GC_clear_roots (void)
}

/* 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;
Expand All @@ -269,14 +269,14 @@ static void GC_remove_root_at_pos(int i)
}

#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) \
Expand Down
8 changes: 4 additions & 4 deletions misc.c
Expand Up @@ -845,7 +845,7 @@ GC_API void GC_CALL GC_init(void)
/* 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,
Expand Down Expand Up @@ -1028,7 +1028,6 @@ GC_API void GC_CALL GC_enable_incremental(void)
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)
{
Expand Down Expand Up @@ -1102,9 +1101,10 @@ STATIC int GC_write(int fd, const char *buf, size_t len)
# 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
Expand Down
51 changes: 28 additions & 23 deletions os_dep.c
Expand Up @@ -482,16 +482,16 @@ static ptr_t backing_store_base_from_proc(void)
/* 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)
{
void *p = brk;

brk += increment;

if (brk > memory + sizeof memory)
if (brk > ecos_gc_memory + sizeof(ecos_gc_memory))
{
brk -= increment;
return NULL;
Expand Down Expand Up @@ -2362,7 +2362,7 @@ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
# 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
Expand Down Expand Up @@ -2440,7 +2440,7 @@ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
}

# 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
Expand All @@ -2450,7 +2450,7 @@ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
}

# 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
Expand Down Expand Up @@ -2625,7 +2625,7 @@ void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
/* 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) { \
Expand Down Expand Up @@ -2698,8 +2698,12 @@ STATIC GC_bool GC_old_segv_handler_used_si = FALSE;
/* 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);
Expand All @@ -2716,7 +2720,9 @@ STATIC GC_bool GC_old_segv_handler_used_si = FALSE;
/* 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);
Expand Down Expand Up @@ -3533,12 +3539,12 @@ static struct {
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;
Expand All @@ -3559,10 +3565,10 @@ typedef enum {

#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 {
Expand All @@ -3588,9 +3594,8 @@ static void GC_mprotect_thread_notify(mach_msg_id_t id)
}

/* 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 */
Expand Down Expand Up @@ -3620,7 +3625,7 @@ void GC_mprotect_resume(void)
#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
Expand Down Expand Up @@ -3713,9 +3718,9 @@ static void *GC_mprotect_thread(void *arg)

/* 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");
Expand Down Expand Up @@ -3815,7 +3820,7 @@ void GC_dirty_init(void)
/* 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)
Expand Down

0 comments on commit 340c703

Please sign in to comment.