Unify method for checking system calls and fallback handling. Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> --- configure.ac | 72 ++++++++++++++++++++++++++++++++++++++--------- schedutils/Makefile.am | 11 ++++++- schedutils/ionice.c | 32 --------------------- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index 6e212ea..44892c5 100644 --- a/configure.ac +++ b/configure.ac @@ -186,24 +186,67 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +dnl UTIL_CHECK_SYSCALL(SYSCALL, FALLBACK) +dnl Only specify FALLBACK if the SYSCALL +dnl you're checking for is a "newish" one +dnl ------------------------------------- +AC_DEFUN([UTIL_CHECK_SYSCALL],[ + sysnum="" + AC_MSG_CHECKING([for syscall $1]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/syscall.h> #include <unistd.h> -]], [[ -int test = SYS_pivot_root; -]])], -[AM_CONDITIONAL(HAVE_PIVOT_ROOT, true)], -[AM_CONDITIONAL(HAVE_PIVOT_ROOT, false)]) - - -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +]], [[int test = SYS_$1;]])], + [AC_MSG_RESULT([SYS_$1])],[dnl +dnl Our libc failed use, so see if we can get the kernel +dnl headers to play ball ... + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/syscall.h> #include <unistd.h> -]], [[ -int test = SYS_sched_getaffinity; -]])], -[AM_CONDITIONAL(HAVE_SCHED_GETAFFINITY, true)], -[AM_CONDITIONAL(HAVE_SCHED_GETAFFINITY, false)]) +]], [[int test = __NR_$1;]])], + [sysnum="__NR_$1"],[sysnum=""]) + if test "x$sysnum" != "x" ; then + AC_MSG_RESULT([__NR_$1]) + else + case $host_cpu in + $2 + esac + if test "x$sysnum" = "x" ; then + AC_MSG_WARN([unable to detect syscall $1]) + else + AC_MSG_RESULT([$sysnum]) + fi + fi + AC_DEFINE_UNQUOTED([SYS_$1], $sysnum, [Fallback syscall number for $1 in place of __NR_$1]) + ]) + AM_CONDITIONAL([HAVE_]m4_toupper($1), test -n "$sysnum") +]) +dnl UTIL_SYSCALL_FALLBACK(ARCH, SYSNUM) +dnl ARCH is a normal glob while SYSNUM +dnl is the fallback sycall num for ARCH +dnl ----------------------------------- +AC_DEFUN([UTIL_SYSCALL_FALLBACK],[$1) sysnum=$2;;]) + +UTIL_CHECK_SYSCALL([pivot_root]) +UTIL_CHECK_SYSCALL([sched_getaffinity]) +UTIL_CHECK_SYSCALL([ioprio_set], [dnl + UTIL_SYSCALL_FALLBACK([alpha], [442]) + UTIL_SYSCALL_FALLBACK([i*86], [289]) + UTIL_SYSCALL_FALLBACK([ia64*], [1274]) + UTIL_SYSCALL_FALLBACK([powerpc*], [273]) + UTIL_SYSCALL_FALLBACK([s390*], [282]) + UTIL_SYSCALL_FALLBACK([sparc*], [196]) + UTIL_SYSCALL_FALLBACK([x86_64*], [251]) +]) +UTIL_CHECK_SYSCALL([ioprio_get], [dnl + UTIL_SYSCALL_FALLBACK([alpha], [443]) + UTIL_SYSCALL_FALLBACK([i*86], [290]) + UTIL_SYSCALL_FALLBACK([ia64*], [1275]) + UTIL_SYSCALL_FALLBACK([powerpc*], [274]) + UTIL_SYSCALL_FALLBACK([s390*], [283]) + UTIL_SYSCALL_FALLBACK([sparc*], [218]) + UTIL_SYSCALL_FALLBACK([x86_64*], [252]) +]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ diff --git a/schedutils/Makefile.am b/schedutils/Makefile.am index e93d31b..81a734e 100644 --- a/schedutils/Makefile.am +++ b/schedutils/Makefile.am @@ -2,8 +2,15 @@ include $(top_srcdir)/config/include-Makefile.am if BUILD_SCHEDUTILS -usrbinexec_PROGRAMS = chrt ionice -man_MANS = chrt.1 ionice.1 +usrbinexec_PROGRAMS = chrt +man_MANS = chrt.1 + +if HAVE_IOPRIO_GET +if HAVE_IOPRIO_SET +usrbinexec_PROGRAMS += ionice +man_MANS += ionice.1 +endif +endif if HAVE_SCHED_GETAFFINITY usrbinexec_PROGRAMS += taskset diff --git a/schedutils/ionice.c b/schedutils/ionice.c index 9eb1387..679014a 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -15,38 +15,6 @@ #include <sys/syscall.h> #include <asm/unistd.h> -#if !defined(SYS_ioprio_get) || !defined(SYS_ioprio_set) - -# if defined(__i386__) -# define __NR_ioprio_set 289 -# define __NR_ioprio_get 290 -# elif defined(__powerpc__) || defined(__powerpc64__) -# define __NR_ioprio_set 273 -# define __NR_ioprio_get 274 -# elif defined(__x86_64__) -# define __NR_ioprio_set 251 -# define __NR_ioprio_get 252 -# elif defined(__ia64__) -# define __NR_ioprio_set 1274 -# define __NR_ioprio_get 1275 -# elif defined(__alpha__) -# define __NR_ioprio_set 442 -# define __NR_ioprio_get 443 -# elif defined(__s390x__) || defined(__s390__) -# define __NR_ioprio_set 282 -# define __NR_ioprio_get 283 -# elif defined(__sparc__) || defined(__sparc64__) -# define __NR_ioprio_set 196 -# define __NR_ioprio_get 218 -# else -# error "Unsupported arch" -# endif - -# define SYS_ioprio_get __NR_ioprio_get -# define SYS_ioprio_set __NR_ioprio_set - -#endif /* !SYS_ioprio_get */ - static inline int ioprio_set(int which, int who, int ioprio) { return syscall(SYS_ioprio_set, which, who, ioprio); -- 1.5.3.rc7 - To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html