Fixed link warnings

Hardlink libc functions to the correct version on NetBSD 10 since we do not use the micro-magic from C.
This commit is contained in:
Andreas T Jonsson
2024-04-17 09:46:57 +02:00
parent 80067a959b
commit 2055f2b933
3 changed files with 22 additions and 16 deletions
+14 -7
View File
@@ -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}