pyo3_ffi/cpython/
pystate.rs1use crate::PyThreadState;
2use crate::{PyFrameObject, PyInterpreterState, PyObject};
3use std::ffi::c_int;
4
5pub type Py_tracefunc = unsafe extern "C" fn(
9 obj: *mut PyObject,
10 frame: *mut PyFrameObject,
11 what: c_int,
12 arg: *mut PyObject,
13) -> c_int;
14
15pub const PyTrace_CALL: c_int = 0;
16pub const PyTrace_EXCEPTION: c_int = 1;
17pub const PyTrace_LINE: c_int = 2;
18pub const PyTrace_RETURN: c_int = 3;
19pub const PyTrace_C_CALL: c_int = 4;
20pub const PyTrace_C_EXCEPTION: c_int = 5;
21pub const PyTrace_C_RETURN: c_int = 6;
22pub const PyTrace_OPCODE: c_int = 7;
23
24#[cfg(not(any(PyPy, Py_3_14)))]
32#[repr(C)]
33#[derive(Clone, Copy)]
34pub(crate) struct _PyErr_StackItem {
35 #[cfg(not(Py_3_11))]
36 exc_type: *mut PyObject,
37 exc_value: *mut PyObject,
38 #[cfg(not(Py_3_11))]
39 exc_traceback: *mut PyObject,
40 previous_item: *mut _PyErr_StackItem,
41}
42
43extern "C" {
49 #[cfg(Py_3_13)]
50 pub fn PyThreadState_GetUnchecked() -> *mut PyThreadState;
51
52 #[cfg(not(Py_3_13))]
53 pub(crate) fn _PyThreadState_UncheckedGet() -> *mut PyThreadState;
54
55 #[cfg(Py_3_11)]
56 pub fn PyThreadState_EnterTracing(state: *mut PyThreadState);
57 #[cfg(Py_3_11)]
58 pub fn PyThreadState_LeaveTracing(state: *mut PyThreadState);
59
60 #[cfg_attr(PyPy, link_name = "PyPyGILState_Check")]
61 pub fn PyGILState_Check() -> c_int;
62
63 #[cfg(not(PyPy))]
69 pub fn PyInterpreterState_Main() -> *mut PyInterpreterState;
70 #[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Head")]
71 pub fn PyInterpreterState_Head() -> *mut PyInterpreterState;
72 #[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Next")]
73 pub fn PyInterpreterState_Next(interp: *mut PyInterpreterState) -> *mut PyInterpreterState;
74 #[cfg(not(PyPy))]
75 pub fn PyInterpreterState_ThreadHead(interp: *mut PyInterpreterState) -> *mut PyThreadState;
76 #[cfg(not(PyPy))]
77 pub fn PyThreadState_Next(tstate: *mut PyThreadState) -> *mut PyThreadState;
78
79 #[cfg_attr(PyPy, link_name = "PyPyThreadState_DeleteCurrent")]
80 pub fn PyThreadState_DeleteCurrent();
81}
82
83