Skip to content

Commit

Permalink
Use portable-atomic for targets which lack 64-bit atomics used to che…
Browse files Browse the repository at this point in the history
…ck interpreter ID.

I chose to make the dependency mandatory instead of optional as portable-atomic
itself just forwards to the native atomics when they are available so making
that choice part of our build system is not really necessary. Personally, I was
unable to perceive any noticeable compile-time hit from adding it.
  • Loading branch information
adamreichold authored and davidhewitt committed Feb 22, 2024
1 parent 4774ded commit 9d1b11f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cfg-if = "1.0"
libc = "0.2.62"
parking_lot = ">= 0.11, < 0.13"
memoffset = "0.9"
portable-atomic = "1.0"

# ffi bindings to the python interpreter, split into a separate crate so they can be used independently
pyo3-ffi = { path = "pyo3-ffi", version = "=0.20.2" }
Expand Down
1 change: 1 addition & 0 deletions newsfragments/3619.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use portable-atomic to support platforms without 64-bit atomics
2 changes: 1 addition & 1 deletion src/impl_/pymodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::cell::UnsafeCell;

#[cfg(all(not(PyPy), Py_3_9, not(all(windows, Py_LIMITED_API, not(Py_3_10)))))]
use std::sync::atomic::{AtomicI64, Ordering};
use portable_atomic::{AtomicI64, Ordering};

#[cfg(not(PyPy))]
use crate::exceptions::PyImportError;
Expand Down

0 comments on commit 9d1b11f

Please sign in to comment.