This commit was generated by cvs2svn to compensate for changes in r120,
[util-vserver.git] / m4 / ensc_syscall.m4
1 dnl $Id: ensc_syscall.m4,v 1.2.2.1 2004/02/05 03:52:45 ensc Exp $
2
3 dnl Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 dnl  
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; version 2 of the License.
8 dnl  
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl  
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 dnl Usage: ENSC_SYSCALL
19
20 AC_DEFUN([ENSC_SYSCALL],
21 [
22         AC_REQUIRE([ENSC_KERNEL_HEADERS])
23         AC_MSG_CHECKING([for syscall(2) invocation method])
24         AC_ARG_WITH([syscall],
25                     [AC_HELP_STRING([--with-syscall=METHOD],
26                                     [call syscall(2) with the specified METHOD; valid values are 'fast', 'traditional' and 'auto' (default: auto)])],
27                     [],
28                     [with_syscall=auto])
29         AC_MSG_RESULT([$with_syscall])
30         
31         case x"$with_syscall" in
32             xauto)
33                 AC_CACHE_CHECK([which syscall(2) invocation works], [ensc_cv_test_syscall],
34                                [
35                                 old_CPPFLAGS=$CPPFLAGS
36                                 CPPFLAGS="-I$ensc_cv_path_kernelheaders"
37                                 AC_LANG_PUSH(C)
38                                 AC_COMPILE_IFELSE([
39 #include <asm/unistd.h>
40 #include <syscall.h>
41 #include <errno.h>
42 #define __NR_foo0       300
43 #define __NR_foo1       301
44 #define __NR_foo2       302
45 #define __NR_foo3       303
46 #define __NR_foo4       304
47 #define __NR_foo5       305
48 inline static _syscall0(int, foo0)
49 inline static _syscall1(int, foo1, int, a)
50 inline static _syscall2(int, foo2, int, a, int, b)
51 inline static _syscall3(int, foo3, int, a, int, b, int, c)
52 inline static _syscall4(int, foo4, int, a, int, b, int, c, int, d)
53 inline static _syscall5(int, foo5, int, a, int, b, int, c, int, d, int, e)
54
55 int main() {
56   return foo0() || \
57          foo1(1) || \
58          foo2(1,2) || \
59          foo3(1,2,3) || \
60          foo4(1,2,3,4) || \
61          foo5(1,2,3,4,5);
62 }
63                                 ],
64                                 [ensc_cv_test_syscall=fast],
65                                 [ensc_cv_test_syscall=traditional])
66
67                                 AC_LANG_POP
68                                 CPPFLAGS=$old_CPPFLAGS
69                 ])
70                 with_syscall=$ensc_cv_test_syscall
71                 ;;
72             xfast|xtraditional)
73                 ;;
74             *)
75                 AC_MSG_ERROR(['$with_syscall' is not a valid value for '--with-syscall'])
76                 ;;
77         esac
78
79         if test x"$with_syscall" = xtraditional; then
80             AC_DEFINE(ENSC_SYSCALL_TRADITIONAL,  1, [Define to 1 when the fast syscall(2) invocation does not work])
81         fi
82         
83         AH_BOTTOM([
84 #if defined(__pic__) && defined(__i386) && !defined(ENSC_SYSCALL_TRADITIONAL)
85 #  define ENSC_SYSCALL_TRADITIONAL      1
86 #endif])
87 ])