Skip to content

Commit

Permalink
Define GC_uintptr_t unconditionally in gc.h
Browse files Browse the repository at this point in the history
Issue #627 (bdwgc).

* cord/cordprnt.c (CORD_vsprintf): Compare len (instead of res) to buf;
cast len and buf values to GC_uintptr_t instead of casting res to word
and then to char*.
* cord/cordxtra.c (CORD_nul_func, CORD_chars, refill_cache,
CORD_lf_func): Cast between pointer and char thru GC_uintptr_t instead
of word.
* include/private/dbg_mlc.h (MARKED_FOR_FINALIZATION,
MARKED_FROM_REGISTER, NOT_MARKED): Likewise.
* cord/tests/cordtest.c (test_fn, test_cord_x1, test_cord_x2):
Likewise.
* dbg_mlc.c (GC_has_other_debug_info, GC_store_debug_info_inner,
GC_check_annotated_obj): Cast body, sz to GC_uintptr_t (instead of
word); cast base/ohdr to GC_uintptr_t* instead of word*.
* dbg_mlc.c (GC_print_backtrace): Remove out label; adjust indentation.
* dbg_mlc.c (GET_OH_LINENUM): Add missing parentheses.
* include/gc/gc.h (GC_PRE_INCR3, GC_POST_INCR3): Likewise.
* dbg_mlc.c [!SHORT_DBG_HDRS] (GC_print_smashed_obj): Rename
clobbered_addr argument to clobbered; reformat comment.
* dbg_mlc.c (GC_FREED_MEM_MARKER): Move definition to dbg_mlc.h.
* dbg_mlc.c (GC_debug_free): Cast sz and GC_size(base) to GC_uintptr_t;
cast p to GC_uintptr_t* instead of word*.
* dbg_mlc.c (GC_check_leaked): Cast base to GC_uintptr_t* instead of
word*.
* include/private/dbg_mlc.h [(KEEP_BACK_PTRS || MAKE_BACK_GRAPH)
&& !(PARALLEL_MARK || KEEP_BACK_PTRS)] (GC_HAS_DEBUG_INFO): Likewise.
* dbg_mlc.c (GC_debug_invoke_finalizer): Change "fns" to "function" in
comment.
* dbg_mlc.c (store_old, GC_debug_register_finalizer,
GC_debug_register_finalizer_no_order,
GC_debug_register_finalizer_unreachable,
GC_debug_register_finalizer_ignore_self): Store NULL (instead of 0)
to *ocd.
* gc.man (.TH): Update date.
* gc.man (GC_set_warn_proc): Change arg type from GC_word to
GC_uintptr_t.
* include/gc/gc.h (GC_warn_proc, GC_ignore_warn_proc): Likewise.
* misc.c (GC_default_warn_proc, GC_ignore_warn_proc): Likewise.
* tests/cpp.cc (warn_proc): Likewise.
* gcj_mlc.c (GC_gcj_fake_mark_proc, GC_init_gcj_malloc): Rename
FUNCPTR_IS_WORD to FUNCPTR_IS_DATAPTR.
* include/private/gc_priv.h (FUNCPTR_IS_WORD): Likewise.
* misc.c [!CPPCHECK] (GC_init): Likewise.
* pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2
&& DEBUG_THREADS] (GC_start_rtn_prepare_thread): Likewise.
* include/gc/gc.h (GC_uintptr_t): Define unconditionally; move
definition to the beginning of the file.
* include/gc/gc.h (GC_general_register_disappearing_link,
GC_malloc_many): Refine comment.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): Likewise.
* include/gc/gc.h (GC_hidden_pointer): Change type from GC_word to
GC_uintptr_t.
* include/private/gc_priv.h (GC_funcptr_uint): Likewise.
* include/private/dbg_mlc.h (GC_FREED_MEM_MARKER, START_FLAG,
END_FLAG): Cast to GC_uintptr_t instead of word.
* include/private/dbg_mlc.h [ALIGNMENT==1] (HIDE_BACK_PTR): Likewise.
* include/private/dbg_mlc.h (oh): Remove oh_dummy field; make
oh_back_ptr and oh_bg_ptr field either present both or not; refine
comment.
* include/private/dbg_mlc.h [!SHORT_DBG_HDRS] (oh.oh_sz, oh.oh_sf):
Change type from word to GC_uintptr_t.
* include/private/gc_priv.h (GC_ASSERT): Move definition upper (to be
right after include gc_locks.h).
* include/private/gc_priv.h (WARN): Cast arg to GC_uintptr_t instead
of word.
* include/private/gc_priv.h (WARN_PRIdPTR): Change comment to TODO
item.
* mallocx.c [_FORTIFY_SOURCE && __GNUC__ && !__clang__] (GC_realloc):
Change type of cleared_p local variable from word to GC_uintptr_t;
reformat comment.
* mallocx.c [!_FORTIFY_SOURCE || !__GNUC__ || __clang__] (GC_realloc):
Define cleared_p as a macro (and undefine it at the end of function).
* misc.c [!CPPCHECK] (GC_init): Change ptr_t to ptrdiff_t in comparison
to sizeof word.
* misc.c [!CPPCHECK && FUNCPTR_IS_DATAPTR] (GC_init): Change word to
ptr_t in comparison to sizeof GC_funcptr_uint.
* misc.c [!CPPCHECK] (GC_init): Add assertion that size of GC_uintptr_t
matches size of ptr_t.
* pthread_support.c [E2K] (GC_record_stack_base, GC_set_stackbottom):
Cast sb->reg_base to GC_uintptr_t instead of ADDR() usage.
* pthread_support.c [E2K] (GC_get_my_stackbottom): Cast crtn->ps_ofs to
GC_uintptr_t instead of word; add comment.
* tests/cpp.cc (Disguise): Change type or result from
GC_word to GC_uintptr_t.
* tests/cpp.cc (Undisguise): Rename i argument to v and change its type
from GC_word to GC_uintptr_t.
* tests/cpp.cc (main): Change type of as, bs local variables from
GC_word[] to GC_uintptr_t[].
* tests/cpp.cc (INT_TO_SEXPR, SEXPR_TO_INT): Rename argument; cast thru
GC_uintptr_t instead of GC_word.
* tests/cpp.cc [TEST_WITH_SYSTEM_MALLOC] (reverse): Cast
TEST_WITH_SYSTEM_MALLOC() result to GC_word.
* tests/cpp.cc (reverse_test_inner, finalizer, mktree): Cast between
pointer and int thru GC_uintptr_t instead GC_word.
* thread_local_alloc.c (return_freelists, GC_init_thread_local):
Likewise.
* tests/cpp.cc (warn_proc): Rename argument from p to arg; remove cast
of arg to unsigned long.
  • Loading branch information
