gdbsupport: re-indent ptrace.m4
[deliverable/binutils-gdb.git] / gdbsupport / ptrace.m4
CommitLineData
b811d2c2 1dnl Copyright (C) 2012-2020 Free Software Foundation, Inc.
eb7aa561
PA
2dnl
3dnl This file is part of GDB.
4dnl
5dnl This program is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18dnl Check the return and argument types of ptrace.
19
20AC_DEFUN([GDB_AC_PTRACE],
21[
22
23AC_CHECK_HEADERS([sys/ptrace.h ptrace.h])
24
25gdb_ptrace_headers='
26#include <sys/types.h>
27#if HAVE_SYS_PTRACE_H
28# include <sys/ptrace.h>
29#endif
30#if HAVE_UNISTD_H
31# include <unistd.h>
32#endif
33'
c884cc46 34
eb7aa561
PA
35# Check return type. Varargs (used on GNU/Linux) conflict with the
36# empty argument list, so check for that explicitly.
b6fb30ed
SM
37AC_CACHE_CHECK(
38 [return type of ptrace],
39 [gdb_cv_func_ptrace_ret],
40 [AC_TRY_COMPILE(
41 [$gdb_ptrace_headers],
42 [extern long ptrace (enum __ptrace_request, ...);],
43 [gdb_cv_func_ptrace_ret='long'],
44 [AC_TRY_COMPILE(
45 [$gdb_ptrace_headers],
46 [extern int ptrace ();],
47 [gdb_cv_func_ptrace_ret='int'],
48 [gdb_cv_func_ptrace_ret='long']
49 )]
50 )]
51)
52
53AC_DEFINE_UNQUOTED(
54 [PTRACE_TYPE_RET],
55 [$gdb_cv_func_ptrace_ret],
56 [Define as the return type of ptrace.]
57)
58
eb7aa561 59# Check argument types.
b6fb30ed
SM
60AC_CACHE_CHECK(
61 [types of arguments for ptrace],
62 [gdb_cv_func_ptrace_args],
63 [AC_TRY_COMPILE(
64 [$gdb_ptrace_headers],
65 [extern long ptrace (enum __ptrace_request, ...);],
66 [gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'],
67 [for gdb_arg1 in 'int' 'long'; do
68 for gdb_arg2 in 'pid_t' 'int' 'long'; do
69 for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
70 for gdb_arg4 in 'int' 'long' 'void *'; do
71 AC_TRY_COMPILE(
72 [$gdb_ptrace_headers],
73 [extern $gdb_cv_func_ptrace_ret ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);],
74 [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
75 break 4;]
76 )
77
78 for gdb_arg5 in 'int *' 'int' 'long'; do
79 AC_TRY_COMPILE(
80 [$gdb_ptrace_headers],
81 [extern $gdb_cv_func_ptrace_ret ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);],
82 [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
83 break 5;]
84 )
85 done
86 done
87 done
88 done
89 done
90 # Provide a safe default value.
91 : ${gdb_cv_func_ptrace_args='int,int,long,long'}]
92 )]
93)
94
eb7aa561
PA
95ac_save_IFS=$IFS; IFS=','
96set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
97IFS=$ac_save_IFS
98shift
54019719
PA
99AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG1, $[1],
100 [Define to the type of arg 1 for ptrace.])
eb7aa561
PA
101AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
102 [Define to the type of arg 3 for ptrace.])
103AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
104 [Define to the type of arg 4 for ptrace.])
105if test -n "$[5]"; then
106 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
107 [Define to the type of arg 5 for ptrace.])
108fi
109])
This page took 0.662162 seconds and 4 git commands to generate.