Skip to content

Commit

Permalink
Merge #2811
Browse files Browse the repository at this point in the history
2811: adjust vectorcall symbols for pypy r=davidhewitt a=davidhewitt

Closes #2738

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
  • Loading branch information
bors[bot] and davidhewitt authored Dec 17, 2022
2 parents 239f8e6 + 4a6b24e commit 203ac5d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/2811.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add FFI definitions `PyVectorcall_NARGS` and `PY_VECTORCALL_ARGUMENTS_OFFSET` for PyPy 3.8 and up.
1 change: 1 addition & 0 deletions newsfragments/2811.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unresolved symbol for `PyObject_Vectorcall` on PyPy 3.9 and up.
11 changes: 7 additions & 4 deletions pyo3-ffi/src/cpython/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use std::os::raw::{c_char, c_int};
#[cfg(not(Py_3_11))]
use crate::Py_buffer;

#[cfg(Py_3_8)]
use crate::pyport::PY_SSIZE_T_MAX;
#[cfg(all(Py_3_8, not(PyPy)))]
use crate::{
pyport::PY_SSIZE_T_MAX, vectorcallfunc, PyCallable_Check, PyThreadState, PyThreadState_GET,
PyTuple_Check, PyType_HasFeature, Py_TPFLAGS_HAVE_VECTORCALL,
vectorcallfunc, PyCallable_Check, PyThreadState, PyThreadState_GET, PyTuple_Check,
PyType_HasFeature, Py_TPFLAGS_HAVE_VECTORCALL,
};
#[cfg(Py_3_8)]
use libc::size_t;
Expand Down Expand Up @@ -39,11 +41,11 @@ extern "C" {
) -> *mut PyObject;
}

#[cfg(all(Py_3_8, not(PyPy)))]
#[cfg(all(Py_3_8))]
const PY_VECTORCALL_ARGUMENTS_OFFSET: Py_ssize_t =
1 << (8 * std::mem::size_of::<Py_ssize_t>() as Py_ssize_t - 1);

#[cfg(all(Py_3_8, not(PyPy)))]
#[cfg(all(Py_3_8))]
#[inline(always)]
pub unsafe fn PyVectorcall_NARGS(n: size_t) -> Py_ssize_t {
assert!(n <= (PY_SSIZE_T_MAX as size_t));
Expand Down Expand Up @@ -103,6 +105,7 @@ pub unsafe fn PyObject_Vectorcall(
extern "C" {
#[cfg(all(PyPy, Py_3_8))]
#[cfg_attr(not(Py_3_9), link_name = "_PyPyObject_Vectorcall")]
#[cfg_attr(Py_3_9, link_name = "PyPyObject_Vectorcall")]
pub fn PyObject_Vectorcall(
callable: *mut PyObject,
args: *const *mut PyObject,
Expand Down

0 comments on commit 203ac5d

Please sign in to comment.