Description: Fix build with GNU libc 2.41
Author: Aurelien Jarno <aurelien@aurel32.net>
Last-Update: 2025-03-08
Bug-Debian: http://bugs.debian.org/1099285
Forwarded: https://github.com/scheduler-tools/rt-app/pull/136

--- rt-app-1.0.orig/configure.ac
+++ rt-app-1.0/configure.ac
@@ -16,7 +16,7 @@ AC_CHECK_LIB([pthread], [pthread_create]
 AC_CHECK_LIB([m], [round])
 AC_CHECK_LIB([rt], [clock_gettime])
 AC_CHECK_LIB([json-c], [json_object_from_file])
-AC_CHECK_FUNCS(sched_setattr, [], [])
+AC_CHECK_FUNCS(sched_setattr, [have_sched_settattr=yes], [have_sched_settattr=no])
 
 AC_ARG_WITH([deadline],
 	[AS_HELP_STRING([--with-deadline], 
@@ -24,7 +24,7 @@ AC_ARG_WITH([deadline],
 	[AC_DEFINE([DLSCHED], [1], [Define if you have SCHED_DEADLINE support])], 
 	[with_deadline=no])
 
-AM_CONDITIONAL([SET_DLSCHED], [test x$with_deadline != xno && test !HAVE_SCHED_SETATTR])
+AM_CONDITIONAL([SET_DLSCHED], [test x$with_deadline != xno && test x$have_sched_settattr = xno])
 
 AC_ARG_VAR([LOGLVL], [verbosity level, from 0 to 100. 100 is very verbose])
 
--- rt-app-1.0.orig/src/rt-app_args.c
+++ rt-app-1.0/src/rt-app_args.c
@@ -19,6 +19,7 @@ along with this program; if not, write t
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
--- rt-app-1.0.orig/src/rt-app_parse_config.c
+++ rt-app-1.0/src/rt-app_parse_config.c
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fi
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <json-c/json.h>
 
 #include "rt-app_utils.h"
--- rt-app-1.0.orig/src/rt-app_types.h
+++ rt-app-1.0/src/rt-app_types.h
@@ -25,7 +25,10 @@ Foundation, Inc., 51 Franklin Street, Fi
 #include <pthread.h>
 
 #include "config.h"
+
+#ifndef HAVE_SCHED_SETATTR
 #include "dl_syscalls.h"
+#endif
 
 #define RTAPP_POLICY_DESCR_LENGTH 16
 #define RTAPP_RESOURCE_DESCR_LENGTH 16
--- rt-app-1.0.orig/src/rt-app_utils.c
+++ rt-app-1.0/src/rt-app_utils.c
@@ -19,12 +19,15 @@ along with this program; if not, write t
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <math.h>
 #include <stdarg.h>
+#include <unistd.h>
+#include <sys/syscall.h>
 
 #include "rt-app_utils.h"
 
