|
4 | 4 |
|
5 | 5 | use super::{MetricType, TypedMetric}; |
6 | 6 | use std::marker::PhantomData; |
7 | | -use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; |
| 7 | +#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))] |
| 8 | +use std::sync::atomic::AtomicU64; |
| 9 | +use std::sync::atomic::{AtomicU32, Ordering}; |
8 | 10 | use std::sync::Arc; |
9 | 11 |
|
10 | 12 | /// Open Metrics [`Counter`] to measure discrete events. |
@@ -36,11 +38,18 @@ use std::sync::Arc; |
36 | 38 | /// counter.inc(); |
37 | 39 | /// let _value: f64 = counter.get(); |
38 | 40 | /// ``` |
| 41 | +#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))] |
39 | 42 | pub struct Counter<N = u64, A = AtomicU64> { |
40 | 43 | value: Arc<A>, |
41 | 44 | phantom: PhantomData<N>, |
42 | 45 | } |
43 | 46 |
|
| 47 | +#[cfg(any(target_arch = "mips", target_arch = "powerpc"))] |
| 48 | +pub struct Counter<N = u32, A = AtomicU32> { |
| 49 | + value: Arc<A>, |
| 50 | + phantom: PhantomData<N>, |
| 51 | +} |
| 52 | + |
44 | 53 | impl<N, A> Clone for Counter<N, A> { |
45 | 54 | fn clone(&self) -> Self { |
46 | 55 | Self { |
@@ -96,6 +105,7 @@ pub trait Atomic<N> { |
96 | 105 | fn get(&self) -> N; |
97 | 106 | } |
98 | 107 |
|
| 108 | +#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))] |
99 | 109 | impl Atomic<u64> for AtomicU64 { |
100 | 110 | fn inc(&self) -> u64 { |
101 | 111 | self.inc_by(1) |
@@ -124,6 +134,7 @@ impl Atomic<u32> for AtomicU32 { |
124 | 134 | } |
125 | 135 | } |
126 | 136 |
|
| 137 | +#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))] |
127 | 138 | impl Atomic<f64> for AtomicU64 { |
128 | 139 | fn inc(&self) -> f64 { |
129 | 140 | self.inc_by(1.0) |
@@ -165,6 +176,7 @@ mod tests { |
165 | 176 | assert_eq!(1, counter.get()); |
166 | 177 | } |
167 | 178 |
|
| 179 | + #[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))] |
168 | 180 | #[test] |
169 | 181 | fn f64_stored_in_atomic_u64() { |
170 | 182 | fn prop(fs: Vec<f64>) { |
|
0 commit comments