summaryrefslogtreecommitdiff
path: root/runtime/ops/os/sys_info.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops/os/sys_info.rs')
-rw-r--r--runtime/ops/os/sys_info.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/ops/os/sys_info.rs b/runtime/ops/os/sys_info.rs
index ecb40b9a0..91422546c 100644
--- a/runtime/ops/os/sys_info.rs
+++ b/runtime/ops/os/sys_info.rs
@@ -302,6 +302,8 @@ pub fn mem_info() -> Option<MemInfo> {
}
pub fn os_uptime() -> u64 {
+ let mut uptime: u64 = 0;
+
#[cfg(target_os = "linux")]
{
let mut info = std::mem::MaybeUninit::uninit();
@@ -310,7 +312,7 @@ pub fn os_uptime() -> u64 {
if res == 0 {
// SAFETY: `sysinfo` initializes the struct.
let info = unsafe { info.assume_init() };
- return info.uptime as u64;
+ uptime = info.uptime as u64;
}
}
@@ -340,7 +342,7 @@ pub fn os_uptime() -> u64 {
)
};
if res == 0 {
- return SystemTime::now()
+ uptime = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map(|d| {
(d - Duration::new(
@@ -357,8 +359,8 @@ pub fn os_uptime() -> u64 {
unsafe {
// Windows is the only one that returns `uptime` in milisecond precision,
// so we need to get the seconds out of it to be in sync with other envs.
- return unsafe { winapi::um::sysinfoapi::GetTickCount64() as u64 / 1000 };
+ uptime = winapi::um::sysinfoapi::GetTickCount64() as u64 / 1000;
}
- 0
+ uptime
}