summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger2007-09-07 16:55:36 +0200
committerKarel Zak2007-09-20 00:22:22 +0200
commit72065909ccd29cd3c7c3105c95ba2434db304552 (patch)
tree0e8705d5cfc36f60fd9d2500b1c9023ed098c5a0
parentbuild-sys: nls/locale handling in util-linux-ng general (diff)
downloadkernel-qcow2-util-linux-72065909ccd29cd3c7c3105c95ba2434db304552.tar.gz
kernel-qcow2-util-linux-72065909ccd29cd3c7c3105c95ba2434db304552.tar.xz
kernel-qcow2-util-linux-72065909ccd29cd3c7c3105c95ba2434db304552.zip
build-sys: unify method for checking system calls and fallback handling
Co-Author: Stepan Kasal <skasal@redhat.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Stepan Kasal <skasal@redhat.com>
-rw-r--r--configure.ac83
-rw-r--r--schedutils/Makefile.am11
-rw-r--r--schedutils/ionice.c32
3 files changed, 78 insertions, 48 deletions
diff --git a/configure.ac b/configure.ac
index e7cfca3cd..b23395fd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,24 +187,79 @@ 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], [
+ dnl This macro uses host_cpu.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_CACHE_CHECK([for syscall $1],
+ [util_cv_syscall_$1],
+ [_UTIL_SYSCALL_CHECK_DECL([SYS_$1],
+ [syscall=SYS_$1],
+ [dnl Our libc failed use, so see if we can get the kernel
+ dnl headers to play ball ...
+ _UTIL_SYSCALL_CHECK_DECL([_NR_$1],
+ [syscall=_NR_$1],
+ [
+ syscall=no
+ case $host_cpu in
+ _UTIL_CHECK_SYSCALL_FALLBACK(m4_shift($@))
+ esac
+ ])
+ ])
+ util_cv_syscall_$1=$syscall
+ ])
+ AM_CONDITIONAL([HAVE_]m4_toupper($1), [test $util_cv_syscall_$1 != no])
+ case $util_cv_syscall_$1 in #(
+ no) AC_MSG_WARN([Unable to detect syscall $1.]) ;;
+ SYS_*) ;;
+ *) AC_DEFINE_UNQUOTED([SYS_$1], [$util_cv_syscall_$1],
+ [Fallback syscall number for $1]) ;;
+ esac
+])
+
+dnl _UTIL_SYSCALL_CHECK_DECL(SYMBOL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+dnl Check if SYMBOL is declared, using the headers needed for syscall checks.
+dnl -------------------------------------
+m4_define([_UTIL_SYSCALL_CHECK_DECL],
+[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)])
+]], [[int test = $1;]])],
+[$2], [$3])
+])
+dnl _UTIL_CHECK_SYSCALL_FALLBACK(PATTERN, VALUE, ...)
+dnl Helper macro to create the body for the above `case'.
+dnl -------------------------------------
+m4_define([_UTIL_CHECK_SYSCALL_FALLBACK],
+[m4_ifval([$1],
+ [#(
+ $1) syscall="$2" ;;dnl
+ _UTIL_CHECK_SYSCALL_FALLBACK(m4_shiftn(2, $@))])dnl
+])
-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)])
+
+UTIL_CHECK_SYSCALL([pivot_root])
+UTIL_CHECK_SYSCALL([sched_getaffinity])
+UTIL_CHECK_SYSCALL([ioprio_set],
+ [alpha], [442],
+ [i*86], [289],
+ [ia64*], [1274],
+ [powerpc*], [273],
+ [s390*], [282],
+ [sparc*], [196],
+ [x86_64*], [251])
+UTIL_CHECK_SYSCALL([ioprio_get],
+ [alpha], [443],
+ [i*86], [290],
+ [ia64*], [1275],
+ [powerpc*], [274],
+ [s390*], [283],
+ [sparc*], [218],
+ [x86_64*], [252])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
diff --git a/schedutils/Makefile.am b/schedutils/Makefile.am
index e93d31b39..81a734e96 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 9eb13877b..679014af4 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);