Issue #206 (bdwgc).
* alloc.c (GC_copyright): Change type from char* const to
const char* const.
* alloc.c (GC_set_fl_marks, GC_clear_fl_marks, GC_finish_collection,
GC_allocobj): Add missing explicit casts from void* to ptr_t.
* backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Likewise.
* blacklst.c (GC_default_print_heap_obj_proc,
GC_print_blacklisted_ptr): Likewise.
* dbg_mlc.c (GC_get_back_ptr_info, GC_store_debug_info_inner,
GC_store_debug_info, GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable,
GC_debug_free, GC_debug_free_inner, GC_debug_register_finalizer,
GC_debug_register_finalizer_no_order,
GC_debug_register_finalizer_unreachable,
GC_debug_register_finalizer_ignore_self): Likewise.
* finalize.c (GC_grow_table, push_and_mark_object,
ensure_toggleref_capacity, GC_dump_finalization_links,
GC_dump_finalization, GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links, GC_finalize): Likewise.
* gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise.
* mallocx.c (GC_memalign): Likewise.
* mark.c (GC_mark_from, GC_mark_and_push, GC_push_all_eager,
GC_push_all_stack, GC_push_marked1, GC_push_marked2, GC_push_marked4):
Likewise.
* mark_rts.c (GC_exclude_static_roots_inner): Likewise.
* misc.c (GC_base): Likewise.
* new_hblk.c (GC_new_hblk): Likewise.
* pthread_support.c (GC_register_altstack, GC_thr_init,
GC_record_stack_base): Likewise.
* ptr_chck.c (GC_is_visible): Likewise.
* reclaim.c (GC_reclaim_small_nonempty_block,
GC_disclaim_and_reclaim_or_free_small_block): Likewise.
* thread_local_alloc.c (GC_mark_thread_local_fls_for): Likewise.
* typd_mlc.c (GC_typed_mark_proc,
GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* win32_threads.c (GC_record_stack_base, GC_get_stack_min,
GC_push_stack_for): Likewise.
* blacklst.c (GC_copy_bl): Rename "new" argument to "dest".
* dbg_mlc.c (GC_store_debug_info_inner, GC_print_smashed_obj): Change
type of p argument from ptr_t to void*.
* include/private/gc_priv.h (GC_is_heap_base, GC_is_static_root):
Likewise.
* mark_rts.c [!THREADS] (GC_is_static_root): Likewise.
* os_dep.c (GC_is_malloc_heap_base, GC_is_heap_base): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* dbg_mlc.c (GC_print_obj): Change type of kind_str local variable
from char* to const char*.
* dbg_mlc.c (GC_debug_strdup, GC_debug_strndup): Cast result of
GC_debug_malloc_atomic() to char*.
* mallocx.c (GC_strdup, GC_strndup): Likewise.
* dbg_mlc.c (GC_debug_wcsdup): Cast result of GC_debug_malloc_atomic()
to wchar_t*.
* mallocx.c (GC_wcsdup): Likewise.
* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]
(GC_register_dynamic_libraries): Cast p local variable to char*.
* os_dep.c (GC_register_data_segments): Likewise.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Cast masked
fc_word to struct GC_finalizer_closure* (instead of void*).
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Cast result of
GC_malloc_kind() to word*.
* typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed):
Likewise.
* include/private/gc_priv.h (WARN): Cast away const qualifier for msg
(and the string literal).
* misc.c (GC_default_on_abort): Remove cast to void* for WRITE()
buf argument.
* misc.c (GC_new_free_list_inner): Cast result local variable to void**.
* misc.c (GC_new_free_list): Change type of result local variable from
void* to void**.
* pthread_support.c (GC_start_rtn_prepare_thread): Cast arg to
struct start_info*.
* win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Likewise.
* reclaim.c (GC_print_free_list): Replace ptr_t flh to void *flh_next
local variable; remove redundant casts.
* tools/if_mach.c (EXECV_ARGV_T): New macro; add comment.
* tools/if_not_there.c (EXECV_ARGV_T): Likewise.
* tools/if_mach.c (main): Use EXECV_ARGV_T instead of void* for
execvp() argument.
* tools/if_not_there.c (main): Likewise.
* typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor,
SequenceDescriptor): Move struct definition out of union
ComplexDescriptor.
* typd_mlc.c (GC_add_ext_descriptor): Rename "new" local variable to
newExtD.
* win32_threads.c (GC_CreateThread, GC_beginthreadex): Cast result
of GC_malloc_uncollectable() to thread_args*.
* win32_threads.c [PARALLEL_MARK && !MSWINCE && __cplusplus]
(GC_thr_init): Do not cast GetProcessAffinityMask() arguments to void*.
STATIC word GC_used_heap_size_after_full = 0;
/* GC_copyright symbol is externally visible. */
-char * const GC_copyright[] =
+const 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. ",
++hhdr -> hb_n_marks;
}
- q = obj_link(q);
+ q = (ptr_t)obj_link(q);
if (q == NULL)
break;
}
GC_bytes_found -= sz;
- q = obj_link(q);
+ q = (ptr_t)obj_link(q);
if (q == NULL)
break;
for (kind = 0; kind < GC_n_kinds; kind++) {
for (size = 1; size <= MAXOBJGRANULES; size++) {
- q = GC_obj_kinds[kind].ok_freelist[size];
- if (q != 0) GC_set_fl_marks(q);
+ q = (ptr_t)GC_obj_kinds[kind].ok_freelist[size];
+ if (q != NULL)
+ GC_set_fl_marks(q);
}
}
GC_start_reclaim(TRUE);
for (kind = 0; kind < GC_n_kinds; kind++) {
for (size = 1; size <= MAXOBJGRANULES; size++) {
- q = GC_obj_kinds[kind].ok_freelist[size];
- if (q != 0) GC_clear_fl_marks(q);
+ q = (ptr_t)GC_obj_kinds[kind].ok_freelist[size];
+ if (q != NULL)
+ GC_clear_fl_marks(q);
}
}
}
/* Successful allocation; reset failure count. */
GC_fail_count = 0;
- return(*flh);
+ return (ptr_t)(*flh);
}
FIXUP_POINTER(current);
if (current >= (word)GC_least_plausible_heap_addr &&
current <= (word)GC_greatest_plausible_heap_addr) {
- ptr_t target = GC_base((void *)current);
+ ptr_t target = (ptr_t)GC_base((void *)current);
if (0 != target) {
add_edge(p, target);
}
GC_INNER void GC_default_print_heap_obj_proc(ptr_t p)
{
- ptr_t base = GC_base(p);
+ ptr_t base = (ptr_t)GC_base(p);
int kind = HDR(base)->hb_obj_kind;
GC_err_printf("object at %p of appr. %lu bytes (%s)\n",
STATIC void GC_print_blacklisted_ptr(word p, ptr_t source,
const char *kind_str)
{
- ptr_t base = GC_base(source);
+ ptr_t base = (ptr_t)GC_base(source);
if (0 == base) {
GC_err_printf("Black listing (%s) %p referenced from %p in %s\n",
BZERO(doomed, sizeof(page_hash_table));
}
-STATIC void GC_copy_bl(word *old, word *new)
+STATIC void GC_copy_bl(word *old, word *dest)
{
- BCOPY(old, new, sizeof(page_hash_table));
+ BCOPY(old, dest, sizeof(page_hash_table));
}
static word total_stack_black_listed(void);
}
}
# endif
- bp_base = GC_base(bp);
- if (0 == bp_base) {
+ bp_base = (ptr_t)GC_base(bp);
+ if (NULL == bp_base) {
*base_p = bp;
*offset_p = 0;
return GC_REFD_FROM_ROOT;
ptr_t base;
do {
result = GC_generate_random_heap_address();
- base = GC_base(result);
- } while (base == 0 || !GC_is_marked(base));
+ base = (ptr_t)GC_base(result);
+ } while (NULL == base || !GC_is_marked(base));
return result;
}
/* Store debugging info into p. Return displaced pointer. */
/* This version assumes we do hold the allocation lock. */
-STATIC ptr_t GC_store_debug_info_inner(ptr_t p, word sz GC_ATTR_UNUSED,
+STATIC void *GC_store_debug_info_inner(void *p, word sz GC_ATTR_UNUSED,
const char *string, int linenum)
{
word * result = (word *)((oh *)p + 1);
GC_ASSERT(GC_size(p) >= sizeof(oh) + sz);
- GC_ASSERT(!(SMALL_OBJ(sz) && CROSSES_HBLK(p, sz)));
+ GC_ASSERT(!(SMALL_OBJ(sz) && CROSSES_HBLK((ptr_t)p, sz)));
# ifdef KEEP_BACK_PTRS
((oh *)p) -> oh_back_ptr = HIDE_BACK_PTR(NOT_MARKED);
# endif
((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
result[SIMPLE_ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result;
# endif
- return((ptr_t)result);
+ return result;
}
GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *string,
DCL_LOCK_STATE;
LOCK();
- result = GC_store_debug_info_inner(p, sz, string, linenum);
+ result = (ptr_t)GC_store_debug_info_inner(p, sz, string, linenum);
UNLOCK();
return result;
}
ptr_t q;
hdr * hhdr;
int kind;
- char *kind_str;
+ const char *kind_str;
char buffer[GC_TYPE_DESCR_LEN + 1];
GC_ASSERT(I_DONT_HOLD_LOCK());
/* Use GC_err_printf and friends to print a description of the object */
/* whose client-visible address is p, and which was smashed at */
/* clobbered_addr. */
- STATIC void GC_print_smashed_obj(const char *msg, ptr_t p,
+ STATIC void GC_print_smashed_obj(const char *msg, void *p,
ptr_t clobbered_addr)
{
oh * ohdr = (oh *)GC_base(p);
|| ohdr -> oh_string == 0) {
GC_err_printf(
"%s %p in or near object at %p(<smashed>, appr. sz = %lu)\n",
- msg, (void *)clobbered_addr, (void *)p,
+ msg, (void *)clobbered_addr, p,
(unsigned long)(GC_size((ptr_t)ohdr) - DEBUG_BYTES));
} else {
GC_err_printf("%s %p in or near object at %p (%s:%d, sz=%lu)\n",
- msg, (void *)clobbered_addr, (void *)p,
+ msg, (void *)clobbered_addr, p,
(word)(ohdr -> oh_string) < HBLKSIZE ? "(smashed string)" :
ohdr -> oh_string[0] == '\0' ? "EMPTY(smashed?)" :
ohdr -> oh_string,
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
GC_API GC_ATTR_MALLOC void * GC_CALL
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
GC_API GC_ATTR_MALLOC void * GC_CALL
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return GC_store_debug_info(result, (word)lb, s, i);
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
#ifdef DBG_HDRS_ALL
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
GC_API void GC_CALL GC_debug_change_stubborn(const void *p)
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strdup(const char *str,
}
lb = strlen(str) + 1;
- copy = GC_debug_malloc_atomic(lb, OPT_RA s, i);
+ copy = (char *)GC_debug_malloc_atomic(lb, OPT_RA s, i);
if (copy == NULL) {
# ifndef MSWINCE
errno = ENOMEM;
size_t len = strlen(str); /* str is expected to be non-NULL */
if (len > size)
len = size;
- copy = GC_debug_malloc_atomic(len + 1, OPT_RA s, i);
+ copy = (char *)GC_debug_malloc_atomic(len + 1, OPT_RA s, i);
if (copy == NULL) {
# ifndef MSWINCE
errno = ENOMEM;
GC_EXTRA_PARAMS)
{
size_t lb = (wcslen(str) + 1) * sizeof(wchar_t);
- wchar_t *copy = GC_debug_malloc_atomic(lb, OPT_RA s, i);
+ wchar_t *copy = (wchar_t *)GC_debug_malloc_atomic(lb, OPT_RA s, i);
if (copy == NULL) {
# ifndef MSWINCE
errno = ENOMEM;
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
#ifdef GC_ATOMIC_UNCOLLECTABLE
GC_start_debugging();
}
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
#endif /* GC_ATOMIC_UNCOLLECTABLE */
ptr_t base;
if (0 == p) return;
- base = GC_base(p);
- if (base == 0) {
+ base = (ptr_t)GC_base(p);
+ if (NULL == base) {
# if defined(REDIRECT_MALLOC) \
&& ((defined(NEED_CALLINFO) && defined(GC_HAVE_BUILTIN_BACKTRACE)) \
|| defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS) \
/* Used internally; we assume it's called correctly. */
GC_INNER void GC_debug_free_inner(void * p)
{
- ptr_t base = GC_base(p);
+ ptr_t base = (ptr_t)GC_base(p);
GC_ASSERT((ptr_t)p - (ptr_t)base == sizeof(oh));
# ifdef LINT2
if (!base) ABORT("Invalid GC_debug_free_inner argument");
{
GC_finalization_proc my_old_fn = OFN_UNSET;
void * my_old_cd;
- ptr_t base = GC_base(obj);
- if (0 == base) {
+ ptr_t base = (ptr_t)GC_base(obj);
+ if (NULL == base) {
/* We won't collect it, hence finalizer wouldn't be run. */
if (ocd) *ocd = 0;
if (ofn) *ofn = 0;
{
GC_finalization_proc my_old_fn = OFN_UNSET;
void * my_old_cd;
- ptr_t base = GC_base(obj);
- if (0 == base) {
+ ptr_t base = (ptr_t)GC_base(obj);
+ if (NULL == base) {
/* We won't collect it, hence finalizer wouldn't be run. */
if (ocd) *ocd = 0;
if (ofn) *ofn = 0;
{
GC_finalization_proc my_old_fn = OFN_UNSET;
void * my_old_cd;
- ptr_t base = GC_base(obj);
- if (0 == base) {
+ ptr_t base = (ptr_t)GC_base(obj);
+ if (NULL == base) {
/* We won't collect it, hence finalizer wouldn't be run. */
if (ocd) *ocd = 0;
if (ofn) *ofn = 0;
{
GC_finalization_proc my_old_fn = OFN_UNSET;
void * my_old_cd;
- ptr_t base = GC_base(obj);
- if (0 == base) {
+ ptr_t base = (ptr_t)GC_base(obj);
+ if (NULL == base) {
/* We won't collect it, hence finalizer wouldn't be run. */
if (ocd) *ocd = 0;
if (ofn) *ofn = 0;
# ifdef MSWIN32
if (GC_no_win32_dlls) return;
# endif
- base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
+ p = GC_sysinfo.lpMinimumApplicationAddress;
+ base = limit = (char *)p;
while ((word)p < (word)GC_sysinfo.lpMaximumApplicationAddress) {
size_t result = VirtualQuery(p, &buf, sizeof(buf));
# endif
if ((char *)p != limit) {
GC_cond_add_roots(base, limit);
- base = p;
+ base = (char *)p;
}
limit = new_limit;
}
for (i = 0; i < old_size; i++) {
p = (*table)[i];
while (p != 0) {
- ptr_t real_key = GC_REVEAL_POINTER(p -> hidden_key);
+ ptr_t real_key = (ptr_t)GC_REVEAL_POINTER(p->hidden_key);
struct hash_chain_entry *next = p -> next;
size_t new_hash = HASH3(real_key, new_size, log_new_size);
static void push_and_mark_object(void *p)
{
- GC_normal_finalize_mark_proc(p);
+ GC_normal_finalize_mark_proc((ptr_t)p);
while (!GC_mark_stack_empty()) {
MARK_FROM_MARK_STACK();
}
GC_ASSERT(capacity_inc >= 0);
if (NULL == GC_toggleref_arr) {
GC_toggleref_array_capacity = 32; /* initial capacity */
- GC_toggleref_arr = GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
+ GC_toggleref_arr = (GCToggleRef *)GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
GC_toggleref_array_capacity * sizeof(GCToggleRef),
NORMAL);
if (NULL == GC_toggleref_arr)
return FALSE;
}
- new_array = GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
+ new_array = (GCToggleRef *)GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
GC_toggleref_array_capacity * sizeof(GCToggleRef),
NORMAL);
if (NULL == new_array)
for (curr_dl = dl_hashtbl -> head[i]; curr_dl != 0;
curr_dl = dl_next(curr_dl)) {
- ptr_t real_ptr = GC_REVEAL_POINTER(curr_dl -> dl_hidden_obj);
- ptr_t real_link = GC_REVEAL_POINTER(curr_dl -> dl_hidden_link);
+ ptr_t real_ptr = (ptr_t)GC_REVEAL_POINTER(curr_dl->dl_hidden_obj);
+ ptr_t real_link = (ptr_t)GC_REVEAL_POINTER(curr_dl->dl_hidden_link);
GC_printf("Object: %p, link: %p\n",
(void *)real_ptr, (void *)real_link);
for (i = 0; i < fo_size; i++) {
for (curr_fo = GC_fnlz_roots.fo_head[i];
curr_fo != NULL; curr_fo = fo_next(curr_fo)) {
- ptr_t real_ptr = GC_REVEAL_POINTER(curr_fo -> fo_hidden_base);
+ ptr_t real_ptr = (ptr_t)GC_REVEAL_POINTER(curr_fo->fo_hidden_base);
GC_printf("Finalizable object: %p\n", (void *)real_ptr);
}
struct disappearing_link *curr, *next;
ITERATE_DL_HASHTBL_BEGIN(dl_hashtbl, curr, prev)
- ptr_t real_ptr = GC_REVEAL_POINTER(curr -> dl_hidden_obj);
- ptr_t real_link = GC_REVEAL_POINTER(curr -> dl_hidden_link);
+ ptr_t real_ptr = (ptr_t)GC_REVEAL_POINTER(curr->dl_hidden_obj);
+ ptr_t real_link = (ptr_t)GC_REVEAL_POINTER(curr->dl_hidden_link);
if (!GC_is_marked(real_ptr)) {
*(word *)real_link = 0;
struct disappearing_link *curr, *next;
ITERATE_DL_HASHTBL_BEGIN(dl_hashtbl, curr, prev)
- ptr_t real_link = GC_base(GC_REVEAL_POINTER(curr -> dl_hidden_link));
+ ptr_t real_link =
+ (ptr_t)GC_base(GC_REVEAL_POINTER(curr->dl_hidden_link));
if (NULL != real_link && !GC_is_marked(real_link)) {
GC_clear_mark_bit(curr);
for (curr_fo = GC_fnlz_roots.fo_head[i];
curr_fo != NULL; curr_fo = fo_next(curr_fo)) {
GC_ASSERT(GC_size(curr_fo) >= sizeof(struct finalizable_object));
- real_ptr = GC_REVEAL_POINTER(curr_fo -> fo_hidden_base);
+ real_ptr = (ptr_t)GC_REVEAL_POINTER(curr_fo->fo_hidden_base);
if (!GC_is_marked(real_ptr)) {
GC_MARKED_FOR_FINALIZATION(real_ptr);
GC_MARK_FO(real_ptr, curr_fo -> fo_mark_proc);
curr_fo = GC_fnlz_roots.fo_head[i];
prev_fo = 0;
while (curr_fo != 0) {
- real_ptr = GC_REVEAL_POINTER(curr_fo -> fo_hidden_base);
+ real_ptr = (ptr_t)GC_REVEAL_POINTER(curr_fo->fo_hidden_base);
if (!GC_is_marked(real_ptr)) {
if (!GC_java_finalization) {
GC_set_mark_bit(real_ptr);
curr_fo = GC_fnlz_roots.fo_head[i];
GC_fnlz_roots.fo_head[i] = NULL;
while (curr_fo != NULL) {
- real_ptr = GC_REVEAL_POINTER(curr_fo -> fo_hidden_base);
+ real_ptr = (ptr_t)GC_REVEAL_POINTER(curr_fo->fo_hidden_base);
GC_MARK_FO(real_ptr, GC_normal_finalize_mark_proc);
GC_set_mark_bit(real_ptr);
/* info, GC_reclaim_with_finalization must be extended to clear */
/* fragments so that the assumption holds for the selected word. */
const struct GC_finalizer_closure *fc
- = (void *)(fc_word & ~(word)FINALIZER_CLOSURE_FLAG);
+ = (struct GC_finalizer_closure *)(fc_word
+ & ~(word)FINALIZER_CLOSURE_FLAG);
(*fc->proc)((word *)obj + 1, fc->cd);
}
return 0;
word *op;
GC_ASSERT(GC_finalized_kind != 0);
- op = GC_malloc_kind(SIZET_SAT_ADD(lb, sizeof(word)), GC_finalized_kind);
+ op = (word *)GC_malloc_kind(SIZET_SAT_ADD(lb, sizeof(word)),
+ GC_finalized_kind);
if (EXPECT(NULL == op, FALSE))
return NULL;
*op = (word)fclos | FINALIZER_CLOSURE_FLAG;
return((*oom_fn)(lb));
}
} else {
- GC_gcjobjfreelist[lg] = obj_link(op);
+ GC_gcjobjfreelist[lg] = (ptr_t)obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES((word)lg);
}
*(void **)op = ptr_to_struct_containing_descr;
}
UNLOCK();
ADD_CALL_CHAIN(result, ra);
- return (GC_store_debug_info(result, (word)lb, s, i));
+ return GC_store_debug_info((ptr_t)result, (word)lb, s, i);
}
/* There is no THREAD_LOCAL_ALLOC for GC_gcj_malloc_ignore_off_page(). */
return((*oom_fn)(lb));
}
} else {
- GC_gcjobjfreelist[lg] = obj_link(op);
+ GC_gcjobjfreelist[lg] = (ptr_t)obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES((word)lg);
}
} else {
size_t gran_displ = BYTES_TO_GRANULES(displ); \
size_t gran_offset = hhdr -> hb_map[gran_displ]; \
size_t byte_offset = displ & (GRANULE_BYTES - 1); \
- ptr_t base = current; \
+ ptr_t base = (ptr_t)(current); \
/* The following always fails for large block references. */ \
if (EXPECT((gran_offset | byte_offset) != 0, FALSE)) { \
if ((hhdr -> hb_flags & LARGE_BLOCK) != 0) { \
size_t displ = HBLKDISPL(current); /* Displacement in block; in bytes. */\
unsigned32 low_prod, high_prod; \
unsigned32 inv_sz = hhdr -> hb_inv_sz; \
- ptr_t base = current; \
+ ptr_t base = (ptr_t)(current); \
LONG_MULT(high_prod, low_prod, (unsigned32)displ, inv_sz); \
/* product is > and within sz_in_bytes of displ * sz_in_bytes * 2**32 */ \
if (EXPECT(low_prod >> 16 != 0, FALSE)) { \
/* Print warning message, e.g. almost out of memory. */
/* The argument (if any) format specifier should be: */
/* "%s", "%p" or "%"WARN_PRIdPTR. */
-#define WARN(msg, arg) (*GC_current_warn_proc)("GC Warning: " msg, \
- (word)(arg))
+#define WARN(msg, arg) \
+ (*GC_current_warn_proc)((/* no const */ char *)("GC Warning: " msg), \
+ (word)(arg))
GC_EXTERN GC_warn_proc GC_current_warn_proc;
/* Print format type macro for decimal signed_word value passed WARN(). */
#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
struct _SYSTEM_INFO;
GC_EXTERN struct _SYSTEM_INFO GC_sysinfo;
- GC_INNER GC_bool GC_is_heap_base(ptr_t p);
+ GC_INNER GC_bool GC_is_heap_base(void *p);
#endif
GC_EXTERN word GC_black_list_spacing;
GC_INNER void GC_thr_init(void);
GC_INNER void GC_init_parallel(void);
#else
- GC_INNER GC_bool GC_is_static_root(ptr_t p);
+ GC_INNER GC_bool GC_is_static_root(void *p);
/* Is the address p in one of the registered static */
/* root sections? */
#endif
/* We could also try to make sure that the real rounded-up object size */
/* is a multiple of align. That would be correct up to HBLKSIZE. */
new_lb = SIZET_SAT_ADD(lb, align - 1);
- result = GC_malloc(new_lb);
+ result = (ptr_t)GC_malloc(new_lb);
/* It is OK not to check result for NULL as in that case */
/* GC_memalign returns NULL too since (0 + 0 % align) is 0. */
offset = (word)result % align;
GC_register_displacement(offset);
}
}
- result = (void *) ((ptr_t)result + offset);
+ result += offset;
GC_ASSERT((word)result % align == 0);
return result;
}
size_t lb;
if (s == NULL) return NULL;
lb = strlen(s) + 1;
- if ((copy = GC_malloc_atomic(lb)) == NULL) {
+ copy = (char *)GC_malloc_atomic(lb);
+ if (NULL == copy) {
# ifndef MSWINCE
errno = ENOMEM;
# endif
size_t len = strlen(str); /* str is expected to be non-NULL */
if (len > size)
len = size;
- copy = GC_malloc_atomic(len + 1);
+ copy = (char *)GC_malloc_atomic(len + 1);
if (copy == NULL) {
# ifndef MSWINCE
errno = ENOMEM;
GC_API GC_ATTR_MALLOC wchar_t * GC_CALL GC_wcsdup(const wchar_t *str)
{
size_t lb = (wcslen(str) + 1) * sizeof(wchar_t);
- wchar_t *copy = GC_malloc_atomic(lb);
+ wchar_t *copy = (wchar_t *)GC_malloc_atomic(lb);
+
if (copy == NULL) {
# ifndef MSWINCE
errno = ENOMEM;
word current; /* Candidate pointer. */
ptr_t limit = 0; /* (Incl) limit of current candidate range. */
word descr;
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
DECLARE_HDR_CACHE;
# define SPLIT_RANGE_WORDS 128 /* Must be power of 2. */
GET_HDR(obj, hhdr);
if ((EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)
&& (!GC_all_interior_pointers
- || NULL == (hhdr = GC_find_header(GC_base(obj)))))
+ || NULL == (hhdr = GC_find_header((ptr_t)GC_base(obj)))))
|| EXPECT(HBLK_IS_FREE(hhdr), FALSE)) {
GC_ADD_TO_BLACK_LIST_NORMAL(obj, (ptr_t)src);
return mark_stack_ptr;
GET_HDR(p, hhdr);
if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)
&& (NULL == hhdr
- || (r = GC_base(p)) == NULL
+ || (r = (ptr_t)GC_base(p)) == NULL
|| (hhdr = HDR(r)) == NULL)) {
GC_ADD_TO_BLACK_LIST_STACK(p, source);
return;
word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
register word *p;
register word *lim;
- register ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- register ptr_t least_ha = GC_least_plausible_heap_addr;
+ register ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ register ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
# define GC_greatest_plausible_heap_addr greatest_ha
# define GC_least_plausible_heap_addr least_ha
word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
register word *p;
register word *lim;
- register ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- register ptr_t least_ha = GC_least_plausible_heap_addr;
+ register ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ register ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
# define GC_greatest_plausible_heap_addr greatest_ha
# define GC_least_plausible_heap_addr least_ha
/* Allow registers to be used for some frequently accessed */
/* global variables. Otherwise aliasing issues are likely */
/* to prevent that. */
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;
word *p;
word *plim;
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;
word *p;
word *plim;
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;
#ifndef THREADS
/* Primarily for debugging support: */
/* Is the address p in one of the registered static root sections? */
- GC_INNER GC_bool GC_is_static_root(ptr_t p)
+ GC_INNER GC_bool GC_is_static_root(void *p)
{
static int last_root_set = MAX_ROOT_SETS;
int i;
if (0 == GC_excl_table_entries) {
next = 0;
} else {
- next = GC_next_exclusion(start);
+ next = GC_next_exclusion((ptr_t)start);
}
if (0 != next) {
size_t i;
bottom_index *bi;
hdr *candidate_hdr;
- r = p;
+ r = (ptr_t)p;
if (!EXPECT(GC_is_initialized, TRUE)) return 0;
h = HBLKPTR(r);
GET_BI(r, bi);
if (!GC_write_disabled)
# endif
{
- if (WRITE(GC_stderr, (void *)msg, strlen(msg)) >= 0)
- (void)WRITE(GC_stderr, (void *)("\n"), 1);
+ if (WRITE(GC_stderr, msg, strlen(msg)) >= 0)
+ (void)WRITE(GC_stderr, "\n", 1);
}
# else
__android_log_assert("*" /* cond */, GC_ANDROID_LOG_TAG, "%s\n", msg);
result = GC_INTERNAL_MALLOC((MAXOBJGRANULES+1) * sizeof(ptr_t), PTRFREE);
if (NULL == result) ABORT("Failed to allocate freelist for new kind");
BZERO(result, (MAXOBJGRANULES+1)*sizeof(ptr_t));
- return result;
+ return (void **)result;
}
GC_API void ** GC_CALL GC_new_free_list(void)
{
- void *result;
+ void ** result;
DCL_LOCK_STATE;
LOCK();
result = GC_new_free_list_inner();
/* Build the free list */
GC_obj_kinds[kind].ok_freelist[gran] =
GC_build_fl(h, GRANULES_TO_WORDS(gran), clear,
- GC_obj_kinds[kind].ok_freelist[gran]);
+ (ptr_t)GC_obj_kinds[kind].ok_freelist[gran]);
}
/* Is p the base of one of the malloc heap sections we already know */
/* about? */
- STATIC GC_bool GC_is_malloc_heap_base(ptr_t p)
+ STATIC GC_bool GC_is_malloc_heap_base(void *p)
{
struct GC_malloc_heap_list *q = GC_malloc_heap_l;
/* Is p the start of either the malloc heap, or of one of our */
/* heap sections? */
- GC_INNER GC_bool GC_is_heap_base(ptr_t p)
+ GC_INNER GC_bool GC_is_heap_base(void *p)
{
unsigned i;
# ifndef REDIRECT_MALLOC
limit = new_limit;
} else {
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
- base = p;
+ base = (char *)p;
limit = new_limit;
}
}
LOCK();
me = GC_lookup_thread(self);
if (me != NULL) {
- me->stack = stack;
+ me->stack = (ptr_t)stack;
me->stack_size = stack_size;
- me->altstack = altstack;
+ me->altstack = (ptr_t)altstack;
me->altstack_size = altstack_size;
} else {
/* This happens if we are called before GC_thr_init. */
# endif
t -> flags = DETACHED | MAIN_THREAD;
if (THREAD_EQUAL(self, main_pthread_id)) {
- t -> stack = main_stack;
+ t -> stack = (ptr_t)main_stack;
t -> stack_size = main_stack_size;
- t -> altstack = main_altstack;
+ t -> altstack = (ptr_t)main_altstack;
t -> altstack_size = main_altstack_size;
}
}
const struct GC_stack_base *sb)
{
# ifndef GC_DARWIN_THREADS
- me -> stop_info.stack_ptr = sb -> mem_base;
+ me -> stop_info.stack_ptr = (ptr_t)sb->mem_base;
# endif
- me -> stack_end = sb -> mem_base;
+ me -> stack_end = (ptr_t)sb->mem_base;
if (me -> stack_end == NULL)
ABORT("Bad stack base in GC_register_my_thread");
# ifdef IA64
- me -> backing_store_end = sb -> reg_base;
+ me -> backing_store_end = (ptr_t)sb->reg_base;
# endif
}
void **pstart_arg,
struct GC_stack_base *sb, void *arg)
{
- struct start_info * si = arg;
+ struct start_info * si = (struct start_info *)arg;
pthread_t self = pthread_self();
GC_thread me;
DCL_LOCK_STATE;
#ifndef THREADS
/* Could p be a stack address? */
- STATIC GC_bool GC_on_stack(ptr_t p)
+ STATIC GC_bool GC_on_stack(void *p)
{
# ifdef STACK_GROWS_DOWN
if ((word)p >= (word)GC_approx_sp()
} else {
/* p points to the heap. */
word descr;
- ptr_t base = GC_base(p); /* Should be manually inlined? */
+ ptr_t base = (ptr_t)GC_base(p); /* Should be manually inlined? */
if (base == 0) goto fail;
if (HBLKPTR(base) != HBLKPTR(p)) hhdr = HDR((word)p);
GC_reclaim_check(hbp, hhdr, sz);
} else {
*flh = GC_reclaim_generic(hbp, hhdr, sz, ok -> ok_init,
- *flh, &GC_bytes_found);
+ (ptr_t)(*flh), &GC_bytes_found);
}
}
hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no;
flh_next = GC_reclaim_generic(hbp, hhdr, sz, ok -> ok_init,
- *flh, &GC_bytes_found);
+ (ptr_t)(*flh), &GC_bytes_found);
if (hhdr -> hb_n_marks)
*flh = flh_next;
else {
/* Currently for debugger use only: */
GC_API void GC_CALL GC_print_free_list(int kind, size_t sz_in_granules)
{
- ptr_t flh;
+ void *flh_next;
int n;
GC_ASSERT(kind < MAXOBJKINDS);
GC_ASSERT(sz_in_granules <= MAXOBJGRANULES);
- flh = GC_obj_kinds[kind].ok_freelist[sz_in_granules];
- for (n = 0; flh; n++) {
- struct hblk *block = HBLKPTR(flh);
+ flh_next = GC_obj_kinds[kind].ok_freelist[sz_in_granules];
+ for (n = 0; flh_next; n++) {
GC_printf("Free object in heap block %p [%d]: %p\n",
- (void *)block, n, (void *)flh);
- flh = obj_link(flh);
+ (void *)HBLKPTR(flh_next), n, flh_next);
+ flh_next = obj_link(flh_next);
}
}
for (j = 0; j < TINY_FREELISTS; ++j) {
for (i = 0; i < THREAD_FREELISTS_KINDS; ++i) {
- q = p -> _freelists[i][j];
+ q = (ptr_t)p->_freelists[i][j];
if ((word)q > HBLKSIZE)
GC_set_fl_marks(q);
}
# ifdef GC_GCJ_SUPPORT
if (EXPECT(j > 0, TRUE)) {
- q = p -> gcj_freelists[j];
+ q = (ptr_t)p->gcj_freelists[j];
if ((word)q > HBLKSIZE)
GC_set_fl_marks(q);
}
# include <string.h>
# include <unistd.h>
+#ifdef __cplusplus
+# define EXECV_ARGV_T char**
+#else
+ /* The 2nd argument of execvp() prototype may be either char**, or */
+ /* char* const*, or const char* const*. */
+# define EXECV_ARGV_T void*
+#endif
+
int main(int argc, char **argv)
{
if (argc < 4) goto Usage;
&& strcmp(OS_TYPE, argv[2]) != 0) return(0);
fprintf(stderr, "^^^^Starting command^^^^\n");
fflush(stdout);
- execvp(TRUSTED_STRING(argv[3]), (void *)(argv + 3));
+ execvp(TRUSTED_STRING(argv[3]), (EXECV_ARGV_T)(argv + 3));
perror("Couldn't execute");
Usage:
#include <dirent.h>
#endif /* __DJGPP__ */
+#ifdef __cplusplus
+# define EXECV_ARGV_T char**
+#else
+# define EXECV_ARGV_T void* /* see the comment in if_mach.c */
+#endif
+
int main(int argc, char **argv)
{
FILE * f;
if (argc == 2)
return(2); /* the file does not exist but no command is given */
- execvp(TRUSTED_STRING(argv[2]), (void *)(argv + 2));
+ execvp(TRUSTED_STRING(argv[2]), (EXECV_ARGV_T)(argv + 2));
exit(1);
Usage:
/* We may eventually need to add provisions for headers and */
/* trailers. Hence we provide for tree structured descriptors, */
/* though we don't really use them currently. */
-typedef union ComplexDescriptor {
+
struct LeafDescriptor { /* Describes simple array */
word ld_tag;
# define LEAF_TAG 1
- size_t ld_size; /* bytes per element */
- /* multiple of ALIGNMENT */
- size_t ld_nelements; /* Number of elements. */
+ size_t ld_size; /* bytes per element */
+ /* multiple of ALIGNMENT. */
+ size_t ld_nelements; /* Number of elements. */
GC_descr ld_descriptor; /* A simple length, bitmap, */
/* or procedure descriptor. */
} ld;
+
struct ComplexArrayDescriptor {
word ad_tag;
# define ARRAY_TAG 2
size_t ad_nelements;
union ComplexDescriptor * ad_element_descr;
} ad;
+
struct SequenceDescriptor {
word sd_tag;
# define SEQUENCE_TAG 3
union ComplexDescriptor * sd_first;
union ComplexDescriptor * sd_second;
} sd;
+
+typedef union ComplexDescriptor {
+ struct LeafDescriptor ld;
+ struct ComplexArrayDescriptor ad;
+ struct SequenceDescriptor sd;
} complex_descriptor;
#define TAG ad.ad_tag
LOCK();
while (GC_avail_descr + nwords >= GC_ed_size) {
- ext_descr * new;
+ ext_descr * newExtD;
size_t new_size;
word ed_size = GC_ed_size;
new_size = 2 * ed_size;
if (new_size > MAX_ENV) return(-1);
}
- new = (ext_descr *) GC_malloc_atomic(new_size * sizeof(ext_descr));
- if (new == 0) return(-1);
+ newExtD = (ext_descr *)GC_malloc_atomic(new_size * sizeof(ext_descr));
+ if (NULL == newExtD)
+ return -1;
LOCK();
if (ed_size == GC_ed_size) {
if (GC_avail_descr != 0) {
- BCOPY(GC_ext_descriptors, new,
+ BCOPY(GC_ext_descriptors, newExtD,
GC_avail_descr * sizeof(ext_descr));
}
GC_ed_size = new_size;
- GC_ext_descriptors = new;
+ GC_ext_descriptors = newExtD;
} /* else another thread already resized it in the meantime */
}
result = GC_avail_descr;
word bm = GC_ext_descriptors[env].ed_bitmap;
word * current_p = addr;
word current;
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
DECLARE_HDR_CACHE;
INIT_HDR_CACHE;
GC_ASSERT(GC_explicit_typing_initialized);
lb = SIZET_SAT_ADD(lb, TYPD_EXTRA_BYTES);
- op = GC_malloc_kind(lb, GC_explicit_kind);
+ op = (word *)GC_malloc_kind(lb, GC_explicit_kind);
if (EXPECT(NULL == op, FALSE))
return NULL;
/* It is not safe to use GC_size_map[lb] to compute lg here as the */
/* See the comment in GC_malloc_explicitly_typed. */
lg = BYTES_TO_GRANULES(GC_size(op));
} else {
- GC_eobjfreelist[lg] = obj_link(op);
+ GC_eobjfreelist[lg] = (ptr_t)obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES((word)lg);
UNLOCK();
((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
}
}
- return((void *) op);
+ return op;
}
GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n,
lb = SIZET_SAT_ADD(lb, TYPD_EXTRA_BYTES);
break;
}
- op = GC_malloc_kind(lb, GC_array_kind);
+ op = (word *)GC_malloc_kind(lb, GC_array_kind);
if (EXPECT(NULL == op, FALSE))
return NULL;
lg = BYTES_TO_GRANULES(GC_size(op));
GC_INLINE void GC_record_stack_base(GC_vthread me,
const struct GC_stack_base *sb)
{
- me -> stack_base = sb -> mem_base;
+ me -> stack_base = (ptr_t)sb->mem_base;
# ifdef IA64
- me -> backing_store_end = sb -> reg_base;
+ me -> backing_store_end = (ptr_t)sb->reg_base;
# endif
if (me -> stack_base == NULL)
ABORT("Bad stack base in GC_register_my_thread");
last_address = s;
}
do {
- bottom = last_info.BaseAddress;
+ bottom = (ptr_t)last_info.BaseAddress;
VirtualQuery(bottom - 1, &last_info, sizeof(last_info));
last_address = bottom - 1;
} while ((last_info.Protect & PAGE_READWRITE)
if (may_be_in_stack(thread -> id == me &&
(word)sp < (word)thread->last_stack_min ?
sp : thread -> last_stack_min)) {
- stack_min = last_info.BaseAddress;
+ stack_min = (ptr_t)last_info.BaseAddress;
/* Do not probe rest of the stack if sp is correct. */
if ((word)sp < (word)stack_min
|| (word)sp >= (word)thread->stack_base)
return CreateThread(lpThreadAttributes, dwStackSize, lpStartAddress,
lpParameter, dwCreationFlags, lpThreadId);
} else {
- thread_args *args = GC_malloc_uncollectable(sizeof(thread_args));
+ thread_args *args =
+ (thread_args *)GC_malloc_uncollectable(sizeof(thread_args));
/* Handed off to and deallocated by child thread. */
HANDLE thread_h;
- if (0 == args) {
+ if (NULL == args) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
arglist, initflag, thrdaddr);
} else {
GC_uintptr_t thread_h;
- thread_args *args = GC_malloc_uncollectable(sizeof(thread_args));
+ thread_args *args =
+ (thread_args *)GC_malloc_uncollectable(sizeof(thread_args));
/* Handed off to and deallocated by child thread. */
- if (0 == args) {
+ if (NULL == args) {
/* MSDN docs say _beginthreadex() returns 0 on error and sets */
/* errno to either EAGAIN (too many threads) or EINVAL (the */
/* argument is invalid or the stack size is incorrect), so we */
DWORD sysMask;
# endif
int ncpu = 0;
- if (GetProcessAffinityMask(GetCurrentProcess(),
+ if (
+# ifdef __cplusplus
+ GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask)
+# else
+ /* Cast args to void* for compatibility with some old SDKs. */
+ GetProcessAffinityMask(GetCurrentProcess(),
(void *)&procMask, (void *)&sysMask)
+# endif
&& procMask) {
do {
ncpu++;
/* This is otherwise saved only in an area mmapped by the thread */
/* library, which isn't visible to the collector. */
- si = GC_malloc_uncollectable(sizeof(struct start_info));
- if (0 == si) return(EAGAIN);
+ si = (struct start_info *)GC_malloc_uncollectable(
+ sizeof(struct start_info));
+ if (NULL == si)
+ return EAGAIN;
si -> start_routine = start_routine;
si -> arg = arg;
STATIC void * GC_CALLBACK GC_pthread_start_inner(struct GC_stack_base *sb,
void * arg)
{
- struct start_info * si = arg;
+ struct start_info * si = (struct start_info *)arg;
void * result;
void *(*start)(void *);
void *start_arg;