From 105535756ec1aadb34115fbbf3f83e562c39c317 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 10 Oct 2023 16:03:57 -0400 Subject: [PATCH] Do not implement clock on wasm32, just return 0 --- zstd-safe/zstd-sys/src/lib.rs | 3 --- zstd-safe/zstd-sys/src/wasm_shim.rs | 5 ----- zstd-safe/zstd-sys/wasm-shim/time.h | 6 +++--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/zstd-safe/zstd-sys/src/lib.rs b/zstd-safe/zstd-sys/src/lib.rs index 69a8dc1d..70b114e2 100644 --- a/zstd-safe/zstd-sys/src/lib.rs +++ b/zstd-safe/zstd-sys/src/lib.rs @@ -9,9 +9,6 @@ #[cfg(target_arch = "wasm32")] extern crate alloc; -#[cfg(target_arch = "wasm32")] -extern crate std; - #[cfg(target_arch = "wasm32")] mod wasm_shim; diff --git a/zstd-safe/zstd-sys/src/wasm_shim.rs b/zstd-safe/zstd-sys/src/wasm_shim.rs index 32763707..8469e5a7 100644 --- a/zstd-safe/zstd-sys/src/wasm_shim.rs +++ b/zstd-safe/zstd-sys/src/wasm_shim.rs @@ -4,11 +4,6 @@ use core::ffi::{c_int, c_void}; const USIZE_ALIGN: usize = core::mem::align_of::(); const USIZE_SIZE: usize = core::mem::size_of::(); -#[no_mangle] -pub extern "C" fn rust_zstd_wasm_shim_clock() -> u64 { - std::time::UNIX_EPOCH.elapsed().unwrap().as_millis() as u64 -} - #[no_mangle] pub extern "C" fn rust_zstd_wasm_shim_qsort( base: *mut c_void, diff --git a/zstd-safe/zstd-sys/wasm-shim/time.h b/zstd-safe/zstd-sys/wasm-shim/time.h index 79258f61..570c09ea 100644 --- a/zstd-safe/zstd-sys/wasm-shim/time.h +++ b/zstd-safe/zstd-sys/wasm-shim/time.h @@ -2,12 +2,12 @@ #define _TIME_H #define CLOCKS_PER_SEC 1000 -typedef unsigned long long clock_t; -clock_t rust_zstd_wasm_shim_clock(); +typedef unsigned long long clock_t; +// Clock is just use for progress reporting, which we disable anyway. inline clock_t clock() { - return rust_zstd_wasm_shim_clock(); + return 0; } #endif // _TIME_H