16#if defined(USE_FFI_CLOSURE_ALLOC)
17#elif !defined(HAVE_FFI_CLOSURE_ALLOC)
18# define USE_FFI_CLOSURE_ALLOC 0
20# define USE_FFI_CLOSURE_ALLOC 1
27#if USE_FFI_CLOSURE_ALLOC
28 ffi_closure_free(cls->
pcl);
30 munmap(cls->
pcl,
sizeof(*cls->
pcl));
37closure_memsize(
const void *
ptr)
43#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
47 size +=
sizeof(ffi_closure);
54 {0, dealloc, closure_memsize,},
65with_gvl_callback(
void *
ptr)
125 case -TYPE_LONG_LONG:
170 case -TYPE_LONG_LONG:
191 (
void)with_gvl_callback(&x);
205#if USE_FFI_CLOSURE_ALLOC
206 closure->
pcl = ffi_closure_alloc(
sizeof(ffi_closure), &closure->
code);
208 closure->
pcl = mmap(
NULL,
sizeof(ffi_closure), PROT_READ | PROT_WRITE,
209 MAP_ANON | MAP_PRIVATE, -1, 0);
254 if (FFI_OK != result)
257#if USE_FFI_CLOSURE_ALLOC
259 (
void *)
self, cl->
code);
261 result = ffi_prep_closure(pcl,
cif, callback, (
void *)
self);
262 cl->
code = (
void *)pcl;
263 i = mprotect(pcl,
sizeof(*pcl), PROT_READ | PROT_EXEC);
269 if (FFI_OK != result)
ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, void **, void *), void *user_data, void *codeloc)
int ruby_thread_has_gvl_p(void)
const rb_data_type_t closure_data_type
void Init_fiddle_closure(void)
#define INT2FFI_TYPE(_type)
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_define_module(const char *)
VALUE rb_cObject
Object class.
void rb_raise(VALUE exc, const char *fmt,...)
void rb_sys_fail(const char *mesg)
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)
RUBY_SYMBOL_EXPORT_BEGIN void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)