diff --git a/builtin.h b/builtin.h index 24aa7c2fdb..f23c0a7dad 100644 --- a/builtin.h +++ b/builtin.h @@ -15,7 +15,7 @@ struct rb_builtin_function { #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) {\ .name = _i < 0 ? NULL : #_name, \ - .func_ptr = (void *)_fname, \ + .func_ptr = (void *)(uintptr_t)_fname, \ .argc = _arity, \ .index = _i, \ } diff --git a/compile.c b/compile.c index 5434a0cf05..6e78b07518 100644 --- a/compile.c +++ b/compile.c @@ -9141,7 +9141,7 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD if (cconst) { typedef VALUE(*builtin_func0)(void *, VALUE); - VALUE const_val = (*(builtin_func0)bf->func_ptr)(NULL, Qnil); + VALUE const_val = (*(builtin_func0)(uintptr_t)bf->func_ptr)(NULL, Qnil); ADD_INSN1(ret, line_node, putobject, const_val); return COMPILE_OK; } diff --git a/coroutine/amd64/Context.h b/coroutine/amd64/Context.h index 44daa4e01a..65aa638304 100644 --- a/coroutine/amd64/Context.h +++ b/coroutine/amd64/Context.h @@ -69,7 +69,7 @@ static inline void coroutine_initialize( context->stack_pointer = (void**)((uintptr_t)top & ~0xF); *--context->stack_pointer = NULL; - *--context->stack_pointer = (void*)start; + *--context->stack_pointer = (void*)(uintptr_t)start; context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); diff --git a/coroutine/arm32/Context.h b/coroutine/arm32/Context.h index 09410eb25d..7529dd2efc 100644 --- a/coroutine/arm32/Context.h +++ b/coroutine/arm32/Context.h @@ -44,7 +44,7 @@ static inline void coroutine_initialize( char * top = (char*)stack + size; context->stack_pointer = (void**)((uintptr_t)top & ~0xF); - *--context->stack_pointer = (void*)start; + *--context->stack_pointer = (void*)(uintptr_t)start; context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); diff --git a/coroutine/arm64/Context.h b/coroutine/arm64/Context.h index eb66fbea0f..b6ca5b8dde 100644 --- a/coroutine/arm64/Context.h +++ b/coroutine/arm64/Context.h @@ -86,7 +86,8 @@ static inline void coroutine_initialize( context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); - context->stack_pointer[0x98 / 8] = ptrauth_sign_instruction_addr((void*)start, (void*)top); + void *addr = (void*)(uintptr_t)start; + context->stack_pointer[0x98 / 8] = ptrauth_sign_instruction_addr(addr, (void*)top); } struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target); diff --git a/coroutine/loongarch64/Context.h b/coroutine/loongarch64/Context.h index 668c9a965e..82b85b36e9 100644 --- a/coroutine/loongarch64/Context.h +++ b/coroutine/loongarch64/Context.h @@ -36,7 +36,7 @@ static inline void coroutine_initialize( context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); - context->stack_pointer[0x90 / 8] = (void*)start; + context->stack_pointer[0x90 / 8] = (void*)(uintptr_t)start; } struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target); diff --git a/coroutine/riscv64/Context.h b/coroutine/riscv64/Context.h index 9ce1140e0b..3660fb5577 100644 --- a/coroutine/riscv64/Context.h +++ b/coroutine/riscv64/Context.h @@ -36,7 +36,7 @@ static inline void coroutine_initialize( context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); - context->stack_pointer[0xc0 / 8] = (void*)start; + context->stack_pointer[0xc0 / 8] = (void*)(uintptr_t)start; } struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target); diff --git a/coroutine/win32/Context.h b/coroutine/win32/Context.h index 902fd1246f..243ae5a43b 100644 --- a/coroutine/win32/Context.h +++ b/coroutine/win32/Context.h @@ -45,7 +45,7 @@ static inline void coroutine_initialize( char * top = (char*)stack + size; context->stack_pointer = (void**)((uintptr_t)top & ~0xF); - *--context->stack_pointer = (void*)start; + *--context->stack_pointer = (void*)(uintptr_t)start; /* Windows Thread Information Block */ *--context->stack_pointer = (void*)0xFFFFFFFF; /* fs:[0] */ diff --git a/coroutine/win64/Context.h b/coroutine/win64/Context.h index d85ebf8e0e..c5cab729f8 100644 --- a/coroutine/win64/Context.h +++ b/coroutine/win64/Context.h @@ -53,7 +53,7 @@ static inline void coroutine_initialize( /* Return address */ *--context->stack_pointer = 0; - *--context->stack_pointer = (void*)start; + *--context->stack_pointer = (void*)(uintptr_t)start; *--context->stack_pointer = (void*)coroutine_trampoline; /* Windows Thread Information Block */ diff --git a/coroutine/x86/Context.h b/coroutine/x86/Context.h index d98eaf6486..f33b338eab 100644 --- a/coroutine/x86/Context.h +++ b/coroutine/x86/Context.h @@ -45,7 +45,7 @@ static inline void coroutine_initialize( context->stack_pointer = (void**)((uintptr_t)top & ~0xF); *--context->stack_pointer = NULL; - *--context->stack_pointer = (void*)start; + *--context->stack_pointer = (void*)(uintptr_t)start; context->stack_pointer -= COROUTINE_REGISTERS; memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); diff --git a/dln.c b/dln.c index db6ea5aa0f..043815148b 100644 --- a/dln.c +++ b/dln.c @@ -437,7 +437,7 @@ dln_sym(void *handle, const char *symbol) #endif } -static void * +static uintptr_t dln_sym_func(void *handle, const char *symbol) { void *func = dln_sym(handle, symbol); @@ -453,7 +453,7 @@ dln_sym_func(void *handle, const char *symbol) #endif dln_loaderror("%s - %s", error, symbol); } - return func; + return (uintptr_t)func; } #define dln_sym_callable(rettype, argtype, handle, symbol) \ diff --git a/ext/-test-/fatal/invalid.c b/ext/-test-/fatal/invalid.c index f0726edb52..393465416a 100644 --- a/ext/-test-/fatal/invalid.c +++ b/ext/-test-/fatal/invalid.c @@ -1,9 +1,9 @@ #include #if SIZEOF_LONG == SIZEOF_VOIDP -# define NUM2PTR(x) (void *)NUM2ULONG(x) +# define NUM2PTR(x) NUM2ULONG(x) #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP -# define NUM2PTR(x) (void *)NUM2ULL(x) +# define NUM2PTR(x) NUM2ULL(x) #endif static VALUE diff --git a/gc.c b/gc.c index c4381e2315..c31da44df4 100644 --- a/gc.c +++ b/gc.c @@ -2478,6 +2478,8 @@ rb_gc_mark_roots(void *objspace, const char **categoryp) #undef MARK_CHECKPOINT } +#define TYPED_DATA_REFS_OFFSET_LIST(d) (size_t *)(uintptr_t)RTYPEDDATA(d)->type->function.dmark + void rb_gc_mark_children(void *objspace, VALUE obj) { @@ -2597,7 +2599,7 @@ rb_gc_mark_children(void *objspace, VALUE obj) if (ptr) { if (RTYPEDDATA_P(obj) && gc_declarative_marking_p(RTYPEDDATA(obj)->type)) { - size_t *offset_list = (size_t *)RTYPEDDATA(obj)->type->function.dmark; + size_t *offset_list = TYPED_DATA_REFS_OFFSET_LIST(obj); for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) { gc_mark_internal(*(VALUE *)((char *)ptr + offset)); @@ -3254,7 +3256,7 @@ rb_gc_update_object_references(void *objspace, VALUE obj) void *const ptr = RTYPEDDATA_P(obj) ? RTYPEDDATA_GET_DATA(obj) : DATA_PTR(obj); if (ptr) { if (RTYPEDDATA_P(obj) && gc_declarative_marking_p(RTYPEDDATA(obj)->type)) { - size_t *offset_list = (size_t *)RTYPEDDATA(obj)->type->function.dmark; + size_t *offset_list = TYPED_DATA_REFS_OFFSET_LIST(obj); for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) { VALUE *ref = (VALUE *)((char *)ptr + offset); @@ -3926,7 +3928,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU cme ? rb_id2name(cme->called_id) : "", cme ? (METHOD_ENTRY_INVALIDATED(cme) ? " [inv]" : "") : "", (void *)cme, - (void *)vm_cc_call(cc)); + (void *)(uintptr_t)vm_cc_call(cc)); break; } default: diff --git a/include/ruby/internal/gc.h b/include/ruby/internal/gc.h index 462f416af2..5ab3bb266e 100644 --- a/include/ruby/internal/gc.h +++ b/include/ruby/internal/gc.h @@ -45,7 +45,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() #define RUBY_REF_EDGE(s, p) offsetof(s, p) -#define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(l) +#define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(uintptr_t)(l) #define RUBY_REF_END SIZE_MAX #define RUBY_REFERENCES(t) static const size_t t[] #define RUBY_REFERENCES_START(t) RUBY_REFERENCES(t) = { diff --git a/prism_compile.c b/prism_compile.c index 5f5e0aa6fe..aca358f871 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -3557,7 +3557,7 @@ retry:; if (cconst) { typedef VALUE(*builtin_func0)(void *, VALUE); - VALUE const_val = (*(builtin_func0)bf->func_ptr)(NULL, Qnil); + VALUE const_val = (*(builtin_func0)(uintptr_t)bf->func_ptr)(NULL, Qnil); PUSH_INSN1(ret, *node_location, putobject, const_val); return COMPILE_OK; } diff --git a/rjit_c.c b/rjit_c.c index e9863129a1..50eb263559 100644 --- a/rjit_c.c +++ b/rjit_c.c @@ -66,7 +66,7 @@ rjit_reserve_addr_space(uint32_t mem_size) // On Linux #if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE) uint32_t const page_size = (uint32_t)sysconf(_SC_PAGESIZE); - uint8_t *const cfunc_sample_addr = (void *)&rjit_reserve_addr_space; + uint8_t *const cfunc_sample_addr = (void *)(uintptr_t)&rjit_reserve_addr_space; uint8_t *const probe_region_end = cfunc_sample_addr + INT32_MAX; // Align the requested address to page size uint8_t *req_addr = align_ptr(cfunc_sample_addr, page_size); diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 543f31a3b1..ea4ce49b63 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -7339,7 +7339,8 @@ vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp, for (int i=0; iargc; i++) { ruby_debug_printf(":%s ", rb_id2name(ISEQ_BODY(cfp->iseq)->local_table[i+start_index])); } - ruby_debug_printf("\n" "%s %s(%d):%p\n", RUBY_FUNCTION_NAME_STRING, bf->name, bf->argc, bf->func_ptr); + ruby_debug_printf("\n" "%s %s(%d):%p\n", RUBY_FUNCTION_NAME_STRING, bf->name, bf->argc, + (void *)(uintptr_t)bf->func_ptr); } if (bf->argc == 0) { diff --git a/vm_trace.c b/vm_trace.c index 7f3f3cd6f4..f7baf3b309 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -1760,7 +1760,7 @@ rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, v rb_postponed_job_queues_t *pjq = GET_VM()->postponed_job_queue; for (unsigned int i = 0; i < PJOB_TABLE_SIZE; i++) { /* Try and set this slot to equal `func` */ - rb_postponed_job_func_t existing_func = (rb_postponed_job_func_t)RUBY_ATOMIC_PTR_CAS(pjq->table[i], NULL, (void *)func); + rb_postponed_job_func_t existing_func = (rb_postponed_job_func_t)(uintptr_t)RUBY_ATOMIC_PTR_CAS(pjq->table[i].func, NULL, (void *)(uintptr_t)func); if (existing_func == NULL || existing_func == func) { /* Either this slot was NULL, and we set it to func, or, this slot was already equal to func. * In either case, clobber the data with our data. Note that concurrent calls to diff --git a/yjit.c b/yjit.c index dedd06dd2d..93d8fe5c9f 100644 --- a/yjit.c +++ b/yjit.c @@ -272,7 +272,7 @@ rb_yjit_reserve_addr_space(uint32_t mem_size) // On Linux #if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE) uint32_t const page_size = (uint32_t)sysconf(_SC_PAGESIZE); - uint8_t *const cfunc_sample_addr = (void *)&rb_yjit_reserve_addr_space; + uint8_t *const cfunc_sample_addr = (void *)(uintptr_t)&rb_yjit_reserve_addr_space; uint8_t *const probe_region_end = cfunc_sample_addr + INT32_MAX; // Align the requested address to page size uint8_t *req_addr = align_ptr(cfunc_sample_addr, page_size); @@ -583,7 +583,7 @@ rb_get_mct_argc(const rb_method_cfunc_t *mct) void * rb_get_mct_func(const rb_method_cfunc_t *mct) { - return (void*)mct->func; // this field is defined as type VALUE (*func)(ANYARGS) + return (void*)(uintptr_t)mct->func; // this field is defined as type VALUE (*func)(ANYARGS) } const rb_iseq_t * @@ -1139,7 +1139,7 @@ rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit // Compile a block version starting at the current instruction uint8_t *rb_yjit_iseq_gen_entry_point(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception); // defined in Rust - uint8_t *code_ptr = rb_yjit_iseq_gen_entry_point(iseq, ec, jit_exception); + uintptr_t code_ptr = (uintptr_t)rb_yjit_iseq_gen_entry_point(iseq, ec, jit_exception); if (jit_exception) { iseq->body->jit_exception = (rb_jit_func_t)code_ptr;