Skip to content

Commit

Permalink
support for 32bit environenments like xtensa, mips ..
Browse files Browse the repository at this point in the history
Signed-off-by: Georg Buschbeck <[email protected]>
  • Loading branch information
Georg Buschbeck committed Dec 14, 2024
1 parent 45c43c9 commit 12958bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ memchr = "^2.3"
reqwest = { version = "^0.12", features = ["blocking"], optional = true }
thiserror = "^1.0"

[target.'cfg(any(target_arch = "powerpc", target_arch = "mips", target_arch = "xtensa"))'.dependencies]
portable-atomic = "1.10.0"

[target.'cfg(target_os = "linux")'.dependencies]
procfs = { version = "^0.16", optional = true, default-features = false }

Expand Down
5 changes: 5 additions & 0 deletions src/atomic64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
use std::cmp::*;
use std::f64;
use std::ops::*;
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa")))]
use std::sync::atomic::{AtomicI64 as StdAtomicI64, AtomicU64 as StdAtomicU64, Ordering};

#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa"))]
use portable_atomic::{AtomicI64 as StdAtomicI64, AtomicU64 as StdAtomicU64, Ordering};


/// An interface for numbers. Used to generically model float metrics and integer metrics, i.e.
/// [`Counter`](crate::Counter) and [`IntCounter`](crate::Counter).
pub trait Number:
Expand Down
7 changes: 6 additions & 1 deletion src/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::convert::From;
use std::sync::{
atomic::{AtomicU64 as StdAtomicU64, Ordering},
Arc, Mutex,
};

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa")))]
use std::sync::atomic::{AtomicU64 as StdAtomicU64, Ordering};

use std::time::{Duration, Instant as StdInstant};
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa"))]
use portable_atomic::{AtomicU64 as StdAtomicU64, Ordering};

use crate::atomic64::{Atomic, AtomicF64, AtomicU64};
use crate::desc::{Desc, Describer};
Expand Down
6 changes: 5 additions & 1 deletion src/timer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa")))]
use std::sync::atomic::{AtomicBool,AtomicU64, Ordering};
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "xtensa"))]
use portable_atomic::{AtomicBool,AtomicU64, Ordering};

use std::thread;
use std::time::{Duration, Instant};

Expand Down

0 comments on commit 12958bb

Please sign in to comment.