From 4f261c281e61a281c4003415ba489e193386e86a Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 14 Aug 2024 14:51:37 -0600 Subject: [PATCH] make the _bits field of PyMutex pub(crate) --- pyo3-ffi/src/cpython/lock.rs | 2 +- pyo3-ffi/src/object.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pyo3-ffi/src/cpython/lock.rs b/pyo3-ffi/src/cpython/lock.rs index 56059919400..58ffdb34223 100644 --- a/pyo3-ffi/src/cpython/lock.rs +++ b/pyo3-ffi/src/cpython/lock.rs @@ -3,7 +3,7 @@ use std::sync::atomic::AtomicU8; #[repr(C)] pub struct PyMutex { - _bits: AtomicU8, + pub(crate) _bits: AtomicU8, } impl fmt::Debug for PyMutex { diff --git a/pyo3-ffi/src/object.rs b/pyo3-ffi/src/object.rs index 9baebb8a51f..7d3c04783dc 100644 --- a/pyo3-ffi/src/object.rs +++ b/pyo3-ffi/src/object.rs @@ -5,7 +5,7 @@ use std::mem; use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void}; use std::ptr; #[cfg(Py_GIL_DISABLED)] -use std::sync::atomic::{AtomicIsize, AtomicU32, Ordering::Relaxed}; +use std::sync::atomic::{AtomicIsize, AtomicU32, AtomicU8, Ordering::Relaxed}; #[cfg(Py_LIMITED_API)] opaque_struct!(PyTypeObject); @@ -42,7 +42,9 @@ pub const fn PyObject_HEAD_INIT() -> PyObject { #[cfg(Py_GIL_DISABLED)] _padding: 0, #[cfg(Py_GIL_DISABLED)] - ob_mutex: unsafe { mem::zeroed::() }, + ob_mutex: PyMutex { + _bits: AtomicU8::new(0), + }, #[cfg(Py_GIL_DISABLED)] ob_gc_bits: 0, #[cfg(Py_GIL_DISABLED)]