Skip to content

Commit 4f261c2

Browse files
committed
make the _bits field of PyMutex pub(crate)
1 parent 848c793 commit 4f261c2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pyo3-ffi/src/cpython/lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::atomic::AtomicU8;
33

44
#[repr(C)]
55
pub struct PyMutex {
6-
_bits: AtomicU8,
6+
pub(crate) _bits: AtomicU8,
77
}
88

99
impl fmt::Debug for PyMutex {

pyo3-ffi/src/object.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::mem;
55
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
66
use std::ptr;
77
#[cfg(Py_GIL_DISABLED)]
8-
use std::sync::atomic::{AtomicIsize, AtomicU32, Ordering::Relaxed};
8+
use std::sync::atomic::{AtomicIsize, AtomicU32, AtomicU8, Ordering::Relaxed};
99

1010
#[cfg(Py_LIMITED_API)]
1111
opaque_struct!(PyTypeObject);
@@ -42,7 +42,9 @@ pub const fn PyObject_HEAD_INIT() -> PyObject {
4242
#[cfg(Py_GIL_DISABLED)]
4343
_padding: 0,
4444
#[cfg(Py_GIL_DISABLED)]
45-
ob_mutex: unsafe { mem::zeroed::<PyMutex>() },
45+
ob_mutex: PyMutex {
46+
_bits: AtomicU8::new(0),
47+
},
4648
#[cfg(Py_GIL_DISABLED)]
4749
ob_gc_bits: 0,
4850
#[cfg(Py_GIL_DISABLED)]

0 commit comments

Comments
 (0)