MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / clockResGet

Method clockResGet

lib/host/wasi/clock-win.cpp:26–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24} // namespace
25
26WasiExpect<void> Clock::clockResGet(__wasi_clockid_t Id,
27 __wasi_timestamp_t &Resolution) noexcept {
28 switch (Id) {
29 case __WASI_CLOCKID_MONOTONIC: {
30 const std::chrono::nanoseconds Result =
31 std::chrono::nanoseconds(std::chrono::seconds{1}) / kFrequency;
32 Resolution = static_cast<__wasi_timestamp_t>(Result.count());
33 return {};
34 }
35 case __WASI_CLOCKID_REALTIME:
36 case __WASI_CLOCKID_PROCESS_CPUTIME_ID:
37 case __WASI_CLOCKID_THREAD_CPUTIME_ID: {
38 ULONG_ MinimumResolution;
39 ULONG_ MaximumResolution;
40 ULONG_ CurrentResolution;
41 if (auto Res = NtQueryTimerResolution(
42 &MinimumResolution, &MaximumResolution, &CurrentResolution);
43 unlikely(!NT_SUCCESS_(Res))) {
44 return WasiUnexpect(detail::fromLastError(RtlNtStatusToDosError(Res)));
45 }
46 const std::chrono::nanoseconds Result = FiletimeDuration{CurrentResolution};
47 Resolution = static_cast<__wasi_timestamp_t>(Result.count());
48 return {};
49 }
50 default:
51 return WasiUnexpect(__WASI_ERRNO_NOSYS);
52 }
53}
54
55WasiExpect<void> Clock::clockTimeGet(__wasi_clockid_t Id,
56 __wasi_timestamp_t Precision

Callers 1

bodyMethod · 0.45

Calls 6

unlikelyFunction · 0.85
NT_SUCCESS_Function · 0.85
WasiUnexpectFunction · 0.85
fromLastErrorFunction · 0.85
RtlNtStatusToDosErrorFunction · 0.85
countMethod · 0.80

Tested by

no test coverage detected