5# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
6# define RB_OBJ_STRING(obj) (obj)
9# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
10# define RB_OBJ_STRING(obj) StringValueCStr(obj)
15#define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
17#define Check_Max_Args(name, len) \
18 Check_Max_Args_(name, len, "")
19#define Check_Max_Args_Long(name, len) \
20 Check_Max_Args_(name, len, "l")
21#define Check_Max_Args_(name, len, fmt) \
22 if ((size_t)(len) < MAX_ARGS) { \
26 rb_raise(rb_eTypeError, \
27 name" is so large that it can cause integer overflow (%"fmt"d)", \
40function_memsize(
const void *p)
42 ffi_cif *
ptr = (ffi_cif *)p;
46#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
55 {0, deallocate, function_memsize,},
94 ffi_type **arg_types, *rtype;
96 VALUE ptr, args, ret_type, abi, kwds, ary;
127 rb_iv_set(
self,
"@return_type", ret_type);
134 arg_types =
xcalloc(
len + 1,
sizeof(ffi_type *));
158nogvl_ffi_call(
void *
ptr)
174 VALUE alloc_buffer = 0;
187 generic_args =
ALLOCV(alloc_buffer,
189 args.
values = (
void **)((
char *)generic_args +
207 args.
values[
i] = (
void *)&generic_args[
i];
271#ifdef HAVE_CONST_FFI_STDCALL
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
#define INT2FFI_TYPE(_type)
#define VALUE2GENERIC(_type, _src, _dst)
#define GENERIC2VALUE(_type, _retval)
#define rb_ary_subseq(ary, beg, len)
const rb_data_type_t function_data_type
#define RB_OBJ_STRING(obj)
VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type)
#define Check_Max_Args(name, len)
void Init_fiddle_function(void)
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_cObject
Object class.
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
Allocates and initializes an instance of klass.
VALUE rb_Integer(VALUE)
Equivalent to Kernel#Integer in Ruby.
VALUE type(ANYARGS)
ANYARGS-ed function type.
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)
size_t ffi_raw_size(ffi_cif *cif)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
MJIT_STATIC void rb_error_arity(int argc, int min, int max)