pyforge_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(Py_3_14))]
32#[repr(C)]
33#[derive(Clone, Copy)]
34pub(crate) struct _PyErr_StackItem {
35 exc_value: *mut PyObject,
36 previous_item: *mut _PyErr_StackItem,
37}
38
39extern_libpython! {
45 #[cfg(Py_3_13)]
46 pub fn PyThreadState_GetUnchecked() -> *mut PyThreadState;
47
48 #[cfg(not(Py_3_13))]
49 pub(crate) fn _PyThreadState_UncheckedGet() -> *mut PyThreadState;
50
51 pub fn PyThreadState_EnterTracing(state: *mut PyThreadState);
52 pub fn PyThreadState_LeaveTracing(state: *mut PyThreadState);
53
54 pub fn PyGILState_Check() -> c_int;
55
56 pub fn PyInterpreterState_Main() -> *mut PyInterpreterState;
62 pub fn PyInterpreterState_Head() -> *mut PyInterpreterState;
63 pub fn PyInterpreterState_Next(interp: *mut PyInterpreterState) -> *mut PyInterpreterState;
64 pub fn PyInterpreterState_ThreadHead(interp: *mut PyInterpreterState) -> *mut PyThreadState;
65 pub fn PyThreadState_Next(tstate: *mut PyThreadState) -> *mut PyThreadState;
66
67 pub fn PyThreadState_DeleteCurrent();
68}
69
70