Ruby
2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)
|
Go to the documentation of this file.
16 #if defined(USE_FFI_CLOSURE_ALLOC)
17 #elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__)
18 # define USE_FFI_CLOSURE_ALLOC 0
19 #elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \
20 (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64))
21 # define USE_FFI_CLOSURE_ALLOC 0
23 # define USE_FFI_CLOSURE_ALLOC 1
30 #if USE_FFI_CLOSURE_ALLOC
31 ffi_closure_free(cls->
pcl);
33 munmap(cls->
pcl,
sizeof(*cls->
pcl));
40 closure_memsize(
const void *
ptr)
46 #if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
50 size +=
sizeof(ffi_closure);
57 {0, dealloc, closure_memsize,},
68 with_gvl_callback(
void *
ptr)
128 case -TYPE_LONG_LONG:
173 case -TYPE_LONG_LONG:
194 (
void)with_gvl_callback(&x);
208 #if USE_FFI_CLOSURE_ALLOC
209 closure->
pcl = ffi_closure_alloc(
sizeof(ffi_closure), &closure->
code);
211 closure->
pcl = mmap(
NULL,
sizeof(ffi_closure), PROT_READ | PROT_WRITE,
212 MAP_ANON | MAP_PRIVATE, -1, 0);
257 if (FFI_OK != result)
260 #if USE_FFI_CLOSURE_ALLOC
262 (
void *)
self, cl->
code);
264 result = ffi_prep_closure(pcl,
cif, callback, (
void *)
self);
265 cl->
code = (
void *)pcl;
266 i = mprotect(pcl,
sizeof(*pcl), PROT_READ | PROT_EXEC);
272 if (FFI_OK != result)
void Init_fiddle_closure(void)
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define RARRAY_LENINT(ary)
void rb_raise(VALUE exc, const char *fmt,...)
const rb_data_type_t closure_data_type
VALUE rb_iv_get(VALUE, const char *)
VALUE rb_ary_tmp_new(long capa)
VALUE rb_ary_push(VALUE ary, VALUE item)
#define INT2FFI_TYPE(_type)
void rb_sys_fail(const char *mesg)
#define RARRAY_AREF(a, i)
size_t ffi_raw_size(ffi_cif *cif)
#define RARRAY_CONST_PTR(a)
RUBY_EXTERN VALUE rb_cObject
#define TypedData_Get_Struct(obj, type, data_type, sval)
int ruby_thread_has_gvl_p(void)
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, void **, void *), void *user_data, void *codeloc)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE type(ANYARGS)
ANYARGS-ed function type.
VALUE rb_iv_set(VALUE, const char *, VALUE)
RUBY_SYMBOL_EXPORT_BEGIN void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)
VALUE rb_const_get(VALUE, ID)