summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-03 21:57:14 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-03 21:57:14 +0100
commit4122120b788df74b7db379b980e853582f555053 (patch)
treef18b2dd01dd6e35dc0087a402547527292f91cb2
parentcd11ae061b002913740483529e31b3f6d3da753d (diff)
Use the new libffi closure API.
darcs-hash:e0e968e79421b740be0860798977a8a205d682fd
-rw-r--r--Objective-C/libobjcl.m19
1 files changed, 7 insertions, 12 deletions
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;
}