1 dnl Copyright (C) 2012-2015 Free Software Foundation, Inc.
3 dnl This file is part of GDB.
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; either version 3 of the License, or
8 dnl (at your option) any later version.
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.
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18 dnl Check the return and argument types of ptrace.
20 AC_DEFUN([GDB_AC_PTRACE],
23 AC_CHECK_HEADERS([sys/ptrace.h ptrace.h])
26 #include <sys/types.h>
28 # include <sys/ptrace.h>
34 # There is no point in checking if we don't have a prototype.
35 AC_CHECK_DECLS(ptrace, [], [
36 : ${gdb_cv_func_ptrace_ret='int'}
37 : ${gdb_cv_func_ptrace_args='int,int,long,long'}
38 ], $gdb_ptrace_headers)
39 # Check return type. Varargs (used on GNU/Linux) conflict with the
40 # empty argument list, so check for that explicitly.
41 AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
42 AC_TRY_COMPILE($gdb_ptrace_headers,
43 [extern long ptrace (enum __ptrace_request, ...);],
44 gdb_cv_func_ptrace_ret='long',
45 AC_TRY_COMPILE($gdb_ptrace_headers,
46 [extern int ptrace ();],
47 gdb_cv_func_ptrace_ret='int',
48 gdb_cv_func_ptrace_ret='long')))
49 AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
50 [Define as the return type of ptrace.])
51 # Check argument types.
52 AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
53 AC_TRY_COMPILE($gdb_ptrace_headers,
54 [extern long ptrace (enum __ptrace_request, ...);],
55 [gdb_cv_func_ptrace_args='int,int,long,long'],[
56 for gdb_arg1 in 'int' 'long'; do
57 for gdb_arg2 in 'pid_t' 'int' 'long'; do
58 for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
59 for gdb_arg4 in 'int' 'long' 'void *'; do
60 AC_TRY_COMPILE($gdb_ptrace_headers, [
61 extern $gdb_cv_func_ptrace_ret
62 ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
63 ], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
65 for gdb_arg5 in 'int *' 'int' 'long'; do
66 AC_TRY_COMPILE($gdb_ptrace_headers, [
67 extern $gdb_cv_func_ptrace_ret
68 ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
70 gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
77 # Provide a safe default value.
78 : ${gdb_cv_func_ptrace_args='int,int,long,long'}
80 ac_save_IFS=$IFS; IFS=','
81 set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
84 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
85 [Define to the type of arg 3 for ptrace.])
86 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
87 [Define to the type of arg 4 for ptrace.])
88 if test -n "$[5]"; then
89 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
90 [Define to the type of arg 5 for ptrace.])