Cast via uintptr_t
function pointer between object pointer
This commit is contained in:
parent
133bacc0dc
commit
6f6735898a
@ -5,6 +5,7 @@ typedef VALUE(*target_func)(VALUE);
|
||||
|
||||
static target_func rst_any_method;
|
||||
|
||||
#define resolve_func(file, name) (target_func)(uintptr_t)rb_ext_resolve_symbol(file, name)
|
||||
VALUE
|
||||
rsr_any_method(VALUE klass)
|
||||
{
|
||||
@ -15,7 +16,7 @@ VALUE
|
||||
rsr_try_resolve_fname(VALUE klass)
|
||||
{
|
||||
target_func rst_something_missing =
|
||||
(target_func) rb_ext_resolve_symbol("-test-/load/resolve_symbol_missing", "rst_any_method");
|
||||
resolve_func("-test-/load/resolve_symbol_missing", "rst_any_method");
|
||||
if (rst_something_missing == NULL) {
|
||||
// This should be done in Init_*, so the error is LoadError
|
||||
rb_raise(rb_eLoadError, "symbol not found: missing fname");
|
||||
@ -27,7 +28,7 @@ VALUE
|
||||
rsr_try_resolve_sname(VALUE klass)
|
||||
{
|
||||
target_func rst_something_missing =
|
||||
(target_func)rb_ext_resolve_symbol("-test-/load/resolve_symbol_target", "rst_something_missing");
|
||||
resolve_func("-test-/load/resolve_symbol_target", "rst_something_missing");
|
||||
if (rst_something_missing == NULL) {
|
||||
// This should be done in Init_*, so the error is LoadError
|
||||
rb_raise(rb_eLoadError, "symbol not found: missing sname");
|
||||
@ -43,7 +44,7 @@ Init_resolve_symbol_resolver(void)
|
||||
* If the module and methods are defined before raising LoadError, retrying `require "this.so"` will
|
||||
* cause re-defining those methods (and will be warned).
|
||||
*/
|
||||
rst_any_method = (target_func)rb_ext_resolve_symbol("-test-/load/resolve_symbol_target", "rst_any_method");
|
||||
rst_any_method = resolve_func("-test-/load/resolve_symbol_target", "rst_any_method");
|
||||
if (rst_any_method == NULL) {
|
||||
rb_raise(rb_eLoadError, "resolve_symbol_target is not loaded");
|
||||
}
|
||||
|
@ -3023,7 +3023,8 @@ vm_call_single_noarg_leaf_builtin(rb_execution_context_t *ec, rb_control_frame_t
|
||||
{
|
||||
const struct rb_builtin_function *bf = calling->cc->aux_.bf;
|
||||
cfp->sp -= (calling->argc + 1);
|
||||
return builtin_invoker0(ec, calling->recv, NULL, (rb_insn_func_t)bf->func_ptr);
|
||||
rb_insn_func_t func_ptr = (rb_insn_func_t)(uintptr_t)bf->func_ptr;
|
||||
return builtin_invoker0(ec, calling->recv, NULL, func_ptr);
|
||||
}
|
||||
|
||||
VALUE rb_gen_method_name(VALUE owner, VALUE name); // in vm_backtrace.c
|
||||
@ -7325,7 +7326,8 @@ invoke_bf(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const struct
|
||||
{
|
||||
const bool canary_p = ISEQ_BODY(reg_cfp->iseq)->builtin_attrs & BUILTIN_ATTR_LEAF; // Verify an assumption of `Primitive.attr! :leaf`
|
||||
SETUP_CANARY(canary_p);
|
||||
VALUE ret = (*lookup_builtin_invoker(bf->argc))(ec, reg_cfp->self, argv, (rb_insn_func_t)bf->func_ptr);
|
||||
rb_insn_func_t func_ptr = (rb_insn_func_t)(uintptr_t)bf->func_ptr;
|
||||
VALUE ret = (*lookup_builtin_invoker(bf->argc))(ec, reg_cfp->self, argv, func_ptr);
|
||||
CHECK_CANARY(canary_p, BIN(invokebuiltin));
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user