Skip to contentSkip to conversation

sched_attr: Do not define for glibc >= 2.41

PATCH In review Khem Raj 2 participants 2 messages Oct 30, 2024 – Oct 31, 2024

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 sched_attr: Do not define for glibc >= 2.41

glibc 2.41+ has added [1] definitions for sched_setattr and sched_getattr functions and struct sched_attr. Therefore, it needs to be checked for here as well before defining sched_attr

Define sched_attr conditionally on SCHED_ATTR_SIZE_VER0

Fixes builds with glibc/trunk

[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=21571ca0d70302909cf72707b2a7736cf12190a0;hp=298bc488fdc047da37482f4003023cb9adef78f8

---
 include/lapi/sched.h | 3 +++
 1 file changed, 3 insertions(+)
include/lapi/sched.h +3 -0
index 26fdb628d..e1c7ff011 100644
@@ -15,6 +15,8 @@
 #include "lapi/syscalls.h"
 #include "lapi/sched.h"
 
+/* sched_attr is not defined in glibc < 2.41 */
+#ifndef SCHED_ATTR_SIZE_VER0
 struct sched_attr {
 	uint32_t size;
 
@@ -44,6 +46,7 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
 {
 	return syscall(__NR_sched_getattr, pid, attr, size, flags);
 }
+#endif
 
 #ifndef HAVE_CLONE3
 struct clone_args {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Khem,

include/lapi/sched.h line 19

Quoted 2 lines
include/lapi/sched.h +2 -0
+/* sched_attr is not defined in glibc < 2.41 */
+#ifndef SCHED_ATTR_SIZE_VER0

Thank you for the fix.

This is faster than traditional AC_CHECK_MEMBERS(struct sched_attr) check, that's why I merged it. I suppose once musl adds the struct it also adds SCHED_ATTR_SIZE_VER0. If not we will need to use AC_CHECK_MEMBERS check.

Bionic uses kernel headers anyway, thus it will work.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp