new file mode 100644
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ */
+
+#ifndef TST_SCHED_H_
+#define TST_SCHED_H_
+
+#include <sched.h>
+
+int tst_sched_setparam(pid_t pid, const struct sched_param *param);
+int tst_sched_getparam(pid_t pid, struct sched_param *param);
+int tst_sched_setscheduler(pid_t pid, int policy, const struct sched_param *param);
+int tst_sched_getscheduler(pid_t pid);
+
+#endif /* TST_SCHED_H_ */
new file mode 100644
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include "tst_sched.h"
+#include "lapi/syscalls.h"
+
+#define TST_SCHED_COMMON(SCALL, ...) do { \
+ int ret = SCALL(__VA_ARGS__); \
+ if (ret == -1 && errno == ENOSYS) \
+ return syscall(__NR_##SCALL, __VA_ARGS__); \
+ return ret; \
+} while (0)
+
+int tst_sched_setparam(pid_t pid, const struct sched_param *param)
+{
+ TST_SCHED_COMMON(sched_setparam, pid, param);
+}
+
+int tst_sched_getparam(pid_t pid, struct sched_param *param)
+{
+ TST_SCHED_COMMON(sched_getparam, pid, param);
+}
+
+int tst_sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)
+{
+ TST_SCHED_COMMON(sched_setscheduler, pid, policy, param);
+}
+
+int tst_sched_getscheduler(pid_t pid)
+{
+ TST_SCHED_COMMON(sched_getscheduler, pid);
+}
The new tst_sched_*() invoke libc variant first, and if ENOSYS errno has been returned, tries to invoke syscall directly. musl implementation returns ENOSYS for some sched_*() functions due to commit 1e21e78bf7a5 ("add support for thread scheduling (POSIX TPS option)"). Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com> --- include/tst_sched.h | 16 ++++++++++++++++ lib/tst_sched.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 include/tst_sched.h create mode 100644 lib/tst_sched.c