Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(portability): Support 32 bit RISC-V #202

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/metrics/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::encoding::{EncodeMetric, MetricEncoder};

use super::{MetricType, TypedMetric};
use std::marker::PhantomData;
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -40,15 +40,15 @@ use std::sync::Arc;
/// counter.inc();
/// let _value: f64 = counter.get();
/// ```
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
#[derive(Debug)]
pub struct Counter<N = u64, A = AtomicU64> {
value: Arc<A>,
phantom: PhantomData<N>,
}

/// Open Metrics [`Counter`] to measure discrete events.
#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32"))]
#[derive(Debug)]
pub struct Counter<N = u32, A = AtomicU32> {
value: Arc<A>,
Expand Down Expand Up @@ -114,7 +114,7 @@ pub trait Atomic<N> {
fn get(&self) -> N;
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
impl Atomic<u64> for AtomicU64 {
fn inc(&self) -> u64 {
self.inc_by(1)
Expand Down Expand Up @@ -143,7 +143,7 @@ impl Atomic<u32> for AtomicU32 {
}
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
impl Atomic<f64> for AtomicU64 {
fn inc(&self) -> f64 {
self.inc_by(1.0)
Expand Down Expand Up @@ -231,7 +231,7 @@ mod tests {
assert_eq!(1, counter.get());
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
#[test]
fn f64_stored_in_atomic_u64() {
fn prop(fs: Vec<f64>) {
Expand Down
8 changes: 4 additions & 4 deletions src/metrics/exemplar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use super::histogram::Histogram;
use super::{MetricType, TypedMetric};
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard};
use std::collections::HashMap;
#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32"))]
use std::sync::atomic::AtomicU32;
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
use std::sync::atomic::AtomicU64;
use std::sync::Arc;

Expand Down Expand Up @@ -65,7 +65,7 @@ pub struct Exemplar<S, V> {
/// }),
/// );
/// ```
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
#[derive(Debug)]
pub struct CounterWithExemplar<S, N = u64, A = AtomicU64> {
pub(crate) inner: Arc<RwLock<CounterWithExemplarInner<S, N, A>>>,
Expand All @@ -77,7 +77,7 @@ impl<S> TypedMetric for CounterWithExemplar<S> {

/// Open Metrics [`Counter`] with an [`Exemplar`] to both measure discrete
/// events and track references to data outside of the metric set.
#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32"))]
#[derive(Debug)]
pub struct CounterWithExemplar<S, N = u32, A = AtomicU32> {
pub(crate) inner: Arc<RwLock<CounterWithExemplarInner<S, N, A>>>,
Expand Down
10 changes: 5 additions & 5 deletions src/metrics/gauge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::encoding::{EncodeGaugeValue, EncodeMetric, MetricEncoder};
use super::{MetricType, TypedMetric};
use std::marker::PhantomData;
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
use std::sync::atomic::{AtomicI64, AtomicU64};
use std::sync::Arc;

Expand Down Expand Up @@ -40,15 +40,15 @@ use std::sync::Arc;
/// gauge.set(42.0);
/// let _value: f64 = gauge.get();
/// ```
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
#[derive(Debug)]
pub struct Gauge<N = i64, A = AtomicI64> {
value: Arc<A>,
phantom: PhantomData<N>,
}

/// Open Metrics [`Gauge`] to record current measurements.
#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32"))]
#[derive(Debug)]
pub struct Gauge<N = i32, A = AtomicI32> {
value: Arc<A>,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Atomic<u32> for AtomicU32 {
}
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
impl Atomic<i64> for AtomicI64 {
fn inc(&self) -> i64 {
self.inc_by(1)
Expand All @@ -213,7 +213,7 @@ impl Atomic<i64> for AtomicI64 {
}
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32")))]
impl Atomic<f64> for AtomicU64 {
fn inc(&self) -> f64 {
self.inc_by(1.0)
Expand Down