-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add bindings for critical section API (#4477)
* add bindings for critical section API * fix build on python < 3.13 * add release note * fix clippy on gil-enabled 3.13 build
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Added bindings for the Python critical section API available on Python 3.13 and newer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#[cfg(Py_GIL_DISABLED)] | ||
use crate::PyMutex; | ||
use crate::PyObject; | ||
|
||
#[repr(C)] | ||
#[cfg(Py_GIL_DISABLED)] | ||
pub struct PyCriticalSection { | ||
_cs_prev: usize, | ||
_cs_mutex: *mut PyMutex, | ||
} | ||
|
||
#[repr(C)] | ||
#[cfg(Py_GIL_DISABLED)] | ||
pub struct PyCriticalSection2 { | ||
_cs_base: PyCriticalSection, | ||
_cs_mutex2: *mut PyMutex, | ||
} | ||
|
||
#[cfg(not(Py_GIL_DISABLED))] | ||
opaque_struct!(PyCriticalSection); | ||
|
||
#[cfg(not(Py_GIL_DISABLED))] | ||
opaque_struct!(PyCriticalSection2); | ||
|
||
extern "C" { | ||
pub fn PyCriticalSection_Begin(c: *mut PyCriticalSection, op: *mut PyObject); | ||
pub fn PyCriticalSection_End(c: *mut PyCriticalSection); | ||
pub fn PyCriticalSection2_Begin(c: *mut PyCriticalSection2, a: *mut PyObject, b: *mut PyObject); | ||
pub fn PyCriticalSection2_End(c: *mut PyCriticalSection2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters