зеркало из https://github.com/github/ruby.git
Cast via `uintptr_t` function pointer between object pointer
- ISO C forbids conversion of function pointer to object pointer type - ISO C forbids conversion of object pointer to function pointer type
This commit is contained in:
Родитель
d8b64eac55
Коммит
9a90cd2284
|
@ -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, \
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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] */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
4
dln.c
4
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) \
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <ruby.h>
|
||||
|
||||
#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
|
||||
|
|
8
gc.c
8
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) : "<NULL>",
|
||||
cme ? (METHOD_ENTRY_INVALIDATED(cme) ? " [inv]" : "") : "",
|
||||
(void *)cme,
|
||||
(void *)vm_cc_call(cc));
|
||||
(void *)(uintptr_t)vm_cc_call(cc));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -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) = {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
2
rjit_c.c
2
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);
|
||||
|
|
|
@ -7339,7 +7339,8 @@ vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp,
|
|||
for (int i=0; i<bf->argc; 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) {
|
||||
|
|
|
@ -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
|
||||
|
|
6
yjit.c
6
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче