Skip to content

Commit

Permalink
Module specifies Py_MOD_GIL_USED
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Jun 10, 2024
1 parent d55b261 commit ac8d90e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,22 @@ pub unsafe extern "C" fn orjson_init_exec(mptr: *mut PyObject) -> c_int {
0
}

#[cfg(Py_3_13)]
#[allow(non_upper_case_globals)]
const Py_mod_gil: c_int = 4;
#[cfg(Py_3_13)]
#[allow(non_upper_case_globals, dead_code, fuzzy_provenance_casts)]
const Py_MOD_GIL_USED: *mut c_void = 0 as *mut c_void;
#[cfg(Py_3_13)]
#[allow(non_upper_case_globals, dead_code, fuzzy_provenance_casts)]
const Py_MOD_GIL_NOT_USED: *mut c_void = 1 as *mut c_void;

#[cfg(not(Py_3_12))]
const PYMODULEDEF_LEN: usize = 2;
#[cfg(Py_3_12)]
#[cfg(all(Py_3_12, not(Py_3_13)))]
const PYMODULEDEF_LEN: usize = 3;
#[cfg(Py_3_13)]
const PYMODULEDEF_LEN: usize = 4;

#[allow(non_snake_case)]
#[no_mangle]
Expand All @@ -172,6 +184,11 @@ pub unsafe extern "C" fn PyInit_orjson() -> *mut PyModuleDef {
slot: Py_mod_multiple_interpreters,
value: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED,
},
#[cfg(Py_3_13)]
PyModuleDef_Slot {
slot: Py_mod_gil,
value: Py_MOD_GIL_USED,
},
PyModuleDef_Slot {
slot: 0,
value: null_mut(),
Expand Down

0 comments on commit ac8d90e

Please sign in to comment.