Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/musl: Make scheduler functions Linux-compatible
@ 2019-05-13 20:00 stefan.nickl at gmail.com
  2019-05-13 20:13 ` Thomas Petazzoni
  2019-10-27 17:14 ` Arnout Vandecappelle
  0 siblings, 2 replies; 13+ messages in thread
From: stefan.nickl at gmail.com @ 2019-05-13 20:00 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Stefan Nickl <Stefan.Nickl@gmail.com>
---
 package/musl/0002-sched-linux-compat.patch | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 package/musl/0002-sched-linux-compat.patch

diff --git a/package/musl/0002-sched-linux-compat.patch
b/package/musl/0002-sched-linux-compat.patch
new file mode 100644
index 0000000000..c1626ea7c3
--- /dev/null
+++ b/package/musl/0002-sched-linux-compat.patch
@@ -0,0 +1,74 @@
+The POSIX functions sched_getscheduler(), sched_setscheduler(),
+sched_getparam(), sched_setparam() are technically not correctly
+implemented by the Linux syscalls of the same name, because what the
+kernel calls a PID and what POSIX calls a PID isn't truly the same,
+resulting in somewhat different semantics as to what these functions
+exactly apply to.
+
+Since the musl developers put a high premium on POSIX compliance, they
+deliberately implement these functions to return -ENOSYS instead of
+relaying them to the respective Linux syscalls as glibc/uClibc do.
+
+This means that virtually all programs written for Linux using these
+functions are currently broken. For example running 'chrt -p 1' fails
+with "Function not implemented" on a musl-libc based system.
+
+While the musl developers are right strictly speaking, it seems
+unfeasible to fix all affected programs in a way that hardly any Linux
+developer will consider to be broken in the first place. So this patch
+simply changes musl to fall in line with the other libcs.
+
+Signed-off-by: Stefan Nickl <Stefan.Nickl@gmail.com>
+---
+diff -ru a/src/sched/sched_getparam.c b/src/sched/sched_getparam.c
+--- a/src/sched/sched_getparam.c	2019-04-10 02:39:21.000000000
+0200
++++ b/src/sched/sched_getparam.c	2019-05-07 08:51:00.980363141
+0200
+@@ -1,8 +1,7 @@
+ #include <sched.h>
+-#include <errno.h>
+ #include "syscall.h"
+ 
+ int sched_getparam(pid_t pid, struct sched_param *param)
+ {
+-	return __syscall_ret(-ENOSYS);
++	return syscall(SYS_sched_getparam, pid, param);
+ }
+diff -ru a/src/sched/sched_getscheduler.c
b/src/sched/sched_getscheduler.c
+--- a/src/sched/sched_getscheduler.c	2019-04-10 02:39:21.000000000
+0200
++++ b/src/sched/sched_getscheduler.c	2019-05-07 08:50:48.246021455
+0200
+@@ -1,8 +1,7 @@
+ #include <sched.h>
+-#include <errno.h>
+ #include "syscall.h"
+ 
+ int sched_getscheduler(pid_t pid)
+ {
+-	return __syscall_ret(-ENOSYS);
++	return syscall(SYS_sched_getscheduler, pid);
+ }
+diff -ru a/src/sched/sched_setparam.c b/src/sched/sched_setparam.c
+--- a/src/sched/sched_setparam.c	2019-04-10 02:39:21.000000000
+0200
++++ b/src/sched/sched_setparam.c	2019-05-07 08:51:03.603227550
+0200
+@@ -1,8 +1,7 @@
+ #include <sched.h>
+-#include <errno.h>
+ #include "syscall.h"
+ 
+ int sched_setparam(pid_t pid, const struct sched_param *param)
+ {
+-	return __syscall_ret(-ENOSYS);
++	return syscall(SYS_sched_setparam, pid, param);
+ }
+diff -ru a/src/sched/sched_setscheduler.c
b/src/sched/sched_setscheduler.c
+--- a/src/sched/sched_setscheduler.c	2019-04-10 02:39:21.000000000
+0200
++++ b/src/sched/sched_setscheduler.c	2019-05-07 08:50:53.379756063
+0200
+@@ -1,8 +1,7 @@
+ #include <sched.h>
+-#include <errno.h>
+ #include "syscall.h"
+ 
+ int sched_setscheduler(pid_t pid, int sched, const struct sched_param
*param)
+ {
+-	return __syscall_ret(-ENOSYS);
++	return syscall(SYS_sched_setscheduler, pid, sched, param);
+ }

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-10-27 17:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-13 20:00 [Buildroot] [PATCH] package/musl: Make scheduler functions Linux-compatible stefan.nickl at gmail.com
2019-05-13 20:13 ` Thomas Petazzoni
2019-05-14 16:32   ` stefan.nickl at gmail.com
2019-05-14 16:33     ` Thomas Petazzoni
     [not found]       ` <a03605e62a3879a0fffcbd14be04907cc3e54d3c.camel@gmail.com>
2019-05-14 16:55         ` Thomas Petazzoni
2019-05-14 17:31       ` stefan.nickl at gmail.com
2019-05-14 18:04         ` Arnout Vandecappelle
2019-05-14 18:54           ` stefan.nickl at gmail.com
2019-05-14 19:38             ` Arnout Vandecappelle
2019-05-14 20:03               ` stefan.nickl at gmail.com
2019-05-14 20:24                 ` Yann E. MORIN
2019-05-14 20:40                   ` stefan.nickl at gmail.com
2019-10-27 17:14 ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox