13 #if defined(MACOSX) || defined(__linux__) || defined(__OpenBSD__) 14 #define DONT_USE_FFI_CLOSURE_ALLOC 21 #ifndef DONT_USE_FFI_CLOSURE_ALLOC 22 ffi_closure_free(cls->
pcl);
24 munmap(cls->
pcl,
sizeof(*cls->
pcl));
38 #if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API 39 size += ffi_raw_size(&cls->
cif);
42 size +=
sizeof(ffi_closure);
111 case -TYPE_LONG_LONG:
136 *(ffi_sarg *)resp =
NUM2INT(ret);
147 *(
double *)resp =
NUM2DBL(ret);
150 *(
float *)resp = (
float)
NUM2DBL(ret);
154 *(LONG_LONG *)resp = NUM2LL(ret);
156 case -TYPE_LONG_LONG:
157 *(
unsigned LONG_LONG *)resp = NUM2ULL(ret);
173 #ifndef DONT_USE_FFI_CLOSURE_ALLOC 174 closure->
pcl = ffi_closure_alloc(
sizeof(ffi_closure), &closure->
code);
176 closure->
pcl = mmap(
NULL,
sizeof(ffi_closure), PROT_READ | PROT_WRITE,
177 MAP_ANON | MAP_PRIVATE, -1, 0);
196 abi =
INT2NUM(FFI_DEFAULT_ABI);
225 #ifndef DONT_USE_FFI_CLOSURE_ALLOC 227 (
void *)
self, cl->
code);
230 cl->
code = (
void *)pcl;
231 i = mprotect(pcl,
sizeof(*pcl), PROT_READ | PROT_EXEC);
static VALUE rb_float_new(double d)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_ary_push(VALUE ary, VALUE item)
VALUE rb_ary_tmp_new(long capa)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_raise(VALUE exc, const char *fmt,...)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
void callback(ffi_cif *cif, void *resp, void **args, void *ctx)
RUBY_EXTERN VALUE rb_cObject
static VALUE to_i(VALUE self)
VALUE rb_iv_get(VALUE, const char *)
const rb_data_type_t closure_data_type
#define INT2FFI_TYPE(_type)
static void dealloc(void *ptr)
VALUE rb_const_get(VALUE, ID)
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
VALUE rb_iv_set(VALUE, const char *, VALUE)
static VALUE initialize(int rbargc, VALUE argv[], VALUE self)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
#define RARRAY_LENINT(ary)
void rb_sys_fail(const char *mesg)
static VALUE allocate(VALUE klass)
#define TypedData_Make_Struct(klass, type, data_type, sval)
void Init_fiddle_closure()
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static size_t closure_memsize(const void *ptr)