vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

ensc_syscall.m4 (3582B)


      1 dnl $Id$
      2 
      3 dnl Copyright (C) 2004, 2005, 2009
      4 dnl     Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
      5 dnl
      6 dnl This program is free software; you can redistribute it and/or modify
      7 dnl it under the terms of the GNU General Public License as published by
      8 dnl the Free Software Foundation; version 2 and/or 3 of the License.
      9 dnl
     10 dnl This program is distributed in the hope that it will be useful,
     11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 dnl GNU General Public License for more details.
     14 dnl
     15 dnl You should have received a copy of the GNU General Public License
     16 dnl along with this program; if not, write to the Free Software
     17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     18 
     19 dnl Usage: ENSC_SYSCALL
     20 
     21 AC_DEFUN([ENSC_SYSCALL_ALTERNATIVE],
     22 [
     23 	AC_MSG_CHECKING([whether to use alternative _syscallX macros])
     24 	AC_ARG_ENABLE([alternative-syscalls],
     25 		      [AC_HELP_STRING([--disable-alternative-syscalls],
     26 				      [do not use the alternative _syscallX macros
     27 				       provided by Herbert Poetzl (default: use them)])],
     28 		      [case $enableval in
     29 			   (yes|no)   ensc_use_alternative_syscall_macros=$enableval;;
     30 			   (*)	      AC_MSG_ERROR(['$enableval' is not a valid value for '--disable-alternative-syscalls']);;
     31 		       esac],
     32 		      [ensc_use_alternative_syscall_macros=yes])
     33 
     34 	case $ensc_use_alternative_syscall_macros in
     35 		(yes)	AC_DEFINE(ENSC_USE_ALTERNATIVE_SYSCALL_MACROS, 1, [Use alternative _syscallX macros]);;
     36 	esac
     37 
     38 	AC_MSG_RESULT([$ensc_use_alternative_syscall_macros])
     39 ])
     40 
     41 AC_DEFUN([ENSC_SYSCALL],
     42 [
     43 	AC_REQUIRE([ENSC_SYSCALL_ALTERNATIVE])
     44 
     45 	AC_MSG_CHECKING([for syscall(2) invocation method])
     46 	AC_ARG_WITH([syscall],
     47 		    [AC_HELP_STRING([--with-syscall=METHOD],
     48 				    [call syscall(2) with the specified METHOD; valid values are 'fast', 'traditional' and 'auto' (default: auto)])],
     49 		    [],
     50 		    [with_syscall=auto])
     51 	AC_MSG_RESULT([$with_syscall])
     52 
     53 	case x"$with_syscall" in
     54 	    (xauto)
     55 		AC_CACHE_CHECK([which syscall(2) invocation works], [ensc_cv_test_syscall],
     56 			       [
     57 				AC_LANG_PUSH(C)
     58 				AC_COMPILE_IFELSE([AC_LANG_SOURCE([
     59 #include "$srcdir/lib/syscall-wrap.h"
     60 #include <errno.h>
     61 
     62 #define __NR_foo0	300
     63 #define __NR_foo1	301
     64 #define __NR_foo2	302
     65 #define __NR_foo3	303
     66 #define __NR_foo4	304
     67 #define __NR_foo5	305
     68 inline static _syscall0(int, foo0)
     69 inline static _syscall1(int, foo1, int, a)
     70 inline static _syscall2(int, foo2, int, a, int, b)
     71 inline static _syscall3(int, foo3, int, a, int, b, int, c)
     72 inline static _syscall4(int, foo4, int, a, int, b, int, c, int, d)
     73 inline static _syscall5(int, foo5, int, a, int, b, int, c, int, d, int, e)
     74 
     75 int main() {
     76   return foo0() || \
     77 	 foo1(1) || \
     78 	 foo2(1,2) || \
     79 	 foo3(1,2,3) || \
     80 	 foo4(1,2,3,4) || \
     81 	 foo5(1,2,3,4,5);
     82 }
     83 				])],
     84 				[ensc_cv_test_syscall=fast],
     85 				[ensc_cv_test_syscall=traditional])
     86 
     87 				AC_LANG_POP
     88 		])
     89 		with_syscall=$ensc_cv_test_syscall
     90 		;;
     91 	    (xfast|xtraditional)
     92 		;;
     93 	    *)
     94 		AC_MSG_ERROR(['$with_syscall' is not a valid value for '--with-syscall'])
     95 		;;
     96 	esac
     97 
     98 	if test x"$with_syscall $ensc_use_alternative_syscall_macros" = 'xfast yes'; then
     99 	    with_syscall='alternative'
    100 	fi
    101 
    102 	if test x"$with_syscall" = xtraditional; then
    103 	    AC_DEFINE(ENSC_SYSCALL_TRADITIONAL,	 1, [Define to 1 when the fast syscall(2) invocation does not work])
    104 	fi
    105 
    106 	AH_BOTTOM([
    107 #if defined(__pic__) && defined(__i386) && !defined(ENSC_SYSCALL_TRADITIONAL) && !defined(ENSC_USE_ALTERNATIVE_SYSCALL_MACROS)
    108 #  define ENSC_SYSCALL_TRADITIONAL	1
    109 #endif])
    110 ])