Unify method for checking system calls and fallback handling. Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> --- configure.ac | 70 ++++++++++++++++++++++++++++++++++++++++---------- mount/Makefile.am | 9 +----- schedutils/ionice.c | 32 ----------------------- 3 files changed, 58 insertions(+), 53 deletions(-) diff --git a/configure.ac b/configure.ac index 6e212ea..46f39fe 100644 --- a/configure.ac +++ b/configure.ac @@ -186,24 +186,66 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +dnl UTIL_SYSCALL_CHECK(SYSCALL, FALLBACK) +dnl Only specify FALLBACK if the SYSCALL +dnl you're checking for is a "newish" one +dnl ------------------------------------- +AC_DEFUN([UTIL_SYSCALL_CHECK],[ + 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 + *) sysnum=-1;; + esac + if test "x$sysnum" = "x-1" ; then + AC_MSG_RESULT([unable to detect]) + else + AC_MSG_RESULT([$sysnum]) + fi + fi + AC_DEFINE_UNQUOTED([SYS_$1], $sysnum, [Fallback syscall number for $1 in place of __NR_$1]) + ]) +]) +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_SYSCALL_CHECK([pivot_root]) +UTIL_SYSCALL_CHECK([sched_getaffinity]) +UTIL_SYSCALL_CHECK([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_SYSCALL_CHECK([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/mount/Makefile.am b/mount/Makefile.am index f40bdd7..962e596 100644 --- a/mount/Makefile.am +++ b/mount/Makefile.am @@ -3,8 +3,8 @@ include $(top_srcdir)/config/include-Makefile.am EXTRA_DIST = README.mount bin_PROGRAMS = mount umount -sbin_PROGRAMS = losetup swapon -man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8 +sbin_PROGRAMS = losetup swapon pivot_root +man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8 pivot_root.8 utils_common = sundries.c xmalloc.c realpath.c fsprobe.c @@ -48,11 +48,6 @@ utils_common += fsprobe_volumeid.c LDADD_common += -lvolume_id endif -if HAVE_PIVOT_ROOT -sbin_PROGRAMS += pivot_root -man_MANS += pivot_root.8 -endif - noinst_PROGRAMS = mtab_lock_test mtab_lock_test_SOURCES = fstab.c sundries.c xmalloc.c $(headers_common) mtab_lock_test_CPPFLAGS = -DMAIN_TEST_MTABLOCK $(AM_CPPFLAGS) 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