#! /bin/sh -e ## DP: Taken from http://git.openmoko.org/?p=openmoko.git;a=blob;f=packages/python/python-2.5.1/enable-ctypes-module.patch;h=dd5adaf0e7d72410ec49d77d9fcf4ca430179fc5;hb=b5f4910681c247295fed9e22ac92bf9f1a3fc4a7 dir= if [ $# -eq 3 -a "$2" = '-d' ]; then pdir="-d $3" dir="$3/" elif [ $# -ne 1 ]; then echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" exit 1 fi case "$1" in -patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0 ;; -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0 ;; *) echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" exit 1 esac exit 0 diff -urNad python2.5-2.5.2~/Modules/_ctypes/_ctypes.c python2.5-2.5.2/Modules/_ctypes/_ctypes.c --- python2.5-2.5.2~/Modules/_ctypes/_ctypes.c 2008-11-13 15:36:43.000000000 +0100 +++ python2.5-2.5.2/Modules/_ctypes/_ctypes.c 2008-11-13 15:37:13.000000000 +0100 @@ -3430,7 +3430,9 @@ Py_CLEAR(self->paramflags); if (self->thunk) { +#if FFI_CLOSURES FreeClosure(self->thunk->pcl); +#endif PyMem_Free(self->thunk); self->thunk = NULL; } diff -urNad python2.5-2.5.2~/Modules/_ctypes/callbacks.c python2.5-2.5.2/Modules/_ctypes/callbacks.c --- python2.5-2.5.2~/Modules/_ctypes/callbacks.c 2008-11-13 15:36:43.000000000 +0100 +++ python2.5-2.5.2/Modules/_ctypes/callbacks.c 2008-11-13 15:37:13.000000000 +0100 @@ -273,11 +273,13 @@ PyErr_NoMemory(); return NULL; } +#if FFI_CLOSURES p->pcl = MallocClosure(); if (p->pcl == NULL) { PyErr_NoMemory(); goto error; } +#endif for (i = 0; i < nArgs; ++i) { PyObject *cnv = PySequence_GetItem(converters, i); @@ -315,12 +317,14 @@ "ffi_prep_cif failed with %d", result); goto error; } +#if FFI_CLOSURES 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); goto error; } +#endif p->converters = converters; p->callable = callable; @@ -328,8 +332,10 @@ error: if (p) { +#if FFI_CLOSURES if (p->pcl) FreeClosure(p->pcl); +#endif PyMem_Free(p); } return NULL; diff -urNad python2.5-2.5.2~/Modules/_ctypes/ctypes.h python2.5-2.5.2/Modules/_ctypes/ctypes.h --- python2.5-2.5.2~/Modules/_ctypes/ctypes.h 2008-11-13 15:36:43.000000000 +0100 +++ python2.5-2.5.2/Modules/_ctypes/ctypes.h 2008-11-13 15:37:13.000000000 +0100 @@ -68,7 +68,9 @@ }; typedef struct { +#if FFI_CLOSURES ffi_closure *pcl; /* the C callable */ +#endif ffi_cif cif; PyObject *converters; PyObject *callable; diff -urNad python2.5-2.5.2~/Modules/_ctypes/malloc_closure.c python2.5-2.5.2/Modules/_ctypes/malloc_closure.c --- python2.5-2.5.2~/Modules/_ctypes/malloc_closure.c 2006-06-12 22:56:48.000000000 +0200 +++ python2.5-2.5.2/Modules/_ctypes/malloc_closure.c 2008-11-13 15:37:13.000000000 +0100 @@ -27,7 +27,9 @@ /******************************************************************/ typedef union _tagITEM { +#if FFI_CLOSURES ffi_closure closure; +#endif union _tagITEM *next; } ITEM;