|
@@ -9,11 +9,20 @@ when ODIN_OS == .Darwin {
|
|
|
|
|
|
import "core:c"
|
|
|
|
|
|
-@(default_calling_convention="c")
|
|
|
-foreign libc {
|
|
|
- clock_gettime :: proc(clock_id: u64, timespec: ^timespec) -> c.int ---
|
|
|
- sleep :: proc(seconds: c.uint) -> c.int ---
|
|
|
- nanosleep :: proc(requested, remaining: ^timespec) -> c.int ---
|
|
|
+when ODIN_OS == .NetBSD {
|
|
|
+ @(default_calling_convention="c")
|
|
|
+ foreign libc {
|
|
|
+ @(link_name="__clock_gettime50") clock_gettime :: proc(clock_id: u64, timespec: ^timespec) -> c.int ---
|
|
|
+ @(link_name="__nanosleep50") nanosleep :: proc(requested, remaining: ^timespec) -> c.int ---
|
|
|
+ @(link_name="sleep") sleep :: proc(seconds: c.uint) -> c.int ---
|
|
|
+ }
|
|
|
+} else {
|
|
|
+ @(default_calling_convention="c")
|
|
|
+ foreign libc {
|
|
|
+ clock_gettime :: proc(clock_id: u64, timespec: ^timespec) -> c.int ---
|
|
|
+ sleep :: proc(seconds: c.uint) -> c.int ---
|
|
|
+ nanosleep :: proc(requested, remaining: ^timespec) -> c.int ---
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
timespec :: struct {
|
|
@@ -65,8 +74,6 @@ seconds_since_boot :: proc "c" () -> f64 {
|
|
|
return f64(ts_boottime.tv_sec) + f64(ts_boottime.tv_nsec) / 1e9
|
|
|
}
|
|
|
|
|
|
-// TODO(phix): 'nanosleep' here might refere to the wrong version on NetBSD. Need to investigate this further.
|
|
|
-// Normally this is solved by just including 'time.h'. So I need to understand the macro-magic going on in there.
|
|
|
inline_nanosleep :: proc "c" (nanoseconds: i64) -> (remaining: timespec, res: i32) {
|
|
|
s, ns := nanoseconds / 1e9, nanoseconds % 1e9
|
|
|
requested := timespec{tv_sec=s, tv_nsec=ns}
|