[Python-checkins] r83926 - in python/branches/release31-maint: Misc/NEWS Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/ctypes.h Modules/_ctypes/libffi/fficonfig.py.in Modules/_ctypes/libffi_msvc/ffi.c Modules/_ctypes/libffi_msvc/ffi.h Modules/_ctypes/malloc_closure.c setup.py

antoine.pitrou python-checkins at python.org
Tue Aug 10 02:22:01 CEST 2010


Author: antoine.pitrou
Date: Tue Aug 10 02:22:01 2010
New Revision: 83926

Log:
Fix buildbot issues due to _ctypes failing to compile in 3.1.

Recorded rollback of revisions 83837,83841 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k



Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/Modules/_ctypes/_ctypes.c
   python/branches/release31-maint/Modules/_ctypes/callbacks.c
   python/branches/release31-maint/Modules/_ctypes/ctypes.h
   python/branches/release31-maint/Modules/_ctypes/libffi/fficonfig.py.in
   python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.c
   python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.h
   python/branches/release31-maint/Modules/_ctypes/malloc_closure.c
   python/branches/release31-maint/setup.py

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Tue Aug 10 02:22:01 2010
@@ -15,11 +15,6 @@
 - Issue #5319: Print an error if flushing stdout fails at interpreter
   shutdown.
 
-- Issue #6869: Fix a refcount problem in the _ctypes extension.
-
-- Issue #5504: ctypes should now work with systems where mmap can't
-  be PROT_WRITE and PROT_EXEC.
-
 - Issue #8814: function annotations (the ``__annotations__`` attribute)
   are now included in the set of attributes copied by default by
   functools.wraps and functools.update_wrapper.  Patch by Terrence Cole.

Modified: python/branches/release31-maint/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/_ctypes.c	Tue Aug 10 02:22:01 2010
@@ -3367,7 +3367,7 @@
     self->callable = callable;
 
     self->thunk = thunk;
-    *(void **)self->b_ptr = (void *)thunk->pcl_exec;
+    *(void **)self->b_ptr = (void *)thunk->pcl;
 
     Py_INCREF((PyObject *)thunk); /* for KeepRef */
     if (-1 == KeepRef((CDataObject *)self, 0, (PyObject *)thunk)) {
@@ -5326,42 +5326,36 @@
     Struct_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&Struct_Type) < 0)
         return NULL;
-    Py_INCREF(&Struct_Type);
     PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
 
     Py_TYPE(&Union_Type) = &UnionType_Type;
     Union_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&Union_Type) < 0)
         return NULL;
-    Py_INCREF(&Union_Type);
     PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
 
     Py_TYPE(&PyCPointer_Type) = &PyCPointerType_Type;
     PyCPointer_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&PyCPointer_Type) < 0)
         return NULL;
-    Py_INCREF(&PyCPointer_Type);
     PyModule_AddObject(m, "_Pointer", (PyObject *)&PyCPointer_Type);
 
     Py_TYPE(&PyCArray_Type) = &PyCArrayType_Type;
     PyCArray_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&PyCArray_Type) < 0)
         return NULL;
-    Py_INCREF(&PyCArray_Type);
     PyModule_AddObject(m, "Array", (PyObject *)&PyCArray_Type);
 
     Py_TYPE(&Simple_Type) = &PyCSimpleType_Type;
     Simple_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&Simple_Type) < 0)
         return NULL;
-    Py_INCREF(&Simple_Type);
     PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
 
     Py_TYPE(&PyCFuncPtr_Type) = &PyCFuncPtrType_Type;
     PyCFuncPtr_Type.tp_base = &PyCData_Type;
     if (PyType_Ready(&PyCFuncPtr_Type) < 0)
         return NULL;
