From 454ad1f4b82abd781e44bf10e149d8f1ea468a79 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 9 Feb 2026 19:01:43 +0100 Subject: Unwrap cpu affinity syscalls. --- core/os/process_linux.odin | 2 +- core/sys/linux/sys.odin | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/os/process_linux.odin b/core/os/process_linux.odin index 0f387f01f..1d14c4b1f 100644 --- a/core/os/process_linux.odin +++ b/core/os/process_linux.odin @@ -60,7 +60,7 @@ _get_current_thread_id :: proc "contextless" () -> int { _get_processor_core_count :: proc() -> (core_count: int) { cpu_set: [128]u64 - if err := linux.sched_getaffinity(0, size_of(cpu_set), &cpu_set); err != nil { + if _, err := linux.sched_getaffinity(0, size_of(cpu_set), &cpu_set); err == nil { for set in cpu_set { core_count += int(intrinsics.count_ones(set)) } diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin index 392761e1d..6e9c8ab91 100644 --- a/core/sys/linux/sys.odin +++ b/core/sys/linux/sys.odin @@ -2616,9 +2616,9 @@ futex :: proc{ If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument. Otherwise use an array of integers. */ -sched_setaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno) { +sched_setaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (int, Errno) { ret := syscall(SYS_sched_setaffinity, pid, cpusetsize, mask) - return Errno(-ret) + return errno_unwrap(ret, int) } /* @@ -2628,9 +2628,9 @@ sched_setaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawpt If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument. Otherwise use an array of integers. */ -sched_getaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno) { +sched_getaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (int, Errno) { ret := syscall(SYS_sched_getaffinity, pid, cpusetsize, mask) - return Errno(-ret) + return errno_unwrap(ret, int) } // TODO(flysand): set_thread_area -- cgit v1.2.3