diff Modules/_ctypes/callbacks.c @ 63831:e13ea83e2edb 2.7

Fis issue5504: ctypes does now work with systems where mmap can't be PROT_WRITE and PROT_EXEC.
author Thomas Heller <theller@ctypes.org>
date Sun, 08 Aug 2010 17:56:41 +0000
parents fd25030223b0
children d1771b4cd0cb
line wrap: on
line diff
--- a/Modules/_ctypes/callbacks.c	Sun Aug 08 16:18:45 2010 +0000
+++ b/Modules/_ctypes/callbacks.c	Sun Aug 08 17:56:41 2010 +0000
@@ -21,8 +21,8 @@
     Py_XDECREF(self->converters);
     Py_XDECREF(self->callable);
     Py_XDECREF(self->restype);
-    if (self->pcl)
-        _ctypes_free_closure(self->pcl);
+    if (self->pcl_write)
+        ffi_closure_free(self->pcl_write);
     PyObject_GC_Del(self);
 }
 
@@ -391,7 +391,8 @@
         return NULL;
     }
 
-    p->pcl = NULL;
+    p->pcl_exec = NULL;
+    p->pcl_write = NULL;
     memset(&p->cif, 0, sizeof(p->cif));
     p->converters = NULL;
     p->callable = NULL;
@@ -421,8 +422,9 @@
 
     assert(CThunk_CheckExact(p));
 
-    p->pcl = _ctypes_alloc_closure();
-    if (p->pcl == NULL) {
+    p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
+				     &p->pcl_exec);
+    if (p->pcl_write == NULL) {
         PyErr_NoMemory();
         goto error;
     }
@@ -467,7 +469,9 @@
                      "ffi_prep_cif failed with %d", result);
         goto error;
     }
-    result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
+    result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
+				  p,
+				  p->pcl_exec);
     if (result != FFI_OK) {
         PyErr_Format(PyExc_RuntimeError,
                      "ffi_prep_closure failed with %d", result);