| 1 | dnl @synopsis AX_FUNC_SYSCALL |
|---|
| 2 | dnl |
|---|
| 3 | dnl This macro will find out how to call syscall. One or more of the following |
|---|
| 4 | dnl defines will be made as appropriate: |
|---|
| 5 | dnl HAVE_UNISTD_H - If unistd.h is available |
|---|
| 6 | dnl HAVE_SYS_SYSCALL_H - If sys/syscall.h is available |
|---|
| 7 | dnl HAVE_SYSCALL - If syscall() is available and is defined in unistd.h |
|---|
| 8 | dnl HAVE___SYSCALL - If __syscall() is available and is defined in unistd.h |
|---|
| 9 | dnl HAVE___SYSCALL_NEED_DEFN - If __syscall() is available but is not defined in unistd.h |
|---|
| 10 | dnl |
|---|
| 11 | dnl @category C |
|---|
| 12 | dnl @author Martin Ebourne |
|---|
| 13 | dnl @version 2005/07/01 |
|---|
| 14 | dnl @license AllPermissive |
|---|
| 15 | dnl |
|---|
| 16 | dnl Changed by Chris on 081026: |
|---|
| 17 | dnl |
|---|
| 18 | dnl Reversed the test for __syscall(), remove the test for syscall(), |
|---|
| 19 | dnl remove the definition and reverse the sense in ax_func_syscall.m4 |
|---|
| 20 | dnl (which checks for __syscall() needing definition). |
|---|
| 21 | dnl |
|---|
| 22 | dnl Autoconf's AC_CHECK_FUNC defines it when testing for its presence, |
|---|
| 23 | dnl so HAVE___SYSCALL will be true even if __syscall has no definition |
|---|
| 24 | dnl in the system libraries, and this is precisely the case that we |
|---|
| 25 | dnl want to test for, so now we test whether the test program compiles |
|---|
| 26 | dnl with no explicit definition (only the system headers) and if that |
|---|
| 27 | dnl fails, we set HAVE___SYSCALL_NEED_DEFN to 1. |
|---|
| 28 | |
|---|
| 29 | AC_DEFUN([AX_FUNC_SYSCALL], [ |
|---|
| 30 | AC_CHECK_HEADERS([sys/syscall.h unistd.h]) |
|---|
| 31 | AC_CHECK_FUNCS([syscall __syscall]) |
|---|
| 32 | if test "x$ac_cv_func___syscall" = "xyes"; then |
|---|
| 33 | AC_CACHE_CHECK([for __syscall needing definition], [box_cv_have___syscall_need_defn], |
|---|
| 34 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
|---|
| 35 | $ac_includes_default |
|---|
| 36 | #ifdef HAVE_SYS_SYSCALL_H |
|---|
| 37 | #include <sys/syscall.h> |
|---|
| 38 | #endif |
|---|
| 39 | ]], [[ |
|---|
| 40 | __syscall(SYS_exit, 0); |
|---|
| 41 | return 1; |
|---|
| 42 | ]])], |
|---|
| 43 | [box_cv_have___syscall_need_defn=no], [box_cv_have___syscall_need_defn=yes] |
|---|
| 44 | )]) |
|---|
| 45 | if test "x$box_cv_have___syscall_need_defn" = "xyes"; then |
|---|
| 46 | AC_DEFINE([HAVE___SYSCALL_NEED_DEFN], 1, |
|---|
| 47 | [Define to 1 if __syscall is available but needs a definition]) |
|---|
| 48 | fi |
|---|
| 49 | fi |
|---|
| 50 | ])dnl |
|---|