gdbserver: make thread_info non-POD
[deliverable/binutils-gdb.git] / gdbsupport / ptrace.m4
1 dnl Copyright (C) 2012-2021 Free Software Foundation, Inc.
2 dnl
3 dnl This file is part of GDB.
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; either version 3 of the License, or
8 dnl (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
17
18 dnl Check the return and argument types of ptrace.
19
20 AC_DEFUN([GDB_AC_PTRACE],
21 [
22
23 AC_CHECK_HEADERS([sys/ptrace.h ptrace.h])
24
25 gdb_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 '
34
35 # Check return type. Varargs (used on GNU/Linux) conflict with the
36 # empty argument list, so check for that explicitly.
37 AC_CACHE_CHECK(
38 [return type of ptrace],
39 [gdb_cv_func_ptrace_ret],
40 [AC_COMPILE_IFELSE(
41  [AC_LANG_PROGRAM(
42 [$gdb_ptrace_headers],
43 [extern long ptrace (enum __ptrace_request, ...);]
44 )],
45 [gdb_cv_func_ptrace_ret='long'],
46 [AC_COMPILE_IFELSE(
47 [AC_LANG_PROGRAM(
48 [$gdb_ptrace_headers],
49 [extern int ptrace ();]
50 )],
51 [gdb_cv_func_ptrace_ret='int'],
52 [gdb_cv_func_ptrace_ret='long']
53 )]
54 )]
55 )
56
57 AC_DEFINE_UNQUOTED(
58 [PTRACE_TYPE_RET],
59 [$gdb_cv_func_ptrace_ret],
60 [Define as the return type of ptrace.]
61 )
62
63 # Check argument types.
64 AC_CACHE_CHECK(
65 [types of arguments for ptrace],
66 [gdb_cv_func_ptrace_args],
67 [AC_COMPILE_IFELSE(
68 [AC_LANG_PROGRAM(
69 [$gdb_ptrace_headers],
70 [extern long ptrace (enum __ptrace_request, ...);]
71 )],
72 [gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'],
73 [for gdb_arg1 in 'int' 'long'; do
74 for gdb_arg2 in 'pid_t' 'int' 'long'; do
75 for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
76 for gdb_arg4 in 'int' 'long' 'void *'; do
77 AC_COMPILE_IFELSE(
78 [AC_LANG_PROGRAM(
79 [$gdb_ptrace_headers],
80 [extern $gdb_cv_func_ptrace_ret ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);]
81 )],
82 [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
83 break 4;]
84 )
85
86 for gdb_arg5 in 'int *' 'int' 'long'; do
87 AC_COMPILE_IFELSE(
88 [AC_LANG_PROGRAM(
89 [$gdb_ptrace_headers],
90 [extern $gdb_cv_func_ptrace_ret ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);]
91 )],
92 [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
93 break 5;]
94 )
95 done
96 done
97 done
98 done
99 done
100 # Provide a safe default value.
101 : ${gdb_cv_func_ptrace_args='int,int,long,long'}]
102 )]
103 )
104
105 ac_save_IFS=$IFS; IFS=','
106 set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
107 IFS=$ac_save_IFS
108 shift
109 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG1, $[1],
110 [Define to the type of arg 1 for ptrace.])
111 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
112 [Define to the type of arg 3 for ptrace.])
113 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
114 [Define to the type of arg 4 for ptrace.])
115 if test -n "$[5]"; then
116 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
117 [Define to the type of arg 5 for ptrace.])
118 fi
119 ])
This page took 0.032885 seconds and 4 git commands to generate.