From 4122120b788df74b7db379b980e853582f555053 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Mon, 3 Mar 2008 21:57:14 +0100 Subject: Use the new libffi closure API. darcs-hash:e0e968e79421b740be0860798977a8a205d682fd --- Objective-C/libobjcl.m | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index c4dc718..fb9c0a8 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -700,6 +700,7 @@ objcl_create_imp (IMP callback, ffi_status status; ffi_cif cif; ffi_closure *closure; + void *code; int i; @@ -722,6 +723,9 @@ objcl_create_imp (IMP callback, for (i = 0; i < argc; i++) arg_types[i + 2] = objcl_pyobjc_arg_signature_to_ffi_type (arg_typespecs[i]); + TRACE (@"create-imp: closure-alloc"); + closure = ffi_closure_alloc (sizeof (ffi_closure), &code); + TRACE (@"create-imp: prep-cif"); status = ffi_prep_cif (&cif, FFI_DEFAULT_ABI, argc + 2, return_type, arg_types); if (status != FFI_OK) @@ -731,8 +735,9 @@ objcl_create_imp (IMP callback, userInfo: nil] raise]; } - TRACE (@"create-imp: prep-closure"); - status = ffi_prep_closure (closure, &cif, imp_closure, (void *)callback); + TRACE (@"create-imp: prep-closure-loc"); + status = ffi_prep_closure_loc (closure, &cif, imp_closure, + (void *)callback, code); if (status != FFI_OK) { [[NSException exceptionWithName: @"MLKClosureCreationFailure" @@ -740,16 +745,6 @@ objcl_create_imp (IMP callback, userInfo: nil] raise]; } - TRACE (@"create-imp: mprotect"); - if (mprotect (closure, sizeof (closure), PROT_READ | PROT_EXEC) == -1) - { -#if 0 - [[NSException exceptionWithName: @"MLKClosureCreationFailure" - reason: @"Creating an IMP closure failed (this is probably a bug)." - userInfo: nil] raise]; -#endif - } - TRACE (@"create-imp: Closure created."); return (IMP) closure; } -- cgit v1.2.3