From c5bce670df0c89daf56f0bf07b8e34b9944bc12a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 18 Mar 2012 17:54:03 -0700 Subject: [PATCH] Use ffi_closure_alloc and ffi_prep_closure_loc on ARM. --- Execute.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Execute.cpp b/Execute.cpp index c6a5a99..13da508 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -695,6 +695,15 @@ Closure_privateData *CYMakeFunctor_(JSContextRef context, JSObjectRef function, // XXX: in point of fact, this may /need/ to leak :( Closure_privateData *internal(new Closure_privateData(context, function, type)); +#if defined(__APPLE__) && defined(__arm__) + void *executable; + ffi_closure *writable(reinterpret_cast(ffi_closure_alloc(sizeof(ffi_closure), &executable))); + + ffi_status status(ffi_prep_closure_loc(writable, &internal->cif_, callback, internal, executable)); + _assert(status == FFI_OK); + + internal->value_ = executable; +#else ffi_closure *closure((ffi_closure *) _syscall(mmap( NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, @@ -707,6 +716,7 @@ Closure_privateData *CYMakeFunctor_(JSContextRef context, JSObjectRef function, _syscall(mprotect(closure, sizeof(*closure), PROT_READ | PROT_EXEC)); internal->value_ = closure; +#endif return internal; } -- 2.45.2