Merge pull request #3524 from Feoramund/freebsd-amd64-syscall-errno

Add `intrinsics.syscall_bsd`
This commit is contained in:
gingerBill
2024-06-20 11:47:01 +01:00
committed by GitHub
7 changed files with 203 additions and 62 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ version_string_buf: [1024]u8
init_os_version :: proc () {
os_version.platform = .FreeBSD
kernel_version_buf: [129]u8
kernel_version_buf: [1024]u8
b := strings.builder_from_bytes(version_string_buf[:])
// Retrieve kernel info using `sysctl`, e.g. FreeBSD 13.1-RELEASE-p2 GENERIC
+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