Update comment for struct type's length field, introduce type_length_units
[deliverable/binutils-gdb.git] / gdb / ptrace.m4
CommitLineData
eb7aa561
PA
1dnl Copyright (C) 2012-2015 Free Software Foundation, Inc.
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
54019719
PA
25# Needs to be tested in C++ mode, to detect whether we need to cast
26# the first argument to enum __ptrace_request.
27if test "$enable_build_with_cxx" = "yes"; then
28 AC_LANG_PUSH([C++])
29fi
30
eb7aa561
PA
31gdb_ptrace_headers='
32#include <sys/types.h>
33#if HAVE_SYS_PTRACE_H
34# include <sys/ptrace.h>
35#endif
36#if HAVE_UNISTD_H
37# include <unistd.h>
38#endif
39'
40# There is no point in checking if we don't have a prototype.
41AC_CHECK_DECLS(ptrace, [], [
42 : ${gdb_cv_func_ptrace_ret='int'}
43 : ${gdb_cv_func_ptrace_args='int,int,long,long'}
44], $gdb_ptrace_headers)
45# Check return type. Varargs (used on GNU/Linux) conflict with the
46# empty argument list, so check for that explicitly.
47AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
48 AC_TRY_COMPILE($gdb_ptrace_headers,
49 [extern long ptrace (enum __ptrace_request, ...);],
50 gdb_cv_func_ptrace_ret='long',
51 AC_TRY_COMPILE($gdb_ptrace_headers,
52 [extern int ptrace ();],
53 gdb_cv_func_ptrace_ret='int',
54 gdb_cv_func_ptrace_ret='long')))
55AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
56 [Define as the return type of ptrace.])
57# Check argument types.
58AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
59 AC_TRY_COMPILE($gdb_ptrace_headers,
60 [extern long ptrace (enum __ptrace_request, ...);],
54019719 61 [gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'],[
eb7aa561
PA
62for gdb_arg1 in 'int' 'long'; do
63 for gdb_arg2 in 'pid_t' 'int' 'long'; do
64 for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
65 for gdb_arg4 in 'int' 'long' 'void *'; do
66 AC_TRY_COMPILE($gdb_ptrace_headers, [
67extern $gdb_cv_func_ptrace_ret
68 ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
69], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
70 break 4;])
71 for gdb_arg5 in 'int *' 'int' 'long'; do
72 AC_TRY_COMPILE($gdb_ptrace_headers, [
73extern $gdb_cv_func_ptrace_ret
74 ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
75], [
76gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
77 break 5;])
78 done
79 done
80 done
81 done
82done
83# Provide a safe default value.
84: ${gdb_cv_func_ptrace_args='int,int,long,long'}
85])])
86ac_save_IFS=$IFS; IFS=','
87set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
88IFS=$ac_save_IFS
89shift
54019719
PA
90AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG1, $[1],
91 [Define to the type of arg 1 for ptrace.])
eb7aa561
PA
92AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
93 [Define to the type of arg 3 for ptrace.])
94AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
95 [Define to the type of arg 4 for ptrace.])
96if test -n "$[5]"; then
97 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
98 [Define to the type of arg 5 for ptrace.])
99fi
54019719
PA
100
101if test "$enable_build_with_cxx" = "yes"; then
102 AC_LANG_POP([C++])
103fi
eb7aa561 104])
This page took 0.029806 seconds and 4 git commands to generate.