unix: add SchedSetAttr and SchedGetAttr for Linux

Add wrappers for sched_getattr(2) and sched_setattr(2), as well as
various SCHED_ values usable for these.

The kludge in linux/types.go is needed so we can include both
linux/sched/types.h (for struct sched_attr) and sched.h (for a few
defines from include/bits/cpu-set.h).

Unfortunately, they both define struct sched_param, thus the need to
mask one of the definitions.

Change-Id: I3e13cf49ccef7ae81a75d33826d18de84a52106d
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/sys/+/516756
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Kir Kolyshkin
2023-08-09 15:08:02 +00:00
committed by Gopher Robot
parent 60ecf13377
commit ee578879d8
6 changed files with 85 additions and 0 deletions
+9
View File
@@ -138,6 +138,11 @@ struct termios2 {
#include <linux/random.h>
#include <linux/rtc.h>
#include <linux/rtnetlink.h>
// This is to avoid a conflict of struct sched_param being defined by
// both the kernel and the glibc (sched.h) headers.
#define sched_param kernel_sched_param
#include <linux/sched/types.h>
#undef kernel_sched_param
#include <linux/shm.h>
#include <linux/socket.h>
#include <linux/stat.h>
@@ -5796,3 +5801,7 @@ const (
RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = C.RISCV_HWPROBE_MISALIGNED_UNSUPPORTED
RISCV_HWPROBE_MISALIGNED_MASK = C.RISCV_HWPROBE_MISALIGNED_MASK
)
type SchedAttr C.struct_sched_attr
const SizeofSchedAttr = C.sizeof_struct_sched_attr