-    Py_INCREF(&PyCFuncPtr_Type);
     PyModule_AddObject(m, "CFuncPtr", (PyObject *)&PyCFuncPtr_Type);
 
     /*************************************************

Modified: python/branches/release31-maint/Modules/_ctypes/callbacks.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/callbacks.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/callbacks.c	Tue Aug 10 02:22:01 2010
@@ -16,8 +16,8 @@
     Py_XDECREF(self->converters);
     Py_XDECREF(self->callable);
     Py_XDECREF(self->restype);
-    if (self->pcl_write)
-        ffi_closure_free(self->pcl_write);
+    if (self->pcl)
+        _ctypes_free_closure(self->pcl);
     PyObject_GC_Del(self);
 }
 
@@ -370,8 +370,7 @@
         return NULL;
     }
 
-    p->pcl_exec = NULL;
-    p->pcl_write = NULL;
+    p->pcl = NULL;
     memset(&p->cif, 0, sizeof(p->cif));
     p->converters = NULL;
     p->callable = NULL;
@@ -401,9 +400,8 @@
 
     assert(CThunk_CheckExact((PyObject *)p));
 
-    p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
-									 &p->pcl_exec);
-    if (p->pcl_write == NULL) {
+    p->pcl = _ctypes_alloc_closure();
+    if (p->pcl == NULL) {
         PyErr_NoMemory();
         goto error;
     }
@@ -448,9 +446,7 @@
                      "ffi_prep_cif failed with %d", result);
         goto error;
     }
-    result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
-				  p,
-				  p->pcl_exec);
+    result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
     if (result != FFI_OK) {
         PyErr_Format(PyExc_RuntimeError,
                      "ffi_prep_closure failed with %d", result);

Modified: python/branches/release31-maint/Modules/_ctypes/ctypes.h
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/ctypes.h	(original)
+++ python/branches/release31-maint/Modules/_ctypes/ctypes.h	Tue Aug 10 02:22:01 2010
@@ -58,8 +58,7 @@
 
 typedef struct {
     PyObject_VAR_HEAD
-    ffi_closure *pcl_write; /* the C callable, writeable */
-    void *pcl_exec;         /* the C callable, executable */
+    ffi_closure *pcl; /* the C callable */
     ffi_cif cif;
     int flags;
     PyObject *converters;

Modified: python/branches/release31-maint/Modules/_ctypes/libffi/fficonfig.py.in
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/libffi/fficonfig.py.in	(original)
+++ python/branches/release31-maint/Modules/_ctypes/libffi/fficonfig.py.in	Tue Aug 10 02:22:01 2010
@@ -1,7 +1,5 @@
 ffi_sources = """
 src/prep_cif.c
-src/closures.c
-src/dlmalloc.c
 """.split()
 
 ffi_platforms = {

Modified: python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.c	Tue Aug 10 02:22:01 2010
@@ -371,11 +371,10 @@
 extern void ffi_closure_OUTER();
 
 ffi_status
-ffi_prep_closure_loc (ffi_closure* closure,
-					  ffi_cif* cif,
-					  void (*fun)(ffi_cif*,void*,void**,void*),
-					  void *user_data,
-					  void *codeloc)
+ffi_prep_closure (ffi_closure* closure,
+		  ffi_cif* cif,
+		  void (*fun)(ffi_cif*,void*,void**,void*),
+		  void *user_data)
 {
   short bytes;
   char *tramp;
@@ -453,5 +452,6 @@
   closure->cif  = cif;
   closure->user_data = user_data;
   closure->fun  = fun;
+
   return FFI_OK;
 }

Modified: python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.h
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.h	(original)
+++ python/branches/release31-maint/Modules/_ctypes/libffi_msvc/ffi.h	Tue Aug 10 02:22:01 2010
@@ -221,15 +221,11 @@
   void      *user_data;
 } ffi_closure;
 
-void ffi_closure_free(void *);
-void *ffi_closure_alloc (size_t size, void **code);
-
 ffi_status
-ffi_prep_closure_loc (ffi_closure*,
+ffi_prep_closure (ffi_closure*,
 		  ffi_cif *,
 		  void (*fun)(ffi_cif*,void*,void**,void*),
-		  void *user_data,
-		  void *codeloc);
+		  void *user_data);
 
 typedef struct {
   char tramp[FFI_TRAMPOLINE_SIZE];

Modified: python/branches/release31-maint/Modules/_ctypes/malloc_closure.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/malloc_closure.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/malloc_closure.c	Tue Aug 10 02:22:01 2010
@@ -89,7 +89,7 @@
 /******************************************************************/
 
 /* put the item back into the free list */
-void ffi_closure_free(void *p)
+void _ctypes_free_closure(void *p)
 {
     ITEM *item = (ITEM *)p;
     item->next = free_list;
@@ -97,7 +97,7 @@
 }
 
 /* return one item from the free list, allocating more if needed */
-void *ffi_closure_alloc(size_t ignored, void** codeloc)
+void *_ctypes_alloc_closure(void)
 {
     ITEM *item;
     if (!free_list)
@@ -106,7 +106,5 @@
         return NULL;
     item = free_list;
     free_list = item->next;
-	*codeloc = (void *)item;
-    return (void *)item;
+    return item;
 }
-

Modified: python/branches/release31-maint/setup.py
==============================================================================
--- python/branches/release31-maint/setup.py	(original)
+++ python/branches/release31-maint/setup.py	Tue Aug 10 02:22:01 2010
@@ -1636,7 +1636,8 @@
                    '_ctypes/callbacks.c',
                    '_ctypes/callproc.c',
                    '_ctypes/stgdict.c',
-                   '_ctypes/cfield.c']
+                   '_ctypes/cfield.c',
+                   '_ctypes/malloc_closure.c']
         depends = ['_ctypes/ctypes.h']
 
         if sys.platform == 'darwin':


More information about the Python-checkins mailing list