You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
odin-sysinfo/systeminfo_freebsd.odin

34 lines
578 B
Plaintext

package systeminfo
import "core:fmt"
import c "core:c/libc"
import "core:strings"
import "core:sys/unix"
get_hostname :: proc() -> (hostname: string, ok: bool) #optional_ok {
ok = true
hostname_array: [1024]u8
err := gethostname(&hostname_array, i32(1023))
if err != 0 {
ok = false
return
}
hostname = strings.clone(string(hostname_array[:]))
return
}
get_system_uptime_in_seconds :: proc() -> (int, bool) {
tp: unix.timespec
result := unix.clock_gettime(unix.CLOCK_MONOTONIC_RAW, &tp)
if result != 0 {
return 0, false
}
return int(tp.tv_sec), true
}