Skip to content

Commit 078f421

Browse files
committed
JitterRng: fix warning with WASM
1 parent e5b3f3b commit 078f421

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/jitter.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,22 +446,25 @@ impl JitterRng {
446446
self.stir_pool();
447447
self.data
448448
}
449+
450+
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
451+
pub fn test_timer(&mut self) -> Result<u8, TimerError> {
452+
return Err(TimerError::NoTimer);
453+
}
449454

450455
/// Basic quality tests on the timer, by measuring CPU timing jitter a few
451456
/// hundred times.
452457
///
453458
/// If succesful, this will return the estimated number of rounds necessary
454459
/// to collect 64 bits of entropy. Otherwise a `TimerError` with the cause
455460
/// of the failure will be returned.
461+
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
456462
pub fn test_timer(&mut self) -> Result<u8, TimerError> {
457463
debug!("JitterRng: testing timer ...");
458464
// We could add a check for system capabilities such as `clock_getres`
459465
// or check for `CONFIG_X86_TSC`, but it does not make much sense as the
460466
// following sanity checks verify that we have a high-resolution timer.
461467

462-
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
463-
return Err(TimerError::NoTimer);
464-
465468
let mut delta_sum = 0;
466469
let mut old_delta = 0;
467470

0 commit comments

Comments
 (0)