summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alloc.c18
-rw-r--r--backgraph.c2
-rw-r--r--blacklst.c8
-rw-r--r--dbg_mlc.c68
-rw-r--r--dyn_load.c5
-rw-r--r--finalize.c27
-rw-r--r--fnlz_mlc.c6
-rw-r--r--gcj_mlc.c6
-rw-r--r--include/private/gc_pmark.h4
-rw-r--r--include/private/gc_priv.h9
-rw-r--r--mallocx.c12
-rw-r--r--mark.c28
-rw-r--r--mark_rts.c4
-rw-r--r--misc.c10
-rw-r--r--new_hblk.c2
-rw-r--r--os_dep.c6
-rw-r--r--pthread_support.c16
-rw-r--r--ptr_chck.c4
-rw-r--r--reclaim.c15
-rw-r--r--thread_local_alloc.c4
-rw-r--r--tools/if_mach.c10
-rw-r--r--tools/if_not_there.c8
-rw-r--r--typd_mlc.c38
-rw-r--r--win32_threads.c34
24 files changed, 192 insertions, 152 deletions
diff --git a/alloc.c b/alloc.c
index 26201cd5..d9b61a6e 100644
--- a/alloc.c
+++ b/alloc.c
@@ -117,7 +117,7 @@ STATIC GC_bool GC_need_full_gc = FALSE;
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. ",
@@ -817,7 +817,7 @@ GC_INNER void GC_set_fl_marks(ptr_t q)
++hhdr -> hb_n_marks;
}
- q = obj_link(q);
+ q = (ptr_t)obj_link(q);
if (q == NULL)
break;
@@ -905,7 +905,7 @@ STATIC void GC_clear_fl_marks(ptr_t q)
}
GC_bytes_found -= sz;
- q = obj_link(q);
+ q = (ptr_t)obj_link(q);
if (q == NULL)
break;
@@ -976,8 +976,9 @@ STATIC void GC_finish_collection(void)
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);
@@ -1018,8 +1019,9 @@ STATIC void GC_finish_collection(void)
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);
}
}
}
@@ -1496,5 +1498,5 @@ GC_INNER ptr_t GC_allocobj(size_t gran, int kind)
/* Successful allocation; reset failure count. */
GC_fail_count = 0;
- return(*flh);
+ return (ptr_t)(*flh);
}
diff --git a/backgraph.c b/backgraph.c
index 24beaa43..64fc92f9 100644
--- a/backgraph.c
+++ b/backgraph.c
@@ -345,7 +345,7 @@ static void add_back_edges(ptr_t p, size_t n_bytes, word gc_descr)
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);
}
diff --git a/blacklst.c b/blacklst.c
index 23d6a319..356f636e 100644
--- a/blacklst.c
+++ b/blacklst.c
@@ -56,7 +56,7 @@ STATIC void GC_clear_bl(word *);
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",
@@ -71,7 +71,7 @@ GC_INNER void (*GC_print_heap_obj)(ptr_t p) = GC_default_print_heap_obj_proc;
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",
@@ -125,9 +125,9 @@ STATIC void GC_clear_bl(word *doomed)
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);
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 69b671c6..e9c1df55 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -139,8 +139,8 @@
}
}
# 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;
@@ -191,8 +191,8 @@
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;
}
@@ -269,13 +269,13 @@
/* 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
@@ -290,7 +290,7 @@ STATIC ptr_t GC_store_debug_info_inner(ptr_t p, word sz GC_ATTR_UNUSED,
((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,
@@ -300,7 +300,7 @@ 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;
}
@@ -356,7 +356,7 @@ STATIC void GC_print_obj(ptr_t p)
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());
@@ -433,7 +433,7 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
/* 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);
@@ -446,11 +446,11 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t 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,
@@ -550,7 +550,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc(size_t lb,
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
@@ -567,7 +567,7 @@ 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
@@ -585,7 +585,7 @@ 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)
@@ -602,7 +602,7 @@ 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
@@ -662,7 +662,7 @@ 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);
}
GC_API void GC_CALL GC_debug_change_stubborn(const void *p)
@@ -725,7 +725,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_atomic(size_t lb,
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,
@@ -740,7 +740,7 @@ 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;
@@ -758,7 +758,7 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strndup(const char *str,
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;
@@ -778,7 +778,7 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strndup(const char *str,
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;
@@ -805,7 +805,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_uncollectable(size_t lb,
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
@@ -824,7 +824,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_uncollectable(size_t lb,
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 */
@@ -841,8 +841,8 @@ GC_API void GC_CALL GC_debug_free(void * p)
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) \
@@ -909,7 +909,7 @@ GC_API void GC_CALL GC_debug_free(void * p)
/* 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");
@@ -1185,8 +1185,8 @@ GC_API void GC_CALL GC_debug_register_finalizer(void * obj,
{
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;
@@ -1214,8 +1214,8 @@ GC_API void GC_CALL GC_debug_register_finalizer_no_order
{
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;
@@ -1243,8 +1243,8 @@ GC_API void GC_CALL GC_debug_register_finalizer_unreachable
{
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;
@@ -1272,8 +1272,8 @@ GC_API void GC_CALL GC_debug_register_finalizer_ignore_self
{
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;
diff --git a/dyn_load.c b/dyn_load.c
index a5051d44..9db31861 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -995,7 +995,8 @@ GC_INNER void GC_register_dynamic_libraries(void)
# 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));
@@ -1033,7 +1034,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
# endif
if ((char *)p != limit) {
GC_cond_add_roots(base, limit);
- base = p;
+ base = (char *)p;
}
limit = new_limit;
}
diff --git a/finalize.c b/finalize.c
index 06accb89..5132a252 100644
--- a/finalize.c
+++ b/finalize.c
@@ -120,7 +120,7 @@ STATIC void GC_grow_table(struct hash_chain_entry ***table,
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);
@@ -325,7 +325,7 @@ GC_API int GC_CALL GC_unregister_disappearing_link(void * * link)
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();
}
@@ -392,7 +392,7 @@ GC_API int GC_CALL GC_unregister_disappearing_link(void * * link)
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)
@@ -408,7 +408,7 @@ GC_API int GC_CALL GC_unregister_disappearing_link(void * * link)
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)
@@ -817,8 +817,8 @@ GC_API void GC_CALL GC_register_finalizer_unreachable(void * obj,
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);
@@ -843,7 +843,7 @@ GC_API void GC_CALL GC_register_finalizer_unreachable(void * obj,
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);
}
@@ -923,8 +923,8 @@ GC_INLINE void GC_make_disappearing_links_disappear(
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;
@@ -940,7 +940,8 @@ GC_INLINE void GC_remove_dangling_disappearing_links(
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);
@@ -980,7 +981,7 @@ GC_INNER void GC_finalize(void)
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);
@@ -997,7 +998,7 @@ GC_INNER void GC_finalize(void)
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);
@@ -1123,7 +1124,7 @@ GC_INNER void GC_finalize(void)
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);
diff --git a/fnlz_mlc.c b/fnlz_mlc.c
index 16d40af7..17c73ae4 100644
--- a/fnlz_mlc.c
+++ b/fnlz_mlc.c
@@ -42,7 +42,8 @@ STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj)
/* 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;
@@ -87,7 +88,8 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_finalized_malloc(size_t lb,
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;
diff --git a/gcj_mlc.c b/gcj_mlc.c
index bcd95b05..3e450bf6 100644
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -176,7 +176,7 @@ static void maybe_finalize(void)
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;
@@ -224,7 +224,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_gcj_malloc(size_t lb,
}
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(). */
@@ -249,7 +249,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
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 {
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index c327ad60..41d97b79 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -248,7 +248,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp);
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) { \
@@ -304,7 +304,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp);
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)) { \
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index f05469d1..838facd7 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -621,8 +621,9 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* 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(). */
@@ -1563,7 +1564,7 @@ GC_EXTERN size_t GC_page_size;
#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;
@@ -1825,7 +1826,7 @@ void GC_register_data_segments(void);
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
diff --git a/mallocx.c b/mallocx.c
index 1e1e3726..73e50bb9 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -511,7 +511,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_memalign(size_t align, size_t lb)
/* 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;
@@ -523,7 +523,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_memalign(size_t align, size_t lb)
GC_register_displacement(offset);
}
}
- result = (void *) ((ptr_t)result + offset);
+ result += offset;
GC_ASSERT((word)result % align == 0);
return result;
}
@@ -558,7 +558,8 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_strdup(const char *s)
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
@@ -574,7 +575,7 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_strndup(const char *str, size_t size)
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;
@@ -593,7 +594,8 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_strndup(const char *str, size_t size)
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;
diff --git a/mark.c b/mark.c
index 04621c8f..4c240b92 100644
--- a/mark.c
+++ b/mark.c
@@ -664,8 +664,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
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. */
@@ -1477,7 +1477,7 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj,
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;
@@ -1513,7 +1513,7 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj,
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;
@@ -1606,8 +1606,8 @@ GC_API void GC_CALL GC_push_all_eager(void *bottom, void *top)
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
@@ -1651,8 +1651,8 @@ GC_INNER void GC_push_all_stack(ptr_t bottom, ptr_t top)
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
@@ -1716,8 +1716,8 @@ STATIC void GC_push_marked1(struct hblk *h, hdr *hhdr)
/* 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;
@@ -1766,8 +1766,8 @@ STATIC void GC_push_marked2(struct hblk *h, hdr *hhdr)
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;
@@ -1817,8 +1817,8 @@ STATIC void GC_push_marked4(struct hblk *h, hdr *hhdr)
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;
diff --git a/mark_rts.c b/mark_rts.c
index c688feb3..fe25931a 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -77,7 +77,7 @@ static int n_root_sets = 0;
#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;
@@ -454,7 +454,7 @@ GC_INNER void GC_exclude_static_roots_inner(void *start, void *finish)
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;
diff --git a/misc.c b/misc.c
index 0245b591..83ccb5c8 100644
--- a/misc.c
+++ b/misc.c
@@ -408,7 +408,7 @@ GC_API void * GC_CALL GC_base(void * p)
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);
@@ -1890,8 +1890,8 @@ GC_API GC_warn_proc GC_CALL GC_get_warn_proc(void)
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);
@@ -1965,12 +1965,12 @@ GC_API void ** GC_CALL GC_new_free_list_inner(void)
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();
diff --git a/new_hblk.c b/new_hblk.c
index 108bdc05..5e3ce068 100644
--- a/new_hblk.c
+++ b/new_hblk.c
@@ -187,5 +187,5 @@ GC_INNER void GC_new_hblk(size_t gran, int kind)
/* 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]);
}
diff --git a/os_dep.c b/os_dep.c
index 0155c204..6e645919 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1788,7 +1788,7 @@ void GC_register_data_segments(void)
/* 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;
@@ -1849,7 +1849,7 @@ void GC_register_data_segments(void)
/* 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
@@ -1889,7 +1889,7 @@ void GC_register_data_segments(void)
limit = new_limit;
} else {
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
- base = p;
+ base = (char *)p;
limit = new_limit;
}
}
diff --git a/pthread_support.c b/pthread_support.c
index 59d6732d..e6a6a429 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -723,9 +723,9 @@ GC_API void GC_CALL GC_register_altstack(void *stack, GC_word stack_size,
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. */
@@ -1230,9 +1230,9 @@ GC_INNER void GC_thr_init(void)
# 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;
}
}
@@ -1663,13 +1663,13 @@ GC_INLINE void GC_record_stack_base(GC_thread me,
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
}
@@ -1760,7 +1760,7 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
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;
diff --git a/ptr_chck.c b/ptr_chck.c
index e86378e9..d41a0ad2 100644
--- a/ptr_chck.c
+++ b/ptr_chck.c
@@ -159,7 +159,7 @@ void (GC_CALLBACK *GC_is_visible_print_proc)(void * p) =
#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()
@@ -215,7 +215,7 @@ GC_API void * GC_CALL GC_is_visible(void *p)
} 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);
diff --git a/reclaim.c b/reclaim.c
index 3879c22a..85591a30 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -351,7 +351,7 @@ STATIC void GC_reclaim_small_nonempty_block(struct hblk *hbp,
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);
}
}
@@ -366,7 +366,7 @@ STATIC void GC_reclaim_small_nonempty_block(struct hblk *hbp,
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 {
@@ -585,17 +585,16 @@ void GC_print_block_list(void)
/* 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);
}
}
diff --git a/thread_local_alloc.c b/thread_local_alloc.c
index 5608570e..545812a4 100644
--- a/thread_local_alloc.c
+++ b/thread_local_alloc.c
@@ -273,13 +273,13 @@ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p)
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);
}
diff --git a/tools/if_mach.c b/tools/if_mach.c
index 18c40e55..2ddad6f2 100644
--- a/tools/if_mach.c
+++ b/tools/if_mach.c
@@ -5,6 +5,14 @@
# 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;
@@ -13,7 +21,7 @@ int main(int argc, char **argv)
&& 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:
diff --git a/tools/if_not_there.c b/tools/if_not_there.c
index 10f5d14a..d388d04b 100644
--- a/tools/if_not_there.c
+++ b/tools/if_not_there.c
@@ -10,6 +10,12 @@
#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;
@@ -43,7 +49,7 @@ int main(int argc, char **argv)
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:
diff --git a/typd_mlc.c b/typd_mlc.c
index 05079f14..b5e2c612 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -62,28 +62,35 @@ typedef struct {
/* 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
@@ -129,7 +136,7 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits)
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;
@@ -143,16 +150,17 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits)
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;
@@ -363,8 +371,8 @@ STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
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;
@@ -591,7 +599,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_explicitly_typed(size_t lb,
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 */
@@ -627,7 +635,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL
/* 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();
@@ -640,7 +648,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL
((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,
@@ -672,7 +680,7 @@ 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));
diff --git a/win32_threads.c b/win32_threads.c
index c0b99e95..71cafa33 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -369,9 +369,9 @@ STATIC GC_bool GC_in_thread_creation = FALSE;
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");
@@ -1362,7 +1362,7 @@ STATIC ptr_t GC_get_stack_min(ptr_t s)
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)
@@ -1479,7 +1479,7 @@ STATIC word GC_push_stack_for(GC_thread thread, DWORD me)
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)
@@ -2246,11 +2246,12 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
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;
}
@@ -2294,10 +2295,11 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
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 */
@@ -2464,8 +2466,14 @@ GC_INNER void GC_thr_init(void)
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++;
@@ -2588,8 +2596,10 @@ GC_INNER void GC_thr_init(void)
/* 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;
@@ -2616,7 +2626,7 @@ GC_INNER void GC_thr_init(void)
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;