[pypy-commit] cffi default: Minor hack to remove one indirection in the _cffi_exports function calls.

arigo noreply at buildbot.pypy.org
Thu Jun 14 23:56:36 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r362:0b7ef6b5be53
Date: 2012-06-14 23:56 +0200
http://bitbucket.org/cffi/cffi/changeset/0b7ef6b5be53/

Log:	Minor hack to remove one indirection in the _cffi_exports function
	calls.

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -479,6 +479,7 @@
     ((void(*)(void))_cffi_exports[13])
 #define _cffi_save_errno                                                 \
     ((void(*)(void))_cffi_exports[14])
+#define _CFFI_NUM_EXPORTS 15
 
 #if SIZEOF_LONG < SIZEOF_LONG_LONG
 #  define _cffi_to_c_long_long PyLong_AsLongLong
@@ -488,7 +489,7 @@
 
 typedef struct _ctypedescr CTypeDescrObject;
 
-static void **_cffi_exports;
+static void *_cffi_exports[_CFFI_NUM_EXPORTS];
 static PyObject *_cffi_types, *_cffi_VerificationError;
 
 static PyObject *_cffi_setup_custom(void);   /* forward */
@@ -518,7 +519,8 @@
         PyErr_SetNone(PyExc_ImportError);
         return;
     }
-    _cffi_exports = (void **)PyCObject_AsVoidPtr(c_api_object);
+    memcpy(_cffi_exports, PyCObject_AsVoidPtr(c_api_object),
+           _CFFI_NUM_EXPORTS * sizeof(void *));
 }
 
 #define _cffi_type(num) ((CTypeDescrObject *)PyList_GET_ITEM(_cffi_types, num))


More information about the pypy-commit mailing list