Skip to content

Commit

Permalink
Do not implement clock on wasm32, just return 0
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Oct 10, 2023
1 parent e1c631c commit 1055357
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
3 changes: 0 additions & 3 deletions zstd-safe/zstd-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 0 additions & 5 deletions zstd-safe/zstd-sys/src/wasm_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ use core::ffi::{c_int, c_void};
const USIZE_ALIGN: usize = core::mem::align_of::<usize>();
const USIZE_SIZE: usize = core::mem::size_of::<usize>();

#[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,
Expand Down
6 changes: 3 additions & 3 deletions zstd-safe/zstd-sys/wasm-shim/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1055357

Please sign in to comment.