From 7485f3414841a315702e912cddafd979b282fd94 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Mon, 5 Aug 2024 04:27:10 -0400 Subject: [PATCH] make target mips-unknown-linux-gnu happy --- .cargo/config.toml | 3 +++ src/traffic_status.rs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index f79cba3..6c13c99 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -7,3 +7,6 @@ protocol = "sparse" # target = "aarch64-apple-ios" # target = "x86_64-pc-windows-msvc" # target = "x86_64-apple-darwin" + +[target.'cfg(target_arch = "mips")'] +linker = "mips-linux-gnu-gcc" diff --git a/src/traffic_status.rs b/src/traffic_status.rs index 61858db..21453ba 100644 --- a/src/traffic_status.rs +++ b/src/traffic_status.rs @@ -19,7 +19,7 @@ pub unsafe extern "C" fn overtls_set_traffic_status_callback( log::error!("set traffic status callback failed"); } if send_interval_secs > 0 { - SEND_INTERVAL_SECS.store(send_interval_secs as u64, std::sync::atomic::Ordering::Relaxed); + SEND_INTERVAL_SECS.store(send_interval_secs, std::sync::atomic::Ordering::Relaxed); } } @@ -45,7 +45,7 @@ unsafe impl Send for TrafficStatusCallback {} unsafe impl Sync for TrafficStatusCallback {} static TRAFFIC_STATUS_CALLBACK: Mutex> = Mutex::new(None); -static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); +static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(1); static TRAFFIC_STATUS: LazyLock> = LazyLock::new(|| Mutex::new(TrafficStatus::default())); static TIME_STAMP: LazyLock> = LazyLock::new(|| Mutex::new(std::time::Instant::now())); @@ -68,7 +68,7 @@ pub(crate) fn traffic_status_update(delta_tx: usize, delta_rx: usize) -> Result< }; let old_time = { *TIME_STAMP.lock().map_err(|e| Error::from(e.to_string()))? }; let interval_secs = SEND_INTERVAL_SECS.load(std::sync::atomic::Ordering::Relaxed); - if std::time::Instant::now().duration_since(old_time).as_secs() >= interval_secs { + if std::time::Instant::now().duration_since(old_time).as_secs() >= interval_secs as u64 { send_traffic_stat(&traffic_status)?; { let mut time_stamp = TIME_STAMP.lock().map_err(|e| Error::from(e.to_string()))?;