(vm: &VirtualMachine)
| 818 | |
| 819 | #[cfg(all(target_arch = "wasm32", target_os = "emscripten"))] |
| 820 | fn get_process_time(vm: &VirtualMachine) -> PyResult<Duration> { |
| 821 | let t: libc::tms = unsafe { |
| 822 | let mut t = core::mem::MaybeUninit::uninit(); |
| 823 | if libc::times(t.as_mut_ptr()) == -1 { |
| 824 | return Err(vm.new_os_error("Failed to get clock time".to_owned())); |
| 825 | } |
| 826 | t.assume_init() |
| 827 | }; |
| 828 | let freq = unsafe { libc::sysconf(libc::_SC_CLK_TCK) }; |
| 829 | |
| 830 | Ok(Duration::from_nanos( |
| 831 | time_muldiv(t.tms_utime, SEC_TO_NS, freq) + time_muldiv(t.tms_stime, SEC_TO_NS, freq), |
| 832 | )) |
| 833 | } |
| 834 | |
| 835 | #[cfg(not(any( |
| 836 | windows, |
no test coverage detected