Add intrinsics.syscall_bsd

This is a BSD-style syscall that checks for a high Carry Flag as the
error state. If the CF is high, the boolean return value is false, and
if it is low (no errors) then the boolean return value is true.
This commit is contained in:
Feoramund
2024-06-12 13:07:13 -04:00
parent 35a845b93f
commit 5b5402fb23
5 changed files with 195 additions and 54 deletions
+4 -3
View File
@@ -5,14 +5,15 @@ import "base:intrinsics"
sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) {
mib := mib
result_size := i64(size_of(T))
result_size := u64(size_of(T))
res := intrinsics.syscall(SYS_sysctl,
res: uintptr
res, ok = intrinsics.syscall_bsd(SYS_sysctl,
uintptr(raw_data(mib)), uintptr(len(mib)),
uintptr(val), uintptr(&result_size),
uintptr(0), uintptr(0),
)
return res == 0
return
}
// See /usr/include/sys/sysctl.h for details