Skip to content

Commit 3639678

Browse files
use portable-atomic for AtomicU64 where needed
AtomicU64 isn't available in libstd on all targets. portable-atomic fills the gap, and can be nicely cfg-guarded to only be used on such targets. without this patch, gix-status (and thus a lot of other gix crates, and cargo) cannot be built on Debian armel. technically, AtomicUsize is also not guaranteed to exist for all targets, and a similar patch could be written to support those as well if desired. Signed-off-by: Fabian Grünbichler <git@fabian.gruenbichler.email>
1 parent 7dd58b8 commit 3639678

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

gix-status/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ gix-diff = { version = "^0.44.0", path = "../gix-diff", default-features = false
3434
thiserror = "1.0.26"
3535
filetime = "0.2.15"
3636
bstr = { version = "1.3.0", default-features = false }
37+
portable-atomic = "1"
3738

3839
document-features = { version = "0.2.0", optional = true }
3940

gix-status/src/index_as_worktree/function.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ use std::{
22
io,
33
path::Path,
44
slice::Chunks,
5-
sync::atomic::{AtomicU64, AtomicUsize, Ordering},
5+
sync::atomic::{AtomicUsize, Ordering},
66
};
77

8+
#[cfg(target_has_atomic = "64")]
9+
use std::sync::atomic::AtomicU64;
10+
11+
#[cfg(not(target_has_atomic = "64"))]
12+
use portable_atomic::AtomicU64;
13+
814
use bstr::BStr;
915
use filetime::FileTime;
1016
use gix_features::parallel::{in_parallel_if, Reduce};

gix-status/src/index_as_worktree/traits.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ pub trait ReadData<'a> {
5252
///
5353
#[allow(clippy::empty_docs)]
5454
pub mod read_data {
55-
use std::sync::atomic::{AtomicU64, Ordering};
55+
#[cfg(target_has_atomic = "64")]
56+
use std::sync::atomic::AtomicU64;
57+
use std::sync::atomic::Ordering;
58+
59+
#[cfg(not(target_has_atomic = "64"))]
60+
use portable_atomic::AtomicU64;
5661

5762
use gix_filter::pipeline::convert::ToGitOutcome;
5863

0 commit comments

Comments
 (0)