From 559c07bf35031e2d073dae3fbf8f11318953863e Mon Sep 17 00:00:00 2001 From: hboehm Date: Sat, 25 Oct 2008 05:03:02 +0000 Subject: [PATCH] 2008-10-24 Hans Boehm (Really Ivan Maidanski) * alloc.c, dbg_mlc.c, dyn_load.c, finalize.c, gcj_mlc.c, include/gc.h, include/gc_config_macros.h, include/gc_cpp.h, include/gc_gcj.h, include/gc_mark.h, include/gc_typed.h, include/javaxfc.h, include/private/gc_locks.h, include/private/gc_priv.h, malloc.c, mallocx.c, mark.c, mark_rts.c, misc.c, obj_map.c, os_dep.c, pthread_support.c, ptr_chck.c, stubborn.c, tests/test.c, thread_local_alloc.c, typd_mlc.c win32_threads.c: Add GC_CALL and GC_CALLBACK macro invocations. * test.c: Remove some old K&R code. --- ChangeLog | 11 ++ alloc.c | 14 +-- dbg_mlc.c | 53 +++++----- dyn_load.c | 7 +- finalize.c | 24 +++-- gcj_mlc.c | 10 +- include/gc.h | 211 +++++++++++++++++++------------------ include/gc_config_macros.h | 9 +- include/gc_cpp.h | 8 +- include/gc_gcj.h | 10 +- include/gc_mark.h | 4 +- include/gc_typed.h | 9 +- include/javaxfc.h | 2 +- include/private/gc_locks.h | 2 +- include/private/gc_priv.h | 6 +- malloc.c | 8 +- mallocx.c | 12 +-- mark.c | 2 +- mark_rts.c | 8 +- misc.c | 52 ++++----- obj_map.c | 2 +- os_dep.c | 12 +-- pthread_support.c | 11 +- ptr_chck.c | 23 ++-- stubborn.c | 12 +-- tests/test.c | 69 ++++-------- thread_local_alloc.c | 6 +- typd_mlc.c | 10 +- win32_threads.c | 18 ++-- 29 files changed, 320 insertions(+), 305 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf828981..6c2c6f9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-10-24 Hans Boehm (Really Ivan Maidanski) + * alloc.c, dbg_mlc.c, dyn_load.c, finalize.c, gcj_mlc.c, + include/gc.h, include/gc_config_macros.h, include/gc_cpp.h, + include/gc_gcj.h, include/gc_mark.h, include/gc_typed.h, + include/javaxfc.h, include/private/gc_locks.h, + include/private/gc_priv.h, malloc.c, mallocx.c, mark.c, mark_rts.c, + misc.c, obj_map.c, os_dep.c, pthread_support.c, ptr_chck.c, + stubborn.c, tests/test.c, thread_local_alloc.c, typd_mlc.c + win32_threads.c: Add GC_CALL and GC_CALLBACK macro invocations. + * test.c: Remove some old K&R code. + 2008-10-24 Hans Boehm (Partially based loosely on patch from Ivan Maidanski) * win32_threads.c (GC_may_be_in_stack): New. (GC_Thread_Rep): diff --git a/alloc.c b/alloc.c index b2009ea9..8596a17b 100644 --- a/alloc.c +++ b/alloc.c @@ -111,7 +111,7 @@ word GC_free_space_divisor = 3; extern GC_bool GC_collection_in_progress(void); /* Collection is in progress, or was abandoned. */ -int GC_never_stop_func (void) { return(0); } +int GC_CALLBACK GC_never_stop_func (void) { return(0); } unsigned long GC_time_limit = TIME_LIMIT; @@ -126,7 +126,7 @@ STATIC int GC_n_attempts = 0; /* Number of attempts at finishing */ #if defined(SMALL_CONFIG) || defined(NO_CLOCK) # define GC_timeout_stop_func GC_never_stop_func #else - STATIC int GC_timeout_stop_func (void) + STATIC int GC_CALLBACK GC_timeout_stop_func (void) { CLOCK_TYPE current_time; static unsigned count = 0; @@ -444,7 +444,7 @@ void GC_collect_a_little_inner(int n) } } -GC_API int GC_collect_a_little(void) +GC_API int GC_CALL GC_collect_a_little(void) { int result; DCL_LOCK_STATE; @@ -776,7 +776,7 @@ void GC_finish_collection(void) } /* Externally callable routine to invoke full, stop-world collection */ -GC_API int GC_try_to_collect(GC_stop_func stop_func) +GC_API int GC_CALL GC_try_to_collect(GC_stop_func stop_func) { int result; DCL_LOCK_STATE; @@ -799,7 +799,7 @@ GC_API int GC_try_to_collect(GC_stop_func stop_func) return(result); } -GC_API void GC_gcollect(void) +GC_API void GC_CALL GC_gcollect(void) { (void)GC_try_to_collect(GC_never_stop_func); if (GC_have_errors) GC_print_all_errors(); @@ -912,7 +912,7 @@ static INLINE word GC_min(word x, word y) return(x < y? x : y); } -GC_API void GC_set_max_heap_size(GC_word n) +GC_API void GC_CALL GC_set_max_heap_size(GC_word n) { GC_max_heapsize = n; } @@ -997,7 +997,7 @@ GC_bool GC_expand_hp_inner(word n) /* Really returns a bool, but it's externally visible, so that's clumsy. */ /* Arguments is in bytes. */ -GC_API int GC_expand_hp(size_t bytes) +GC_API int GC_CALL GC_expand_hp(size_t bytes) { int result; DCL_LOCK_STATE; diff --git a/dbg_mlc.c b/dbg_mlc.c index 99b6cbaa..3ccb1b52 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -19,8 +19,8 @@ #include #include "private/dbg_mlc.h" -void GC_default_print_heap_obj_proc(); -GC_API void GC_register_finalizer_no_order +void GC_default_print_heap_obj_proc(ptr_t p); +GC_API void GC_CALL GC_register_finalizer_no_order (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); @@ -329,7 +329,7 @@ STATIC ptr_t GC_check_annotated_obj(oh *ohdr) static GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0}; -void GC_register_describe_type_fn(int kind, GC_describe_type_fn fn) +void GC_CALL GC_register_describe_type_fn(int kind, GC_describe_type_fn fn) { GC_describe_type_fns[kind] = fn; } @@ -457,13 +457,13 @@ void GC_start_debugging(void) size_t GC_debug_header_size = sizeof(oh); -GC_API void GC_debug_register_displacement(size_t offset) +GC_API void GC_CALL GC_debug_register_displacement(size_t offset) { GC_register_displacement(offset); GC_register_displacement((word)sizeof(oh) + offset); } -GC_API void * GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) { void * result = GC_malloc(lb + DEBUG_BYTES); @@ -481,7 +481,8 @@ GC_API void * GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) return (GC_store_debug_info(result, (word)lb, s, (word)i)); } -GC_API void * GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb, + GC_EXTRA_PARAMS) { void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES); @@ -499,7 +500,8 @@ GC_API void * GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS) return (GC_store_debug_info(result, (word)lb, s, (word)i)); } -GC_API void * GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb, + GC_EXTRA_PARAMS) { void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES); @@ -555,7 +557,7 @@ GC_API void * GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS) # endif #ifdef STUBBORN_ALLOC -GC_API void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) { void * result = GC_malloc_stubborn(lb + DEBUG_BYTES); @@ -573,7 +575,7 @@ GC_API void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) return (GC_store_debug_info(result, (word)lb, s, (word)i)); } -GC_API void GC_debug_change_stubborn(void *p) +GC_API void GC_CALL GC_debug_change_stubborn(void *p) { void * q = GC_base(p); hdr * hhdr; @@ -590,7 +592,7 @@ GC_API void GC_debug_change_stubborn(void *p) GC_change_stubborn(q); } -GC_API void GC_debug_end_stubborn_change(void *p) +GC_API void GC_CALL GC_debug_end_stubborn_change(void *p) { register void * q = GC_base(p); register hdr * hhdr; @@ -609,22 +611,22 @@ GC_API void GC_debug_end_stubborn_change(void *p) #else /* !STUBBORN_ALLOC */ -GC_API void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS) { return GC_debug_malloc(lb, OPT_RA s, i); } -GC_API void GC_debug_change_stubborn(void *p) +GC_API void GC_CALL GC_debug_change_stubborn(void *p) { } -GC_API void GC_debug_end_stubborn_change(void *p) +GC_API void GC_CALL GC_debug_end_stubborn_change(void *p) { } #endif /* !STUBBORN_ALLOC */ -GC_API void * GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS) { void * result = GC_malloc_atomic(lb + DEBUG_BYTES); @@ -642,7 +644,7 @@ GC_API void * GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS) return (GC_store_debug_info(result, (word)lb, s, (word)i)); } -GC_API char *GC_debug_strdup(const char *str, GC_EXTRA_PARAMS) +GC_API char * GC_CALL GC_debug_strdup(const char *str, GC_EXTRA_PARAMS) { char *copy; if (str == NULL) return NULL; @@ -655,7 +657,7 @@ GC_API char *GC_debug_strdup(const char *str, GC_EXTRA_PARAMS) return copy; } -GC_API void * GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS) { void * result = GC_malloc_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES); @@ -695,7 +697,7 @@ void * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS) } #endif /* ATOMIC_UNCOLLECTABLE */ -GC_API void GC_debug_free(void * p) +GC_API void GC_CALL GC_debug_free(void * p) { ptr_t base; # ifndef SHORT_DBG_HDRS @@ -770,7 +772,7 @@ void GC_debug_free_inner(void * p) } #endif -GC_API void * GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS) +GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS) { void * base; # ifndef SHORT_DBG_HDRS @@ -934,7 +936,7 @@ void * GC_make_closure(GC_finalization_proc fn, void * data) return((void *)result); } -void GC_debug_invoke_finalizer(void * obj, void * data) +void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data) { register struct closure * cl = (struct closure *) data; @@ -961,7 +963,8 @@ static void store_old (void *obj, GC_finalization_proc my_old_fn, } } -GC_API void GC_debug_register_finalizer(void * obj, GC_finalization_proc fn, +GC_API void GC_CALL GC_debug_register_finalizer(void * obj, + GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd) { @@ -983,7 +986,7 @@ GC_API void GC_debug_register_finalizer(void * obj, GC_finalization_proc fn, store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } -GC_API void GC_debug_register_finalizer_no_order +GC_API void GC_CALL GC_debug_register_finalizer_no_order (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd) @@ -1008,7 +1011,7 @@ GC_API void GC_debug_register_finalizer_no_order store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } -GC_API void GC_debug_register_finalizer_unreachable +GC_API void GC_CALL GC_debug_register_finalizer_unreachable (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd) @@ -1033,7 +1036,7 @@ GC_API void GC_debug_register_finalizer_unreachable store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } -GC_API void GC_debug_register_finalizer_ignore_self +GC_API void GC_CALL GC_debug_register_finalizer_ignore_self (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd) @@ -1063,12 +1066,12 @@ GC_API void GC_debug_register_finalizer_ignore_self # define RA #endif -GC_API void * GC_debug_malloc_replacement(size_t lb) +GC_API void * GC_CALL GC_debug_malloc_replacement(size_t lb) { return GC_debug_malloc(lb, RA "unknown", 0); } -GC_API void * GC_debug_realloc_replacement(void *p, size_t lb) +GC_API void * GC_CALL GC_debug_realloc_replacement(void *p, size_t lb) { return GC_debug_realloc(p, lb, RA "unknown", 0); } diff --git a/dyn_load.c b/dyn_load.c index 7c758efa..b06a39c6 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -382,7 +382,7 @@ GC_bool GC_register_main_static_data(void) /* A user-supplied routine that is called to determine if a DSO must be scanned by the gc. */ -static int (*GC_has_static_roots)(const char *, void *, size_t); +static int (GC_CALLBACK * GC_has_static_roots)(const char *, void *, size_t); static int GC_register_dynlib_callback(info, size, ptr) struct dl_phdr_info * info; @@ -1221,9 +1221,8 @@ GC_bool GC_register_main_static_data(void) } /* Register a routine to filter dynamic library registration. */ -GC_API void -GC_register_has_static_roots_callback - (int (*callback)(const char *, void *, size_t)) { +GC_API void GC_CALL GC_register_has_static_roots_callback + (int (GC_CALLBACK * callback)(const char *, void *, size_t)) { # ifdef HAVE_DL_ITERATE_PHDR GC_has_static_roots = callback; # endif diff --git a/finalize.c b/finalize.c index d61b339f..693389a2 100644 --- a/finalize.c +++ b/finalize.c @@ -137,7 +137,7 @@ STATIC void GC_grow_table(struct hash_chain_entry ***table, *table = new_table; } -GC_API int GC_register_disappearing_link(void * * link) +GC_API int GC_CALL GC_register_disappearing_link(void * * link) { ptr_t base; @@ -147,7 +147,8 @@ GC_API int GC_register_disappearing_link(void * * link) return(GC_general_register_disappearing_link(link, base)); } -GC_API int GC_general_register_disappearing_link(void * * link, void * obj) +GC_API int GC_CALL GC_general_register_disappearing_link(void * * link, + void * obj) { struct disappearing_link *curr_dl; size_t index; @@ -206,7 +207,7 @@ GC_API int GC_general_register_disappearing_link(void * * link, void * obj) return(0); } -GC_API int GC_unregister_disappearing_link(void * * link) +GC_API int GC_CALL GC_unregister_disappearing_link(void * * link) { struct disappearing_link *curr_dl, *prev_dl; size_t index; @@ -421,7 +422,7 @@ GC_API void GC_register_finalizer_inner(void * obj, # endif } -GC_API void GC_register_finalizer(void * obj, +GC_API void GC_CALL GC_register_finalizer(void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void ** ocd) { @@ -429,7 +430,7 @@ GC_API void GC_register_finalizer(void * obj, ocd, GC_normal_finalize_mark_proc); } -GC_API void GC_register_finalizer_ignore_self(void * obj, +GC_API void GC_CALL GC_register_finalizer_ignore_self(void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void ** ocd) { @@ -437,7 +438,7 @@ GC_API void GC_register_finalizer_ignore_self(void * obj, ocd, GC_ignore_self_finalize_mark_proc); } -GC_API void GC_register_finalizer_no_order(void * obj, +GC_API void GC_CALL GC_register_finalizer_no_order(void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void ** ocd) { @@ -448,7 +449,7 @@ GC_API void GC_register_finalizer_no_order(void * obj, static GC_bool need_unreachable_finalization = FALSE; /* Avoid the work if this isn't used. */ -GC_API void GC_register_finalizer_unreachable(void * obj, +GC_API void GC_CALL GC_register_finalizer_unreachable(void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void ** ocd) { @@ -713,7 +714,7 @@ STATIC void GC_enqueue_all_finalizers(void) * This routine is externally callable, so is called without * the allocation lock. */ -GC_API void GC_finalize_all(void) +GC_API void GC_CALL GC_finalize_all(void) { DCL_LOCK_STATE; @@ -731,14 +732,14 @@ GC_API void GC_finalize_all(void) /* Returns true if it is worth calling GC_invoke_finalizers. (Useful if */ /* finalizers can only be called from some kind of `safe state' and */ /* getting into that safe state is expensive.) */ -GC_API int GC_should_invoke_finalizers(void) +GC_API int GC_CALL GC_should_invoke_finalizers(void) { return GC_finalize_now != 0; } /* Invoke finalizers for all objects that are ready to be finalized. */ /* Should be called without allocation lock. */ -GC_API int GC_invoke_finalizers(void) +GC_API int GC_CALL GC_invoke_finalizers(void) { struct finalizable_object * curr_fo; int count = 0; @@ -833,7 +834,8 @@ void GC_notify_or_invoke_finalizers(void) } } -GC_API void * GC_call_with_alloc_lock(GC_fn_type fn, void * client_data) +GC_API void * GC_CALL GC_call_with_alloc_lock(GC_fn_type fn, + void * client_data) { void * result; DCL_LOCK_STATE; diff --git a/gcj_mlc.c b/gcj_mlc.c index 5d95ad6c..f155e59b 100644 --- a/gcj_mlc.c +++ b/gcj_mlc.c @@ -50,7 +50,8 @@ ptr_t * GC_gcjobjfreelist; ptr_t * GC_gcjdebugobjfreelist; /* Caller does not hold allocation lock. */ -GC_API void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp) +GC_API void GC_CALL GC_init_gcj_malloc(int mp_index, + void * /* really GC_mark_proc */mp) { GC_bool ignore_gcj_info; DCL_LOCK_STATE; @@ -134,7 +135,8 @@ static void maybe_finalize(void) #ifdef THREAD_LOCAL_ALLOC void * GC_core_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr) #else - GC_API void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr) + GC_API void * GC_CALL GC_gcj_malloc(size_t lb, + void * ptr_to_struct_containing_descr) #endif { ptr_t op; @@ -179,7 +181,7 @@ void GC_start_debugging(void); /* Similar to GC_gcj_malloc, but add debug info. This is allocated */ /* with GC_gcj_debug_kind. */ -GC_API void * GC_debug_gcj_malloc(size_t lb, +GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr, GC_EXTRA_PARAMS) { void * result; @@ -206,7 +208,7 @@ GC_API void * GC_debug_gcj_malloc(size_t lb, return (GC_store_debug_info(result, (word)lb, s, (word)i)); } -GC_API void * GC_gcj_malloc_ignore_off_page(size_t lb, +GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb, void * ptr_to_struct_containing_descr) { ptr_t op; diff --git a/include/gc.h b/include/gc.h index 35c2f6e0..c3bfa17b 100644 --- a/include/gc.h +++ b/include/gc.h @@ -74,7 +74,7 @@ GC_API GC_word GC_gc_no;/* Counter incremented per collection. */ /* Includes empty GCs at startup. */ -GC_API GC_word GC_get_gc_no(void); +GC_API GC_word GC_CALL GC_get_gc_no(void); GC_API int GC_parallel; /* GC is parallelized for performance on */ /* multiprocessors. Currently set only */ @@ -85,12 +85,12 @@ GC_API int GC_parallel; /* GC is parallelized for performance on */ /* If GC_parallel is set, incremental */ /* collection is only partially functional, */ /* and may not be desirable. */ -GC_API int GC_get_parallel(void); +GC_API int GC_CALL GC_get_parallel(void); /* Public R/W variables */ -typedef void * (* GC_oom_func)(size_t /* bytes_requested */); +typedef void * (GC_CALLBACK * GC_oom_func)(size_t /* bytes_requested */); GC_API GC_oom_func GC_oom_fn; /* When there is insufficient memory to satisfy */ /* an allocation request, we return */ @@ -99,7 +99,7 @@ GC_API GC_oom_func GC_oom_fn; /* If it returns, it must return 0 or a valid */ /* pointer to a previously allocated heap */ /* object. */ -GC_API GC_oom_func GC_set_oom_fn(GC_oom_func); +GC_API GC_oom_func GC_CALL GC_set_oom_fn(GC_oom_func); GC_API int GC_find_leak; /* Do not actually garbage collect, but simply */ @@ -125,7 +125,7 @@ GC_API int GC_finalize_on_demand; /* call. The default is determined by whether */ /* the FINALIZE_ON_DEMAND macro is defined */ /* when the collector is built. */ -GC_API int GC_set_finalize_on_demand(int); +GC_API int GC_CALL GC_set_finalize_on_demand(int); GC_API int GC_java_finalization; /* Mark objects reachable from finalizable */ @@ -135,9 +135,9 @@ GC_API int GC_java_finalization; /* determined by JAVA_FINALIZATION macro. */ /* Enables register_finalizer_unreachable to */ /* work correctly. */ -GC_API int GC_set_java_finalization(int); +GC_API int GC_CALL GC_set_java_finalization(int); -typedef void (* GC_finalizer_notifier_proc)(void); +typedef void (GC_CALLBACK * GC_finalizer_notifier_proc)(void); GC_API GC_finalizer_notifier_proc GC_finalizer_notifier; /* Invoked by the collector when there are */ /* objects to be finalized. Invoked at most */ @@ -146,7 +146,7 @@ GC_API GC_finalizer_notifier_proc GC_finalizer_notifier; /* Typically this will notify a finalization */ /* thread, which will call GC_invoke_finalizers */ /* in response. */ -GC_API GC_finalizer_notifier_proc GC_set_finalizer_notifier( +GC_API GC_finalizer_notifier_proc GC_CALL GC_set_finalizer_notifier( GC_finalizer_notifier_proc); GC_API int GC_dont_gc; /* != 0 ==> Dont collect. In versions 6.2a1+, */ @@ -161,7 +161,7 @@ GC_API int GC_dont_gc; /* != 0 ==> Dont collect. In versions 6.2a1+, */ GC_API int GC_dont_expand; /* Dont expand heap unless explicitly requested */ /* or forced to. */ -GC_API int GC_set_dont_expand(int); +GC_API int GC_CALL GC_set_dont_expand(int); GC_API int GC_use_entire_heap; /* Causes the non-incremental collector to use the */ @@ -197,7 +197,7 @@ GC_API int GC_no_dls; /* In Microsoft Windows environments, this will */ /* usually also prevent registration of the */ /* main data segment as part of the root set. */ -GC_API int GC_set_no_dls(int); +GC_API int GC_CALL GC_set_no_dls(int); GC_API GC_word GC_free_space_divisor; /* We try to make sure that we allocate at */ @@ -217,7 +217,7 @@ GC_API GC_word GC_max_retries; /* The maximum number of GCs attempted before */ /* reporting out of memory after heap */ /* expansion fails. Initially 0. */ -GC_API GC_word GC_set_max_retries(GC_word); +GC_API GC_word GC_CALL GC_set_max_retries(GC_word); GC_API char *GC_stackbottom; /* Cool end of user stack. */ @@ -239,7 +239,7 @@ GC_API int GC_dont_precollect; /* Don't collect as part of */ /* before the first collection. */ /* Interferes with blacklisting. */ /* Wizards only. */ -GC_API int GC_set_dont_precollect(int); +GC_API int GC_CALL GC_set_dont_precollect(int); GC_API unsigned long GC_time_limit; /* If incremental collection is enabled, */ @@ -260,7 +260,7 @@ GC_API unsigned long GC_time_limit; /* Initialize the collector. Portable clients should call GC_INIT() from * the main program instead. */ -GC_API void GC_init(void); +GC_API void GC_CALL GC_init(void); /* * general purpose allocation routines, with roughly malloc calling conv. @@ -278,15 +278,15 @@ GC_API void GC_init(void); * starting in 6.0. GC_malloc_stubborn is an alias for GC_malloc unless * the collector is built with STUBBORN_ALLOC defined. */ -GC_API void * GC_malloc(size_t size_in_bytes); -GC_API void * GC_malloc_atomic(size_t size_in_bytes); -GC_API char * GC_strdup (const char *str); -GC_API void * GC_malloc_uncollectable(size_t size_in_bytes); -GC_API void * GC_malloc_stubborn(size_t size_in_bytes); +GC_API void * GC_CALL GC_malloc(size_t size_in_bytes); +GC_API void * GC_CALL GC_malloc_atomic(size_t size_in_bytes); +GC_API char * GC_CALL GC_strdup (const char *str); +GC_API void * GC_CALL GC_malloc_uncollectable(size_t size_in_bytes); +GC_API void * GC_CALL GC_malloc_stubborn(size_t size_in_bytes); /* The following is only defined if the library has been suitably */ /* compiled: */ -GC_API void * GC_malloc_atomic_uncollectable(size_t size_in_bytes); +GC_API void * GC_CALL GC_malloc_atomic_uncollectable(size_t size_in_bytes); /* Explicitly deallocate an object. Dangerous if used incorrectly. */ /* Requires a pointer to the base of an object. */ @@ -294,7 +294,7 @@ GC_API void * GC_malloc_atomic_uncollectable(size_t size_in_bytes); /* An object should not be enable for finalization when it is */ /* explicitly deallocated. */ /* GC_free(0) is a no-op, as required by ANSI C for free. */ -GC_API void GC_free(void * object_addr); +GC_API void GC_CALL GC_free(void * object_addr); /* * Stubborn objects may be changed only if the collector is explicitly informed. @@ -311,8 +311,8 @@ GC_API void GC_free(void * object_addr); * do so. The same applies to dropping stubborn objects that are still * changeable. */ -GC_API void GC_change_stubborn(void *); -GC_API void GC_end_stubborn_change(void *); +GC_API void GC_CALL GC_change_stubborn(void *); +GC_API void GC_CALL GC_end_stubborn_change(void *); /* Return a pointer to the base (lowest address) of an object given */ /* a pointer to a location within the object. */ @@ -325,12 +325,12 @@ GC_API void GC_end_stubborn_change(void *); /* Note that a deallocated object in the garbage collected heap */ /* may be considered valid, even if it has been deallocated with */ /* GC_free. */ -GC_API void * GC_base(void * displaced_pointer); +GC_API void * GC_CALL GC_base(void * displaced_pointer); /* Given a pointer to the base of an object, return its size in bytes. */ /* The returned size may be slightly larger than what was originally */ /* requested. */ -GC_API size_t GC_size(void * object_addr); +GC_API size_t GC_CALL GC_size(void * object_addr); /* For compatibility with C library. This is occasionally faster than */ /* a malloc followed by a bcopy. But if you rely on that, either here */ @@ -340,33 +340,35 @@ GC_API size_t GC_size(void * object_addr); /* If the argument is stubborn, the result will have changes enabled. */ /* It is an error to have changes enabled for the original object. */ /* Follows ANSI conventions for NULL old_object. */ -GC_API void * GC_realloc(void * old_object, size_t new_size_in_bytes); +GC_API void * GC_CALL GC_realloc(void * old_object, size_t new_size_in_bytes); /* Explicitly increase the heap size. */ /* Returns 0 on failure, 1 on success. */ -GC_API int GC_expand_hp(size_t number_of_bytes); +GC_API int GC_CALL GC_expand_hp(size_t number_of_bytes); /* Limit the heap size to n bytes. Useful when you're debugging, */ /* especially on systems that don't handle running out of memory well. */ /* n == 0 ==> unbounded. This is the default. */ -GC_API void GC_set_max_heap_size(GC_word n); +GC_API void GC_CALL GC_set_max_heap_size(GC_word n); /* Inform the collector that a certain section of statically allocated */ /* memory contains no pointers to garbage collected memory. Thus it */ /* need not be scanned. This is sometimes important if the application */ /* maps large read/write files into the address space, which could be */ /* mistaken for dynamic library data segments on some systems. */ -GC_API void GC_exclude_static_roots(void * low_address, +GC_API void GC_CALL GC_exclude_static_roots(void * low_address, void * high_address_plus_1); /* Clear the set of root segments. Wizards only. */ -GC_API void GC_clear_roots(void); +GC_API void GC_CALL GC_clear_roots(void); /* Add a root segment. Wizards only. */ -GC_API void GC_add_roots(void * low_address, void * high_address_plus_1); +GC_API void GC_CALL GC_add_roots(void * low_address, + void * high_address_plus_1); /* Remove a root segment. Wizards only. */ -GC_API void GC_remove_roots(void * low_address, void * high_address_plus_1); +GC_API void GC_CALL GC_remove_roots(void * low_address, + void * high_address_plus_1); /* Add a displacement to the set of those considered valid by the */ /* collector. GC_register_displacement(n) means that if p was returned */ @@ -380,14 +382,14 @@ GC_API void GC_remove_roots(void * low_address, void * high_address_plus_1); /* retention. */ /* This is a no-op if the collector has recognition of */ /* arbitrary interior pointers enabled, which is now the default. */ -GC_API void GC_register_displacement(size_t n); +GC_API void GC_CALL GC_register_displacement(size_t n); /* The following version should be used if any debugging allocation is */ /* being done. */ -GC_API void GC_debug_register_displacement(size_t n); +GC_API void GC_CALL GC_debug_register_displacement(size_t n); /* Explicitly trigger a full, world-stop collection. */ -GC_API void GC_gcollect(void); +GC_API void GC_CALL GC_gcollect(void); /* Trigger a full world-stopped collection. Abort the collection if */ /* and when stop_func returns a nonzero value. Stop_func will be */ @@ -398,32 +400,32 @@ GC_API void GC_gcollect(void); /* aborted collections do no useful work; the next collection needs */ /* to start from the beginning. */ /* Return 0 if the collection was aborted, 1 if it succeeded. */ -typedef int (* GC_stop_func)(void); -GC_API int GC_try_to_collect(GC_stop_func stop_func); +typedef int (GC_CALLBACK * GC_stop_func)(void); +GC_API int GC_CALL GC_try_to_collect(GC_stop_func stop_func); /* Return the number of bytes in the heap. Excludes collector private */ /* data structures. Includes empty blocks and fragmentation loss. */ /* Includes some pages that were allocated but never written. */ -GC_API size_t GC_get_heap_size(void); +GC_API size_t GC_CALL GC_get_heap_size(void); /* Return a lower bound on the number of free bytes in the heap. */ -GC_API size_t GC_get_free_bytes(void); +GC_API size_t GC_CALL GC_get_free_bytes(void); /* Return the number of bytes allocated since the last collection. */ -GC_API size_t GC_get_bytes_since_gc(void); +GC_API size_t GC_CALL GC_get_bytes_since_gc(void); /* Return the total number of bytes allocated in this process. */ /* Never decreases, except due to wrapping. */ -GC_API size_t GC_get_total_bytes(void); +GC_API size_t GC_CALL GC_get_total_bytes(void); /* Disable garbage collection. Even GC_gcollect calls will be */ /* ineffective. */ -GC_API void GC_disable(void); +GC_API void GC_CALL GC_disable(void); /* Re-enable garbage collection. GC_disable() and GC_enable() calls */ /* nest. Garbage collection is enabled if the number of calls to both */ /* both functions is equal. */ -GC_API void GC_enable(void); +GC_API void GC_CALL GC_enable(void); /* Enable incremental/generational collection. */ /* Not advisable unless dirty bits are */ @@ -440,7 +442,7 @@ GC_API void GC_enable(void); /* For best performance, should be called as early as possible. */ /* On some platforms, calling it later may have adverse effects.*/ /* Safe to call before GC_INIT(). Includes a GC_init() call. */ -GC_API void GC_enable_incremental(void); +GC_API void GC_CALL GC_enable_incremental(void); /* Does incremental mode write-protect pages? Returns zero or */ /* more of the following, or'ed together: */ @@ -450,7 +452,7 @@ GC_API void GC_enable_incremental(void); #define GC_PROTECTS_STACK 8 /* Probably impractical. */ #define GC_PROTECTS_NONE 0 -GC_API int GC_incremental_protection_needs(void); +GC_API int GC_CALL GC_incremental_protection_needs(void); /* Perform some garbage collection work, if appropriate. */ /* Return 0 if there is no more work to be done. */ @@ -459,7 +461,7 @@ GC_API int GC_incremental_protection_needs(void); /* progress requires it, e.g. if incremental collection is */ /* disabled. It is reasonable to call this in a wait loop */ /* until it returns 0. */ -GC_API int GC_collect_a_little(void); +GC_API int GC_CALL GC_collect_a_little(void); /* Allocate an object of size lb bytes. The client guarantees that */ /* as long as the object is live, it will be referenced by a pointer */ @@ -475,8 +477,8 @@ GC_API int GC_collect_a_little(void); /* for arrays likely to be larger than 100K or so. For other systems, */ /* or if the collector is not configured to recognize all interior */ /* pointers, the threshold is normally much higher. */ -GC_API void * GC_malloc_ignore_off_page(size_t lb); -GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb); +GC_API void * GC_CALL GC_malloc_ignore_off_page(size_t lb); +GC_API void * GC_CALL GC_malloc_atomic_ignore_off_page(size_t lb); #if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720 # define GC_ADD_CALLER @@ -541,22 +543,23 @@ GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb); /* Debugging (annotated) allocation. GC_gcollect will check */ /* objects allocated in this way for overwrites, etc. */ -GC_API void * GC_debug_malloc(size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API void * GC_debug_malloc_atomic(size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API char * GC_debug_strdup(const char *str, GC_EXTRA_PARAMS); -GC_API void * GC_debug_malloc_uncollectable +GC_API void * GC_CALL GC_debug_malloc(size_t size_in_bytes, GC_EXTRA_PARAMS); +GC_API void * GC_CALL GC_debug_malloc_atomic (size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API void * GC_debug_malloc_stubborn +GC_API char * GC_CALL GC_debug_strdup(const char *str, GC_EXTRA_PARAMS); +GC_API void * GC_CALL GC_debug_malloc_uncollectable (size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API void * GC_debug_malloc_ignore_off_page +GC_API void * GC_CALL GC_debug_malloc_stubborn (size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API void * GC_debug_malloc_atomic_ignore_off_page +GC_API void * GC_CALL GC_debug_malloc_ignore_off_page (size_t size_in_bytes, GC_EXTRA_PARAMS); -GC_API void GC_debug_free (void * object_addr); -GC_API void * GC_debug_realloc +GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page + (size_t size_in_bytes, GC_EXTRA_PARAMS); +GC_API void GC_CALL GC_debug_free (void * object_addr); +GC_API void * GC_CALL GC_debug_realloc (void * old_object, size_t new_size_in_bytes, GC_EXTRA_PARAMS); -GC_API void GC_debug_change_stubborn(void *); -GC_API void GC_debug_end_stubborn_change(void *); +GC_API void GC_CALL GC_debug_change_stubborn(void *); +GC_API void GC_CALL GC_debug_end_stubborn_change(void *); /* Routines that allocate objects with debug information (like the */ /* above), but just fill in dummy file and line number information. */ @@ -570,8 +573,8 @@ GC_API void GC_debug_end_stubborn_change(void *); /* platforms it may be more convenient not to recompile, e.g. for */ /* leak detection. This can be accomplished by instructing the */ /* linker to replace malloc/realloc with these. */ -GC_API void * GC_debug_malloc_replacement (size_t size_in_bytes); -GC_API void * GC_debug_realloc_replacement +GC_API void * GC_CALL GC_debug_malloc_replacement (size_t size_in_bytes); +GC_API void * GC_CALL GC_debug_realloc_replacement (void * object_addr, size_t size_in_bytes); # ifdef GC_DEBUG @@ -642,12 +645,13 @@ GC_API void * GC_debug_realloc_replacement /* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */ /* Christian Jacobi, and Russ Atkinson. It's not perfect, and */ /* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */ -typedef void (*GC_finalization_proc) (void * obj, void * client_data); +typedef void (GC_CALLBACK * GC_finalization_proc) (void * obj, + void * client_data); -GC_API void GC_register_finalizer(void * obj, GC_finalization_proc fn, +GC_API void GC_CALL GC_register_finalizer(void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); -GC_API void GC_debug_register_finalizer +GC_API void GC_CALL GC_debug_register_finalizer (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); /* When obj is no longer accessible, invoke */ @@ -692,10 +696,10 @@ GC_API void GC_debug_register_finalizer /* avoid cycles. */ /* Note that cd will still be viewed as accessible, even if it */ /* refers to the object itself. */ -GC_API void GC_register_finalizer_ignore_self +GC_API void GC_CALL GC_register_finalizer_ignore_self (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); -GC_API void GC_debug_register_finalizer_ignore_self +GC_API void GC_CALL GC_debug_register_finalizer_ignore_self (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); @@ -703,10 +707,10 @@ GC_API void GC_debug_register_finalizer_ignore_self /* It should probably only be used by Java implementations. */ /* Note that cd will still be viewed as accessible, even if it */ /* refers to the object itself. */ -GC_API void GC_register_finalizer_no_order +GC_API void GC_CALL GC_register_finalizer_no_order (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); -GC_API void GC_debug_register_finalizer_no_order +GC_API void GC_CALL GC_debug_register_finalizer_no_order (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); @@ -726,10 +730,10 @@ GC_API void GC_debug_register_finalizer_no_order /* Only works if GC_java_finalization is set. Probably only */ /* of interest when implementing a language that requires */ /* unordered finalization (e.g. Java, C#). */ -GC_API void GC_register_finalizer_unreachable +GC_API void GC_CALL GC_register_finalizer_unreachable (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); -GC_API void GC_debug_register_finalizer_unreachable +GC_API void GC_CALL GC_debug_register_finalizer_unreachable (void * obj, GC_finalization_proc fn, void * cd, GC_finalization_proc *ofn, void * *ocd); @@ -740,7 +744,7 @@ GC_API void GC_debug_register_finalizer_unreachable /* where p is a pointer that is not followed by finalization */ /* code, and should not be considered in determining */ /* finalization order. */ -GC_API int GC_register_disappearing_link(void * * link ); +GC_API int GC_CALL GC_register_disappearing_link(void * * link ); /* Link should point to a field of a heap allocated */ /* object obj. *link will be cleared when obj is */ /* found to be inaccessible. This happens BEFORE any */ @@ -761,7 +765,8 @@ GC_API int GC_register_disappearing_link(void * * link ); /* memory, and GC_oom_fn did not handle the problem. */ /* Only exists for backward compatibility. See below: */ -GC_API int GC_general_register_disappearing_link (void * * link, void * obj); +GC_API int GC_CALL GC_general_register_disappearing_link (void * * link, + void * obj); /* A slight generalization of the above. *link is */ /* cleared when obj first becomes inaccessible. This */ /* can be used to implement weak pointers easily and */ @@ -788,15 +793,15 @@ GC_API int GC_general_register_disappearing_link (void * * link, void * obj); /* decides to reclaim the object and the link is */ /* cleared. */ -GC_API int GC_unregister_disappearing_link (void * * link); +GC_API int GC_CALL GC_unregister_disappearing_link (void * * link); /* Returns 0 if link was not actually registered. */ /* Undoes a registration by either of the above two */ /* routines. */ /* Returns !=0 if GC_invoke_finalizers has something to do. */ -GC_API int GC_should_invoke_finalizers(void); +GC_API int GC_CALL GC_should_invoke_finalizers(void); -GC_API int GC_invoke_finalizers(void); +GC_API int GC_CALL GC_invoke_finalizers(void); /* Run finalizers for all objects that are ready to */ /* be finalized. Return the number of finalizers */ /* that were run. Normally this is also called */ @@ -817,19 +822,19 @@ GC_API int GC_invoke_finalizers(void); # define GC_reachable_here(ptr) \ __asm__ volatile(" " : : "X"(ptr) : "memory"); # else - GC_API void GC_noop1(GC_word x); + GC_API void GC_CALL GC_noop1(GC_word x); # define GC_reachable_here(ptr) GC_noop1((GC_word)(ptr)); #endif /* GC_set_warn_proc can be used to redirect or filter warning messages. */ /* p may not be a NULL pointer. */ -typedef void (*GC_warn_proc) (char *msg, GC_word arg); -GC_API GC_warn_proc GC_set_warn_proc(GC_warn_proc p); +typedef void (GC_CALLBACK * GC_warn_proc) (char *msg, GC_word arg); +GC_API GC_warn_proc GC_CALL GC_set_warn_proc(GC_warn_proc p); /* Returns old warning procedure. */ /* With 0 argument, current warn_proc remains unchanged. */ /* (Only true for GC7.2+) */ -GC_API GC_word GC_set_free_space_divisor(GC_word value); +GC_API GC_word GC_CALL GC_set_free_space_divisor(GC_word value); /* Set free_space_divisor. See above for definition. */ /* Returns old value. */ /* With zero argument, nothing is changed, but old value is */ @@ -852,8 +857,9 @@ GC_API GC_word GC_set_free_space_divisor(GC_word value); /* allocator lock to avoid a race with the collector. */ # endif /* I_HIDE_POINTERS */ -typedef void * (*GC_fn_type) (void * client_data); -GC_API void * GC_call_with_alloc_lock (GC_fn_type fn, void * client_data); +typedef void * (GC_CALLBACK * GC_fn_type) (void * client_data); +GC_API void * GC_CALL GC_call_with_alloc_lock (GC_fn_type fn, + void * client_data); /* These routines are intended to explicitly notify the collector */ /* of new threads. Often this is unnecessary because thread creation */ @@ -874,13 +880,15 @@ struct GC_stack_base { # endif }; -typedef void * (*GC_stack_base_func)(struct GC_stack_base *sb, void *arg); +typedef void * (GC_CALLBACK * GC_stack_base_func)(struct GC_stack_base *sb, + void *arg); /* Call a function with a stack base structure corresponding to */ /* somewhere in the GC_call_with_stack_base frame. This often can */ /* be used to provide a sufficiently accurate stack base. And we */ /* implement it everywhere. */ -GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg); +GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func fn, + void *arg); /* Register the current thread, with the indicated stack base, as */ /* a new thread whose stack(s) should be traced by the GC. If a */ @@ -893,7 +901,7 @@ GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg); #define GC_DUPLICATE 1 /* Was already registered. */ #define GC_NO_THREADS 2 /* No thread support in GC. */ #define GC_UNIMPLEMENTED 3 /* Not yet implemented on this platform. */ -GC_API int GC_register_my_thread(struct GC_stack_base *); +GC_API int GC_CALL GC_register_my_thread(struct GC_stack_base *); /* Unregister the current thread. The thread may no longer allocate */ /* garbage collected memory or manipulate pointers to the */ @@ -902,7 +910,7 @@ GC_API int GC_register_my_thread(struct GC_stack_base *); /* pointer to the garbage-collected heap to another thread, it must */ /* do this before calling GC_unregister_my_thread, most probably */ /* by saving it in a global data structure. */ -GC_API int GC_unregister_my_thread(void); +GC_API int GC_CALL GC_unregister_my_thread(void); /* Attempt to fill in the GC_stack_base structure with the stack base */ /* for this thread. This appears to be required to implement anything */ @@ -910,7 +918,7 @@ GC_API int GC_unregister_my_thread(void); /* threads are not automatically registered with the collector. */ /* It is also unfortunately hard to implement well on many platforms. */ /* Returns GC_SUCCESS or GC_UNIMPLEMENTED. */ -GC_API int GC_get_stack_base(struct GC_stack_base *); +GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *); /* The following routines are primarily intended for use with a */ /* preprocessor which inserts calls to check C pointer arithmetic. */ @@ -921,14 +929,14 @@ GC_API int GC_get_stack_base(struct GC_stack_base *); /* Returns the first argument. */ /* Succeeds if neither p nor q points to the heap. */ /* May succeed if both p and q point to between heap objects. */ -GC_API void * GC_same_obj (void * p, void * q); +GC_API void * GC_CALL GC_same_obj (void * p, void * q); /* Checked pointer pre- and post- increment operations. Note that */ /* the second argument is in units of bytes, not multiples of the */ /* object size. This should either be invoked from a macro, or the */ /* call should be automatically generated. */ -GC_API void * GC_pre_incr (void * *p, ptrdiff_t how_much); -GC_API void * GC_post_incr (void * *p, ptrdiff_t how_much); +GC_API void * GC_CALL GC_pre_incr (void * *p, ptrdiff_t how_much); +GC_API void * GC_CALL GC_post_incr (void * *p, ptrdiff_t how_much); /* Check that p is visible */ /* to the collector as a possibly pointer containing location. */ @@ -938,19 +946,19 @@ GC_API void * GC_post_incr (void * *p, ptrdiff_t how_much); /* untyped allocations. The idea is that it should be possible, though */ /* slow, to add such a call to all indirect pointer stores.) */ /* Currently useless for multithreaded worlds. */ -GC_API void * GC_is_visible (void * p); +GC_API void * GC_CALL GC_is_visible (void * p); /* Check that if p is a pointer to a heap page, then it points to */ /* a valid displacement within a heap object. */ /* Fail conspicuously if this property does not hold. */ /* Uninteresting with GC_all_interior_pointers. */ /* Always returns its argument. */ -GC_API void * GC_is_valid_displacement (void * p); +GC_API void * GC_CALL GC_is_valid_displacement (void * p); /* Explicitly dump the GC state. This is most often called from the */ /* debugger, or by setting the GC_DUMP_REGULARLY environment variable, */ /* but it may be useful to call it from client code during debugging. */ -GC_API void GC_dump(void); +GC_API void GC_CALL GC_dump(void); /* Safer, but slow, pointer addition. Probably useful mainly with */ /* a preprocessor. Useful only for heap pointers. */ @@ -995,11 +1003,11 @@ GC_API void GC_dump(void); #endif /* Functions called to report pointer checking errors */ -GC_API void (*GC_same_obj_print_proc) (void * p, void * q); +GC_API void (GC_CALLBACK * GC_same_obj_print_proc) (void * p, void * q); -GC_API void (*GC_is_valid_displacement_print_proc) (void * p); +GC_API void (GC_CALLBACK * GC_is_valid_displacement_print_proc) (void * p); -GC_API void (*GC_is_visible_print_proc) (void * p); +GC_API void (GC_CALLBACK * GC_is_visible_print_proc) (void * p); /* For pthread support, we generally need to intercept a number of */ @@ -1018,7 +1026,7 @@ GC_API void (*GC_is_visible_print_proc) (void * p); /* the allocation lock can be acquired and released many fewer times. */ /* It is used internally by gc_local_alloc.h, which provides a simpler */ /* programming interface on Linux. */ -GC_API void * GC_malloc_many(size_t lb); +GC_API void * GC_CALL GC_malloc_many(size_t lb); #define GC_NEXT(p) (*(void * *)(p)) /* Retrieve the next element */ /* in returned list. */ @@ -1029,9 +1037,8 @@ GC_API void * GC_malloc_many(size_t lb); first call a user-supplied routine with filename of the library and the address and length of the memory region. This routine should return nonzero if that region should be scanned. */ -GC_API void -GC_register_has_static_roots_callback - (int (*callback)(const char *, void *, size_t)); +GC_API void GC_CALL GC_register_has_static_roots_callback + (int (GC_CALLBACK * callback)(const char *, void *, size_t)); #if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) \ @@ -1075,12 +1082,12 @@ GC_register_has_static_roots_callback typedef uintptr_t GC_uintptr_t; # endif - GC_API GC_uintptr_t GC_beginthreadex( + GC_API GC_uintptr_t GC_CALL GC_beginthreadex( void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr); - GC_API void GC_endthreadex(unsigned retval); + GC_API void GC_CALL GC_endthreadex(unsigned retval); GC_API void WINAPI GC_ExitThread(DWORD dwExitCode); @@ -1106,7 +1113,7 @@ GC_register_has_static_roots_callback * Should be avoided if GC_beginthreadex and friends can be called * instead. */ -GC_API void GC_use_DllMain(void); +GC_API void GC_CALL GC_use_DllMain(void); # ifndef GC_NO_THREAD_REDIRECTS # define CreateThread GC_CreateThread @@ -1159,7 +1166,7 @@ GC_API void GC_use_DllMain(void); /* win32S may not free all resources on process exit. */ /* This explicitly deallocates the heap. */ -GC_API void GC_win32_free_heap(void); +GC_API void GC_CALL GC_win32_free_heap(void); #if ( defined(_AMIGA) && !defined(GC_AMIGA_MAKINGLIB) ) /* Allocation really goes through GC_amiga_allocwrapper_do */ diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index 6bafdc28..98aeef38 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -175,6 +175,13 @@ #endif #ifndef GC_API -#define GC_API extern +# define GC_API extern #endif +#ifndef GC_CALL +# define GC_CALL +#endif + +#ifndef GC_CALLBACK +# define GC_CALLBACK GC_CALL +#endif diff --git a/include/gc_cpp.h b/include/gc_cpp.h index 86a756bc..4a5bc7cb 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -141,7 +141,7 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined. #include "gc.h" #ifndef THINK_CPLUS -# define GC_cdecl +# define GC_cdecl GC_CALLBACK #else # define GC_cdecl _cdecl #endif @@ -212,7 +212,9 @@ private: member derived from "gc_cleanup", its destructors will be invoked. */ -extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );} +extern "C" { + typedef void (GC_CALLBACK * GCCleanUpFunc)( void* obj, void* clientData ); +} #ifdef _MSC_VER // Disable warning that "no matching operator delete found; memory will @@ -339,7 +341,7 @@ inline void gc::operator delete[]( void* obj ) { inline gc_cleanup::~gc_cleanup() { GC_register_finalizer_ignore_self( GC_base(this), 0, 0, 0, 0 );} -inline void gc_cleanup::cleanup( void* obj, void* displ ) { +inline void GC_CALLBACK gc_cleanup::cleanup( void* obj, void* displ ) { ((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();} inline gc_cleanup::gc_cleanup() { diff --git a/include/gc_gcj.h b/include/gc_gcj.h index f018a061..e715b5d7 100644 --- a/include/gc_gcj.h +++ b/include/gc_gcj.h @@ -58,21 +58,23 @@ /* detect the presence or absence of the debug header. */ /* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */ /* want to include that here for namespace pollution reasons. */ -GC_API void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp); +GC_API void GC_CALL GC_init_gcj_malloc(int mp_index, + void * /* really mark_proc */mp); /* Allocate an object, clear it, and store the pointer to the */ /* type structure (vtable in gcj). */ /* This adds a byte at the end of the object if GC_malloc would.*/ -GC_API void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr); +GC_API void * GC_CALL GC_gcj_malloc(size_t lb, + void * ptr_to_struct_containing_descr); /* The debug versions allocate such that the specified mark_proc */ /* is always invoked. */ -GC_API void * GC_debug_gcj_malloc(size_t lb, +GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr, GC_EXTRA_PARAMS); /* Similar to GC_gcj_malloc, but assumes that a pointer to near the */ /* beginning of the resulting object is always maintained. */ -GC_API void * GC_gcj_malloc_ignore_off_page(size_t lb, +GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb, void * ptr_to_struct_containing_descr); /* The kind numbers of normal and debug gcj objects. */ diff --git a/include/gc_mark.h b/include/gc_mark.h index 2ec4e391..71e62dbe 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -180,7 +180,7 @@ unsigned GC_new_proc_inner(GC_mark_proc); /* cause a GC crash if they are accidentally traced. */ void * GC_generic_malloc(size_t lb, int k); -typedef void (*GC_describe_type_fn) (void *p, char *out_buf); +typedef void (GC_CALLBACK * GC_describe_type_fn) (void *p, char *out_buf); /* A procedure which */ /* produces a human-readable */ /* description of the "type" of object */ @@ -194,7 +194,7 @@ typedef void (*GC_describe_type_fn) (void *p, char *out_buf); /* global free list. */ # define GC_TYPE_DESCR_LEN 40 -void GC_register_describe_type_fn(int kind, GC_describe_type_fn knd); +void GC_CALL GC_register_describe_type_fn(int kind, GC_describe_type_fn knd); /* Register a describe_type function */ /* to be used when printing objects */ /* of a particular kind. */ diff --git a/include/gc_typed.h b/include/gc_typed.h index 30e05a9a..323d9a99 100644 --- a/include/gc_typed.h +++ b/include/gc_typed.h @@ -47,7 +47,7 @@ typedef GC_word * GC_bitmap; typedef GC_word GC_descr; -GC_API GC_descr GC_make_descriptor(GC_bitmap bm, size_t len); +GC_API GC_descr GC_CALL GC_make_descriptor(GC_bitmap bm, size_t len); /* Return a type descriptor for the object whose layout */ /* is described by the argument. */ /* The least significant bit of the first word is one */ @@ -74,15 +74,16 @@ GC_API GC_descr GC_make_descriptor(GC_bitmap bm, size_t len); /* ... */ /* T_descr = GC_make_descriptor(T_bitmap, GC_WORD_LEN(T)); */ -GC_API void * GC_malloc_explicitly_typed(size_t size_in_bytes, GC_descr d); +GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t size_in_bytes, + GC_descr d); /* Allocate an object whose layout is described by d. */ /* The resulting object MAY NOT BE PASSED TO REALLOC. */ /* The returned object is cleared. */ -GC_API void * GC_malloc_explicitly_typed_ignore_off_page +GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page (size_t size_in_bytes, GC_descr d); -GC_API void * GC_calloc_explicitly_typed(size_t nelements, +GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t nelements, size_t element_size_in_bytes, GC_descr d); /* Allocate an array of nelements elements, each of the */ diff --git a/include/javaxfc.h b/include/javaxfc.h index fc57b6a9..ac8d81ab 100644 --- a/include/javaxfc.h +++ b/include/javaxfc.h @@ -20,7 +20,7 @@ * probably unlikely. * Thus this is not recommended for general use. */ -GC_API void GC_finalize_all(void); +GC_API void GC_CALL GC_finalize_all(void); # ifdef __cplusplus } /* end of extern "C" */ diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index edee1854..467c1a53 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -29,7 +29,7 @@ # ifdef THREADS # include - void GC_noop1(word); + GC_API void GC_CALL GC_noop1(word); # ifdef PCR # include # include diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 3cb91ff8..b803469e 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1649,7 +1649,7 @@ ptr_t GC_reclaim_generic(struct hblk * hbp, hdr *hhdr, size_t sz, /* reclaimed bytes to *count. */ GC_bool GC_block_empty(hdr * hhdr); /* Block completely unmarked? */ -GC_bool GC_never_stop_func(void); +GC_bool GC_CALLBACK GC_never_stop_func(void); /* Returns FALSE. */ GC_bool GC_try_to_collect_inner(GC_stop_func f); @@ -1760,7 +1760,7 @@ void GC_notify_or_invoke_finalizers(void); /* this procedure yet this GC cycle. */ GC_API void * GC_make_closure(GC_finalization_proc fn, void * data); -GC_API void GC_debug_invoke_finalizer(void * obj, void * data); +GC_API void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data); /* Auxiliary fns to make finalization work */ /* correctly with displaced pointers introduced */ /* by the debugging allocators. */ @@ -1923,7 +1923,7 @@ void GC_print_finalization_stats(void); # endif # endif -void GC_noop1(word); +GC_API void GC_CALL GC_noop1(word); /* Logging and diagnostic output: */ GC_API void GC_printf (const char * format, ...); diff --git a/malloc.c b/malloc.c index 67e74223..9928ea21 100644 --- a/malloc.c +++ b/malloc.c @@ -206,7 +206,7 @@ void * GC_generic_malloc(size_t lb, int k) #ifdef THREAD_LOCAL_ALLOC void * GC_core_malloc_atomic(size_t lb) #else - GC_API void * GC_malloc_atomic(size_t lb) + GC_API void * GC_CALL GC_malloc_atomic(size_t lb) #endif { void *op; @@ -233,7 +233,7 @@ void * GC_generic_malloc(size_t lb, int k) /* provide a version of strdup() that uses the collector to allocate the copy of the string */ -GC_API char *GC_strdup(const char *s) +GC_API char * GC_CALL GC_strdup(const char *s) { char *copy; @@ -250,7 +250,7 @@ GC_API char *GC_strdup(const char *s) #ifdef THREAD_LOCAL_ALLOC void * GC_core_malloc(size_t lb) #else - GC_API void * GC_malloc(size_t lb) + GC_API void * GC_CALL GC_malloc(size_t lb) #endif { void *op; @@ -386,7 +386,7 @@ void * calloc(size_t n, size_t lb) # endif /* REDIRECT_MALLOC */ /* Explicitly deallocate an object p. */ -GC_API void GC_free(void * p) +GC_API void GC_CALL GC_free(void * p) { struct hblk *h; hdr *hhdr; diff --git a/mallocx.c b/mallocx.c index 71fb19a9..a289ade0 100644 --- a/mallocx.c +++ b/mallocx.c @@ -64,7 +64,7 @@ STATIC void * GC_generic_or_special_malloc(size_t lb, int knd) /* lb bytes. The object may be (and quite likely will be) moved. */ /* The kind (e.g. atomic) is the same as that of the old. */ /* Shrinking of large blocks is not implemented well. */ -GC_API void * GC_realloc(void * p, size_t lb) +GC_API void * GC_CALL GC_realloc(void * p, size_t lb) { struct hblk * h; hdr * hhdr; @@ -209,12 +209,12 @@ void * GC_generic_malloc_ignore_off_page(size_t lb, int k) } } -GC_API void * GC_malloc_ignore_off_page(size_t lb) +GC_API void * GC_CALL GC_malloc_ignore_off_page(size_t lb) { return((void *)GC_generic_malloc_ignore_off_page(lb, NORMAL)); } -GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb) +GC_API void * GC_CALL GC_malloc_atomic_ignore_off_page(size_t lb) { return((void *)GC_generic_malloc_ignore_off_page(lb, PTRFREE)); } @@ -419,7 +419,7 @@ DCL_LOCK_STATE; (void) GC_clear_stack(0); } -GC_API void * GC_malloc_many(size_t lb) +GC_API void * GC_CALL GC_malloc_many(size_t lb) { void *result; GC_generic_malloc_many(((lb + EXTRA_BYTES + GRANULE_BYTES-1) @@ -433,7 +433,7 @@ GC_API void * GC_malloc_many(size_t lb) # endif /* Allocate lb bytes of pointerful, traced, but not collectable data */ -GC_API void * GC_malloc_uncollectable(size_t lb) +GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb) { void *op; void **opp; @@ -521,7 +521,7 @@ void * GC_memalign(size_t align, size_t lb) /* Allocate lb bytes of pointerfree, untraced, uncollectable data */ /* This is normally roughly equivalent to the system malloc. */ /* But it may be useful if malloc is redefined. */ -GC_API void * GC_malloc_atomic_uncollectable(size_t lb) +GC_API void * GC_CALL GC_malloc_atomic_uncollectable(size_t lb) { void *op; void **opp; diff --git a/mark.c b/mark.c index 37c76a53..e646b66e 100644 --- a/mark.c +++ b/mark.c @@ -32,7 +32,7 @@ #endif /* Single argument version, robust against whole program analysis. */ -GC_API void GC_noop1(word x) +GC_API void GC_CALL GC_noop1(word x) { static volatile word sink; diff --git a/mark_rts.c b/mark_rts.c index ad10bb4b..5bb5639e 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -142,7 +142,7 @@ static void add_roots_to_index(struct roots *p) word GC_root_size = 0; -GC_API void GC_add_roots(void *b, void *e) +GC_API void GC_CALL GC_add_roots(void *b, void *e) { DCL_LOCK_STATE; @@ -242,7 +242,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_clear_roots (void) +GC_API void GC_CALL GC_clear_roots (void) { DCL_LOCK_STATE; @@ -303,7 +303,7 @@ STATIC void GC_remove_tmp_roots(void) #endif #if !defined(MSWIN32) && !defined(MSWINCE) -GC_API void GC_remove_roots(void *b, void *e) +GC_API void GC_CALL GC_remove_roots(void *b, void *e) { DCL_LOCK_STATE; @@ -406,7 +406,7 @@ STATIC struct exclusion * GC_next_exclusion(ptr_t start_addr) return GC_excl_table + low; } -GC_API void GC_exclude_static_roots(void *start, void *finish) +GC_API void GC_CALL GC_exclude_static_roots(void *start, void *finish) { struct exclusion * next; size_t next_index, i; diff --git a/misc.c b/misc.c index 1488c3d8..3ed1e402 100644 --- a/misc.c +++ b/misc.c @@ -123,7 +123,7 @@ long GC_large_alloc_warn_suppressed = 0; /* Number of warnings suppressed so far. */ /*ARGSUSED*/ -STATIC void * GC_default_oom_fn(size_t bytes_requested) +STATIC void * GC_CALLBACK GC_default_oom_fn(size_t bytes_requested) { return(0); } @@ -324,7 +324,7 @@ void * GC_clear_stack(void *arg) /* Return a pointer to the base address of p, given a pointer to a */ /* an address within an object. Return 0 o.w. */ -GC_API void * GC_base(void * p) +GC_API void * GC_CALL GC_base(void * p) { ptr_t r; struct hblk *h; @@ -367,29 +367,29 @@ GC_API void * GC_base(void * p) /* Return the size of an object, given a pointer to its base. */ /* (For small objects this also happens to work from interior pointers, */ /* but that shouldn't be relied upon.) */ -GC_API size_t GC_size(void * p) +GC_API size_t GC_CALL GC_size(void * p) { hdr * hhdr = HDR(p); return hhdr -> hb_sz; } -GC_API size_t GC_get_heap_size(void) +GC_API size_t GC_CALL GC_get_heap_size(void) { return GC_heapsize; } -GC_API size_t GC_get_free_bytes(void) +GC_API size_t GC_CALL GC_get_free_bytes(void) { return GC_large_free_bytes; } -GC_API size_t GC_get_bytes_since_gc(void) +GC_API size_t GC_CALL GC_get_bytes_since_gc(void) { return GC_bytes_allocd; } -GC_API size_t GC_get_total_bytes(void) +GC_API size_t GC_CALL GC_get_total_bytes(void) { return GC_bytes_allocd+GC_bytes_allocd_before_gc; } @@ -401,7 +401,7 @@ GC_bool GC_is_initialized = FALSE; # endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */ /* FIXME: The GC_init/GC_init_inner distinction should go away. */ -GC_API void GC_init(void) +GC_API void GC_CALL GC_init(void) { /* LOCK(); -- no longer does anything this early. */ GC_init_inner(); @@ -761,7 +761,7 @@ void GC_init_inner(void) # endif } -GC_API void GC_enable_incremental(void) +GC_API void GC_CALL GC_enable_incremental(void) { # if !defined(SMALL_CONFIG) && !defined(KEEP_BACK_PTRS) /* If we are keeping back pointers, the GC itself dirties all */ @@ -1009,14 +1009,14 @@ void GC_err_write(const char *buf, size_t len) } #endif -STATIC void GC_default_warn_proc(char *msg, GC_word arg) +STATIC void GC_CALLBACK GC_default_warn_proc(char *msg, GC_word arg) { GC_err_printf(msg, arg); } GC_warn_proc GC_current_warn_proc = GC_default_warn_proc; -GC_API GC_warn_proc GC_set_warn_proc(GC_warn_proc p) +GC_API GC_warn_proc GC_CALL GC_set_warn_proc(GC_warn_proc p) { GC_warn_proc result; @@ -1031,7 +1031,7 @@ GC_API GC_warn_proc GC_set_warn_proc(GC_warn_proc p) return(result); } -GC_API GC_word GC_set_free_space_divisor (GC_word value) +GC_API GC_word GC_CALL GC_set_free_space_divisor (GC_word value) { GC_word old = GC_free_space_divisor; if (value != ~(GC_word)0) @@ -1062,14 +1062,14 @@ void GC_abort(const char *msg) } #endif -GC_API void GC_enable(void) +GC_API void GC_CALL GC_enable(void) { LOCK(); GC_dont_gc--; UNLOCK(); } -GC_API void GC_disable(void) +GC_API void GC_CALL GC_disable(void) { LOCK(); GC_dont_gc++; @@ -1135,7 +1135,7 @@ unsigned GC_new_proc(GC_mark_proc proc) return result; } -GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg) +GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func fn, void *arg) { int dummy; struct GC_stack_base base; @@ -1151,7 +1151,7 @@ GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg) #if !defined(NO_DEBUGGING) -GC_API void GC_dump(void) +GC_API void GC_CALL GC_dump(void) { GC_printf("***Static roots:\n"); GC_print_static_roots(); @@ -1167,17 +1167,17 @@ GC_API void GC_dump(void) #endif /* NO_DEBUGGING */ -GC_API GC_word GC_get_gc_no(void) +GC_API GC_word GC_CALL GC_get_gc_no(void) { return GC_gc_no; } -GC_API int GC_get_parallel(void) +GC_API int GC_CALL GC_get_parallel(void) { return GC_parallel; } -GC_API GC_oom_func GC_set_oom_fn(GC_oom_func fn) +GC_API GC_oom_func GC_CALL GC_set_oom_fn(GC_oom_func fn) { GC_oom_func ofn = GC_oom_fn; if (fn != (GC_oom_func)0) @@ -1185,7 +1185,7 @@ GC_API GC_oom_func GC_set_oom_fn(GC_oom_func fn) return ofn; } -GC_API GC_finalizer_notifier_proc GC_set_finalizer_notifier( +GC_API GC_finalizer_notifier_proc GC_CALL GC_set_finalizer_notifier( GC_finalizer_notifier_proc fn) { GC_finalizer_notifier_proc ofn = GC_finalizer_notifier; @@ -1194,7 +1194,7 @@ GC_API GC_finalizer_notifier_proc GC_set_finalizer_notifier( return ofn; } -GC_API int GC_set_finalize_on_demand(int value) +GC_API int GC_CALL GC_set_finalize_on_demand(int value) { int ovalue = GC_finalize_on_demand; if (value != -1) @@ -1202,7 +1202,7 @@ GC_API int GC_set_finalize_on_demand(int value) return ovalue; } -GC_API int GC_set_java_finalization(int value) +GC_API int GC_CALL GC_set_java_finalization(int value) { int ovalue = GC_java_finalization; if (value != -1) @@ -1210,7 +1210,7 @@ GC_API int GC_set_java_finalization(int value) return ovalue; } -GC_API int GC_set_dont_expand(int value) +GC_API int GC_CALL GC_set_dont_expand(int value) { int ovalue = GC_dont_expand; if (value != -1) @@ -1218,7 +1218,7 @@ GC_API int GC_set_dont_expand(int value) return ovalue; } -GC_API int GC_set_no_dls(int value) +GC_API int GC_CALL GC_set_no_dls(int value) { int ovalue = GC_no_dls; if (value != -1) @@ -1226,7 +1226,7 @@ GC_API int GC_set_no_dls(int value) return ovalue; } -GC_API GC_word GC_set_max_retries(GC_word value) +GC_API GC_word GC_CALL GC_set_max_retries(GC_word value) { GC_word ovalue = GC_max_retries; if (value != ~(GC_word)0) @@ -1234,7 +1234,7 @@ GC_API GC_word GC_set_max_retries(GC_word value) return ovalue; } -GC_API int GC_set_dont_precollect(int value) +GC_API int GC_CALL GC_set_dont_precollect(int value) { int ovalue = GC_dont_precollect; if (value != -1) diff --git a/obj_map.c b/obj_map.c index 0f66b138..8198a7e5 100644 --- a/obj_map.c +++ b/obj_map.c @@ -24,7 +24,7 @@ /* Consider pointers that are offset bytes displaced from the beginning */ /* of an object to be valid. */ -GC_API void GC_register_displacement(size_t offset) +GC_API void GC_CALL GC_register_displacement(size_t offset) { DCL_LOCK_STATE; diff --git a/os_dep.c b/os_dep.c index c795edb0..2787b8cb 100644 --- a/os_dep.c +++ b/os_dep.c @@ -653,7 +653,7 @@ STATIC word GC_get_writable_length(ptr_t p, ptr_t *base) return(buf.RegionSize); } -GC_API int GC_get_stack_base(struct GC_stack_base *sb) +GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) { int dummy; ptr_t sp = (ptr_t)(&dummy); @@ -1072,7 +1072,7 @@ ptr_t GC_get_main_stack_base(void) /* From pthread_support.c */ #endif -GC_API int GC_get_stack_base(struct GC_stack_base *b) +GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b) { pthread_attr_t attr; size_t size; @@ -1122,7 +1122,7 @@ GC_API int GC_get_stack_base(struct GC_stack_base *b) /* next. Thus this is likely to identify way too large a */ /* "stack" and thus at least result in disastrous performance. */ /* FIXME - Implement better strategies here. */ -GC_API int GC_get_stack_base(struct GC_stack_base *b) +GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b) { # ifdef NEED_FIND_LIMIT int dummy; @@ -1871,7 +1871,7 @@ ptr_t GC_win32_get_mem(word bytes) return(result); } -GC_API void GC_win32_free_heap(void) +GC_API void GC_CALL GC_win32_free_heap(void) { if (GC_no_win32_dlls) { while (GC_n_heap_bases > 0) { @@ -2882,7 +2882,7 @@ void GC_dirty_init(void) } #endif /* !DARWIN */ -GC_API int GC_incremental_protection_needs(void) +GC_API int GC_CALL GC_incremental_protection_needs(void) { if (GC_page_size == HBLKSIZE) { return GC_PROTECTS_POINTER_HEAP; @@ -3895,7 +3895,7 @@ catch_exception_raise_state_identity(mach_port_name_t exception_port, #endif /* DARWIN && MPROTECT_VDB */ # ifndef HAVE_INCREMENTAL_PROTECTION_NEEDS - GC_API int GC_incremental_protection_needs(void) + GC_API int GC_CALL GC_incremental_protection_needs(void) { return GC_PROTECTS_NONE; } diff --git a/pthread_support.c b/pthread_support.c index 7925c605..0e92a851 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -870,7 +870,7 @@ int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset) /* length of time. */ struct blocking_data { - void (*fn)(void *); + void (GC_CALLBACK *fn)(void *); void *arg; }; @@ -897,7 +897,7 @@ static void GC_do_blocking_inner(ptr_t data, void * context) { UNLOCK(); } -void GC_do_blocking(void (*fn)(void *), void *arg) { +void GC_CALL GC_do_blocking(void (GC_CALLBACK *fn)(void *), void *arg) { struct blocking_data my_data; my_data.fn = fn; @@ -913,7 +913,7 @@ struct start_info { /* parent hasn't yet noticed. */ }; -GC_API int GC_unregister_my_thread(void) +GC_API int GC_CALL GC_unregister_my_thread(void) { GC_thread me; @@ -1024,7 +1024,7 @@ STATIC GC_thread GC_register_my_thread_inner(struct GC_stack_base *sb, return me; } -GC_API int GC_register_my_thread(struct GC_stack_base *sb) +GC_API int GC_CALL GC_register_my_thread(struct GC_stack_base *sb) { pthread_t my_pthread = pthread_self(); GC_thread me; @@ -1047,7 +1047,8 @@ GC_API int GC_register_my_thread(struct GC_stack_base *sb) } } -STATIC void * GC_inner_start_routine(struct GC_stack_base *sb, void * arg) +STATIC void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, + void * arg) { struct start_info * si = arg; void * result; diff --git a/ptr_chck.c b/ptr_chck.c index 9d8faa00..a28e027d 100644 --- a/ptr_chck.c +++ b/ptr_chck.c @@ -18,13 +18,13 @@ #include "private/gc_pmark.h" -STATIC void GC_default_same_obj_print_proc(void * p, void * q) +STATIC void GC_CALLBACK GC_default_same_obj_print_proc(void * p, void * q) { GC_err_printf("%p and %p are not in the same object\n", p, q); ABORT("GC_same_obj test failed"); } -void (*GC_same_obj_print_proc) (void *, void *) +void (GC_CALLBACK *GC_same_obj_print_proc) (void *, void *) = GC_default_same_obj_print_proc; /* Check that p and q point to the same object. Call */ @@ -36,7 +36,7 @@ void (*GC_same_obj_print_proc) (void *, void *) /* We assume this is performance critical. (It shouldn't */ /* be called by production code, but this can easily make */ /* debugging intolerably slow.) */ -GC_API void * GC_same_obj(void *p, void *q) +GC_API void * GC_CALL GC_same_obj(void *p, void *q) { struct hblk *h; hdr *hhdr; @@ -99,13 +99,13 @@ fail: return(p); } -STATIC void GC_default_is_valid_displacement_print_proc (void *p) +STATIC void GC_CALLBACK GC_default_is_valid_displacement_print_proc (void *p) { GC_err_printf("%p does not point to valid object displacement\n", p); ABORT("GC_is_valid_displacement test failed"); } -void (*GC_is_valid_displacement_print_proc)(void *) = +void (GC_CALLBACK *GC_is_valid_displacement_print_proc)(void *) = GC_default_is_valid_displacement_print_proc; /* Check that if p is a pointer to a heap page, then it points to */ @@ -114,7 +114,7 @@ void (*GC_is_valid_displacement_print_proc)(void *) = /* Always returns its argument. */ /* Note that we don't lock, since nothing relevant about the header */ /* should change while we have a valid object pointer to the block. */ -GC_API void * GC_is_valid_displacement(void *p) +GC_API void * GC_CALL GC_is_valid_displacement(void *p) { hdr *hhdr; word pdispl; @@ -149,13 +149,14 @@ fail: return(p); } -STATIC void GC_default_is_visible_print_proc(void * p) +STATIC void GC_CALLBACK GC_default_is_visible_print_proc(void * p) { GC_err_printf("%p is not a GC visible pointer location\n", p); ABORT("GC_is_visible test failed"); } -void (*GC_is_visible_print_proc)(void * p) = GC_default_is_visible_print_proc; +void (GC_CALLBACK *GC_is_visible_print_proc)(void * p) = + GC_default_is_visible_print_proc; #ifndef THREADS /* Could p be a stack address? */ @@ -183,7 +184,7 @@ void (*GC_is_visible_print_proc)(void * p) = GC_default_is_visible_print_proc; /* untyped allocations. The idea is that it should be possible, though */ /* slow, to add such a call to all indirect pointer stores.) */ /* Currently useless for multithreaded worlds. */ -GC_API void * GC_is_visible(void *p) +GC_API void * GC_CALL GC_is_visible(void *p) { hdr *hhdr; @@ -255,7 +256,7 @@ fail: } -GC_API void * GC_pre_incr (void **p, ptrdiff_t how_much) +GC_API void * GC_CALL GC_pre_incr (void **p, ptrdiff_t how_much) { void * initial = *p; void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial); @@ -266,7 +267,7 @@ GC_API void * GC_pre_incr (void **p, ptrdiff_t how_much) return (*p = result); } -GC_API void * GC_post_incr (void **p, ptrdiff_t how_much) +GC_API void * GC_CALL GC_post_incr (void **p, ptrdiff_t how_much) { void * initial = *p; void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial); diff --git a/stubborn.c b/stubborn.c index e3f664c7..e5d08e20 100644 --- a/stubborn.c +++ b/stubborn.c @@ -22,35 +22,35 @@ /* MANUAL_VDB. But that imposes the additional constraint that */ /* written, but not yet GC_dirty()ed objects must be referenced */ /* by a stack. */ -GC_API void * GC_malloc_stubborn(size_t lb) +GC_API void * GC_CALL GC_malloc_stubborn(size_t lb) { return(GC_malloc(lb)); } -GC_API void GC_end_stubborn_change(void *p) +GC_API void GC_CALL GC_end_stubborn_change(void *p) { GC_dirty(p); } /*ARGSUSED*/ -GC_API void GC_change_stubborn(void *p) +GC_API void GC_CALL GC_change_stubborn(void *p) { } #else /* !MANUAL_VDB */ -GC_API void * GC_malloc_stubborn(size_t lb) +GC_API void * GC_CALL GC_malloc_stubborn(size_t lb) { return(GC_malloc(lb)); } /*ARGSUSED*/ -GC_API void GC_end_stubborn_change(void *p) +GC_API void GC_CALL GC_end_stubborn_change(void *p) { } /*ARGSUSED*/ -GC_API void GC_change_stubborn(void *p) +GC_API void GC_CALL GC_change_stubborn(void *p) { } diff --git a/tests/test.c b/tests/test.c index 7379f36f..4f14b9fd 100644 --- a/tests/test.c +++ b/tests/test.c @@ -63,9 +63,7 @@ static CRITICAL_SECTION incr_cs; # endif -#ifdef __STDC__ # include -#endif /* Call GC_INIT only on platforms on which we think we really need it, */ /* so that we can test automatic initialization on the rest. */ @@ -128,6 +126,9 @@ int realloc_count = 0; # ifdef MSWINCE # define FAIL DebugBreak() # else +# ifdef SMALL_CONFIG + void GC_abort(const char * msg); +# endif # define FAIL GC_abort("Test failed"); # endif # endif @@ -280,7 +281,6 @@ sexpr gcj_cons(sexpr x, sexpr y) { GC_word * r; sexpr result; - static int count = 0; r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR) + sizeof(struct fake_vtable*), @@ -575,11 +575,8 @@ void reverse_test() c = (sexpr)((char *)c + sizeof(char *)); d = (sexpr)((char *)d + sizeof(char *)); -# ifdef __STDC__ - GC_FREE((void *)e); -# else - GC_FREE((char *)e); -# endif + GC_FREE((void *)e); + check_ints(b,1,50); check_ints(a,1,49); for (i = 0; i < 50; i++) { @@ -637,13 +634,7 @@ int finalizable_count = 0; int finalized_count = 0; volatile int dropped_something = 0; -# ifdef __STDC__ - void finalizer(void * obj, void * client_data) -# else - void finalizer(obj, client_data) - char * obj; - char * client_data; -# endif +void GC_CALLBACK finalizer(void * obj, void * client_data) { tn * t = (tn *)obj; @@ -981,18 +972,8 @@ void typed_test() int fail_count = 0; -#ifndef __STDC__ -/*ARGSUSED*/ -void fail_proc1(x) -void * x; -{ - fail_count++; -} - -#else - /*ARGSUSED*/ -void fail_proc1(void * x) +void GC_CALLBACK fail_proc1(void * x) { fail_count++; } @@ -1003,7 +984,7 @@ static void uniq(void *p, ...) { int n = 0, i, j; q[n++] = p; va_start(a,p); - for (;(q[n] = va_arg(a,void *));n++) ; + for (;(q[n] = va_arg(a,void *)) != NULL;n++) ; va_end(a); for (i=0; i