Author: Armin Rigo <[email protected]>
Branch: cpyext-avoid-roundtrip
Changeset: r92552:05c413f37f2c
Date: 2017-10-02 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/05c413f37f2c/

Log:    (antocuni, arigo)

        Simplification again, using the fixes in ll2ctypes.

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1082,9 +1082,8 @@
     _, state.C.set_marker = rffi.CExternVariable(
                    Py_ssize_t, '_pypy_rawrefcount_w_marker_deallocating',
                    eci, _nowrapper=True, c_type='Py_ssize_t')
-    # XXX meeeeeeeeessssss mmmmmmmmmmmmmmmeeeeeeeeeeeeeeeeeeeeeessssssssssss
-    state.C._PyPy_get_subtype_dealloc = rffi.llexternal(
-        '_PyPy_get_subtype_dealloc', [], rffi.VOIDP,
+    state.C._PyPy_subtype_dealloc = rffi.llexternal(
+        '_PyPy_subtype_dealloc', [PyObject], lltype.Void,
         compilation_info=eci, _nowrapper=True)
 
 
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -335,7 +335,7 @@
 PyAPI_FUNC(int) PyPyType_Register(PyTypeObject *);
 #define PyObject_Length PyObject_Size
 #define _PyObject_GC_Del PyObject_GC_Del
-PyAPI_FUNC(void *) _PyPy_get_subtype_dealloc(void);
+PyAPI_FUNC(void) _PyPy_subtype_dealloc(PyObject *);
 
 
 #ifdef __cplusplus
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -28,7 +28,7 @@
 
     def get_dealloc(self, space):
         state = space.fromcache(State)
-        return cts.cast('destructor', state.C._PyPy_get_subtype_dealloc())
+        return state.C._PyPy_subtype_dealloc
 
     def allocate(self, space, w_type, itemcount=0, immortal=False):
         # typically called from PyType_GenericAlloc via typedescr.allocate
diff --git a/pypy/module/cpyext/src/typeobject.c 
b/pypy/module/cpyext/src/typeobject.c
--- a/pypy/module/cpyext/src/typeobject.c
+++ b/pypy/module/cpyext/src/typeobject.c
@@ -1,6 +1,7 @@
 #include "Python.h"
 
-static void subtype_dealloc(PyObject *obj)
+void
+_PyPy_subtype_dealloc(PyObject *obj)
 {
     PyTypeObject *pto = obj->ob_type;
     PyTypeObject *base = pto;
@@ -11,12 +12,12 @@
        inheritance chain until base.c_tp_dealloc is exactly this_func, and then
        continue on up until they differ.
        */
-    while (base->tp_dealloc != &subtype_dealloc)
+    while (base->tp_dealloc != &_PyPy_subtype_dealloc)
     {
         base = base->tp_base;
         assert(base);
     }
-    while (base->tp_dealloc == &subtype_dealloc)
+    while (base->tp_dealloc == &_PyPy_subtype_dealloc)
     {
         base = base->tp_base;
         assert(base);
@@ -27,9 +28,3 @@
        hopefully this does not clash with the memory model assumed in
        extension modules */
 }
-
-PyAPI_FUNC(void *)
-_PyPy_get_subtype_dealloc(void)
-{
-    return &subtype_dealloc;
-}
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -735,8 +735,7 @@
         if not pto.c_tp_dealloc:
             # strange, but happens (ABCMeta)
             state = space.fromcache(State)
-            d = cts.cast('destructor', state.C._PyPy_get_subtype_dealloc())
-            pto.c_tp_dealloc = d
+            pto.c_tp_dealloc = state.C._PyPy_subtype_dealloc
 
     if builder.cpyext_type_init is not None:
         builder.cpyext_type_init.append((pto, w_type))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to