ivmai committed Jun 12, 2024
1 parent db759a5 commit f68db21
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 333 deletions.
2 changes: 1 addition & 1 deletion cord/cordprnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
va_end(vsprintf_args);
# endif
len = (unsigned)res;
if ((char *)(GC_word)res == buf) {
if ((GC_uintptr_t)len == (GC_uintptr_t)buf) {
/* old style vsprintf */
len = strlen(buf);
} else if (res < 0) {
Expand Down
16 changes: 9 additions & 7 deletions cord/cordxtra.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,13 @@ void CORD_ec_append_cord(CORD_ec x, CORD s)
static char CORD_nul_func(size_t i, void * client_data)
{
(void)i;
return (char)(GC_word)client_data;
return (char)(GC_uintptr_t)client_data;
}

CORD CORD_chars(char c, size_t i)
{
return CORD_from_fn(CORD_nul_func, (void *)(GC_word)(unsigned char)c, i);
return CORD_from_fn(CORD_nul_func,
(void *)(GC_uintptr_t)(unsigned char)c, i);
}

CORD CORD_from_file_eager(FILE * f)
Expand Down Expand Up @@ -537,10 +538,11 @@ static void * GC_CALLBACK refill_cache(void * client_data)
# else
state -> lf_cache[line_no] = new_cache;
# endif
GC_END_STUBBORN_CHANGE((/* no volatile */ void *)
(GC_word)(state -> lf_cache + line_no));
GC_END_STUBBORN_CHANGE((/* no volatile */ cache_line *)
&(state -> lf_cache[line_no]));
state -> lf_current = line_start + LINE_SZ;
return (void *)((GC_word)new_cache->data[MOD_LINE_SZ(file_pos)]);
return (void *)(GC_uintptr_t)
((unsigned char)(new_cache -> data[MOD_LINE_SZ(file_pos)]));
}

#ifndef CORD_USE_GCC_ATOMIC
Expand All @@ -565,7 +567,7 @@ static char CORD_lf_func(size_t i, void * client_data)
get_cache_line, (void *)cl_addr);
# else
cl = (cache_line *)GC_call_with_reader_lock(get_cache_line,
(void *)cl_addr, 0);
(/* no volatile */ void *)cl_addr, 0);
# endif
if (NULL == cl || cl -> tag != DIV_LINE_SZ(i)) {
/* Cache miss */
Expand All @@ -575,7 +577,7 @@ static char CORD_lf_func(size_t i, void * client_data)
rd.file_pos = i;
rd.new_cache = GC_NEW_ATOMIC(cache_line);
if (NULL == rd.new_cache) OUT_OF_MEMORY;
return (char)((GC_word)GC_call_with_alloc_lock(refill_cache, &rd));
return (char)(GC_uintptr_t)GC_call_with_alloc_lock(refill_cache, &rd);
}
return cl -> data[MOD_LINE_SZ(i)];
}
Expand Down
8 changes: 4 additions & 4 deletions cord/tests/cordtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int count;

static int test_fn(char c, void * client_data)
{
if (client_data != (void *)(GC_word)13)
if ((GC_uintptr_t)client_data != 13U)
ABORT("bad client data");
if (count < CORD_ITER_CNT + 1) {
if ((count & 1) == 0) {
Expand Down Expand Up @@ -84,15 +84,15 @@ static void test_cord_x1(CORD x)

count = 0;
if (CORD_iter5(x, CORD_ITER_CNT - 1, test_fn, CORD_NO_FN,
(void *)(GC_word)13) == 0) {
(void *)(GC_uintptr_t)13) == 0) {
ABORT("CORD_iter5 failed");
}
if (count != CORD_ITER_CNT + 2) ABORT("CORD_iter5 failed");

count = 0;
CORD_set_pos(p, x, CORD_ITER_CNT - 1);
while (CORD_pos_valid(p)) {
(void)test_fn(CORD_pos_fetch(p), (void *)(GC_word)13);
(void)test_fn(CORD_pos_fetch(p), (void *)(GC_uintptr_t)13);
CORD_next(p);
}
if (count != CORD_ITER_CNT + 2) ABORT("Position based iteration failed");
Expand Down Expand Up @@ -122,7 +122,7 @@ static void test_cord_x2(CORD x)

count = 0;
if (CORD_iter5(x, CORD_ITER_CNT - 1, test_fn, CORD_NO_FN,
(void *)(GC_word)13) == 0) {
(void *)(GC_uintptr_t)13) == 0) {
ABORT("CORD_iter5 failed");
}
if (count != CORD_ITER_CNT + 2) ABORT("CORD_iter5 failed");
Expand Down
Loading

0 comments on commit f68db21

Please sign in to comment.