]> granicus.if.org Git - strace/blob - acinclude.m4
Fix msgsnd indirect ipccall decoding
[strace] / acinclude.m4
1 dnl
2 dnl This file contains macros used in configure.ac.
3 dnl automake uses this file to generate aclocal.m4, which is used by autoconf.
4 dnl
5
6 dnl ### A macro to find the include directory, useful for cross-compiling.
7 AC_DEFUN([AC_INCLUDEDIR],
8 [AC_REQUIRE([AC_PROG_AWK])dnl
9 AC_SUBST(includedir)
10 AC_MSG_CHECKING(for primary include directory)
11 includedir=/usr/include
12 if test -n "$GCC"
13 then
14         >conftest.c
15         new_includedir=`
16                 $CC -v -E conftest.c 2>&1 | $AWK '
17                         /^End of search list/ { print last; exit }
18                         { last = [$]1 }
19                 '
20         `
21         rm -f conftest.c
22         if test -n "$new_includedir" && test -d "$new_includedir"
23         then
24                 includedir=$new_includedir
25         fi
26 fi
27 AC_MSG_RESULT($includedir)
28 ])
29
30 dnl ### A macro to set gcc warning flags.
31 define(AC_WARNFLAGS,
32 [AC_SUBST(WARNFLAGS)
33 if test -z "$WARNFLAGS"
34 then
35         if test -n "$GCC"
36         then
37                 # If we're using gcc we want warning flags.
38                 WARNFLAGS=-Wall
39         fi
40 fi
41 ])
42
43 dnl ### A macro to determine if we have a "MP" type procfs
44 AC_DEFUN([AC_MP_PROCFS],
45 [AC_MSG_CHECKING(for MP procfs)
46 AC_CACHE_VAL(ac_cv_mp_procfs,
47 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
48 #include <stdio.h>
49 #include <signal.h>
50 #include <sys/procfs.h>
51
52 main()
53 {
54         int pid;
55         char proc[32];
56         FILE *ctl;
57         FILE *status;
58         int cmd;
59         struct pstatus pstatus;
60
61         if ((pid = fork()) == 0) {
62                 pause();
63                 exit(0);
64         }
65         sprintf(proc, "/proc/%d/ctl", pid);
66         if ((ctl = fopen(proc, "w")) == NULL)
67                 goto fail;
68         sprintf(proc, "/proc/%d/status", pid);
69         if ((status = fopen (proc, "r")) == NULL)
70                 goto fail;
71         cmd = PCSTOP;
72         if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
73                 goto fail;
74         if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
75                 goto fail;
76         kill(pid, SIGKILL);
77         exit(0);
78 fail:
79         kill(pid, SIGKILL);
80         exit(1);
81 }
82 ]])],[ac_cv_mp_procfs=yes],[ac_cv_mp_procfs=no],[
83 # Guess or punt.
84 case "$host_os" in
85 svr4.2*|svr5*)
86         ac_cv_mp_procfs=yes
87         ;;
88 *)
89         ac_cv_mp_procfs=no
90         ;;
91 esac
92 ])])
93 AC_MSG_RESULT($ac_cv_mp_procfs)
94 if test "$ac_cv_mp_procfs" = yes
95 then
96         AC_DEFINE([HAVE_MP_PROCFS], 1,
97 [Define if you have a SVR4 MP type procfs.
98 I.E. /dev/xxx/ctl, /dev/xxx/status.
99 Also implies that you have the pr_lwp member in prstatus.])
100 fi
101 ])
102
103 dnl ### A macro to determine if procfs is pollable.
104 AC_DEFUN([AC_POLLABLE_PROCFS],
105 [AC_MSG_CHECKING(for pollable procfs)
106 AC_CACHE_VAL(ac_cv_pollable_procfs,
107 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
108 #include <stdio.h>
109 #include <signal.h>
110 #include <sys/procfs.h>
111 #include <sys/stropts.h>
112 #include <poll.h>
113
114 #ifdef HAVE_MP_PROCFS
115 #define PIOCSTOP        PCSTOP
116 #define POLLWANT        POLLWRNORM
117 #define PROC            "/proc/%d/ctl"
118 #define PROC_MODE       "w"
119 int IOCTL (int fd, int cmd, int arg) {
120         return write (fd, &cmd, sizeof cmd);
121 }
122 #else
123 #define POLLWANT        POLLPRI
124 #define PROC            "/proc/%d"
125 #define PROC_MODE       "r+"
126 #define IOCTL           ioctl
127 #endif
128
129 main()
130 {
131         int pid;
132         char proc[32];
133         FILE *pfp;
134         struct pollfd pfd;
135
136         if ((pid = fork()) == 0) {
137                 pause();
138                 exit(0);
139         }
140         sprintf(proc, PROC, pid);
141         if ((pfp = fopen(proc, PROC_MODE)) == NULL)
142                 goto fail;
143         if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
144                 goto fail;
145         pfd.fd = fileno(pfp);
146         pfd.events = POLLWANT;
147         if (poll(&pfd, 1, 0) < 0)
148                 goto fail;
149         if (!(pfd.revents & POLLWANT))
150                 goto fail;
151         kill(pid, SIGKILL);
152         exit(0);
153 fail:
154         kill(pid, SIGKILL);
155         exit(1);
156 }
157 ]])],[ac_cv_pollable_procfs=yes],[ac_cv_pollable_procfs=no],[
158 # Guess or punt.
159 case "$host_os" in
160 solaris2*|irix5*|svr4.2uw*|svr5*)
161         ac_cv_pollable_procfs=yes
162         ;;
163 *)
164         ac_cv_pollable_procfs=no
165         ;;
166 esac
167 ])])
168 AC_MSG_RESULT($ac_cv_pollable_procfs)
169 if test "$ac_cv_pollable_procfs" = yes
170 then
171         AC_DEFINE([HAVE_POLLABLE_PROCFS], 1,
172 [Define if you have SVR4 and the poll system call works on /proc files.])
173 fi
174 ])
175
176 dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
177 AC_DEFUN([AC_STRUCT_PR_SYSCALL],
178 [AC_MSG_CHECKING(for pr_syscall in struct prstatus)
179 AC_CACHE_VAL(ac_cv_struct_pr_syscall,
180 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/procfs.h>]], [[#ifdef HAVE_MP_PROCFS
181 pstatus_t s;
182 s.pr_lwp.pr_syscall
183 #else
184 prstatus_t s;
185 s.pr_syscall
186 #endif]])],[ac_cv_struct_pr_syscall=yes],[ac_cv_struct_pr_syscall=no])])
187 AC_MSG_RESULT($ac_cv_struct_pr_syscall)
188 if test "$ac_cv_struct_pr_syscall" = yes
189 then
190         AC_DEFINE([HAVE_PR_SYSCALL], 1,
191 [Define if the prstatus structure in sys/procfs.h has a pr_syscall member.])
192 fi
193 ])
194
195 dnl ### A macro to determine whether stat64 is defined.
196 AC_DEFUN([AC_STAT64],
197 [AC_MSG_CHECKING(for stat64 in (asm|sys)/stat.h)
198 AC_CACHE_VAL(ac_cv_type_stat64,
199 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
200 #ifdef LINUX
201 #include <linux/types.h>
202 #include <asm/stat.h>
203 #else
204 #include <sys/stat.h>
205 #endif]], [[struct stat64 st;]])],[ac_cv_type_stat64=yes],[ac_cv_type_stat64=no])])
206 AC_MSG_RESULT($ac_cv_type_stat64)
207 if test "$ac_cv_type_stat64" = yes
208 then
209         AC_DEFINE([HAVE_STAT64], 1,
210 [Define if stat64 is available in asm/stat.h.])
211 fi
212 ])
213
214 dnl ### A macro to determine whether statfs64 is defined.
215 AC_DEFUN([AC_STATFS64],
216 [AC_MSG_CHECKING(for statfs64 in sys/vfs.h)
217 AC_CACHE_VAL(ac_cv_type_statfs64,
218 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef LINUX
219 #include <linux/types.h>
220 #include <sys/vfs.h>
221 #endif]], [[struct statfs64 st;]])],[ac_cv_type_statfs64=yes],[ac_cv_type_statfs64=no])])
222 AC_MSG_RESULT($ac_cv_type_statfs64)
223 if test "$ac_cv_type_statfs64" = yes
224 then
225         AC_DEFINE([HAVE_STATFS64], 1,
226 [Define if statfs64 is available in sys/vfs.h.])
227 fi
228 ])
229
230
231 dnl ### A macro to determine if off_t is a long long
232 AC_DEFUN([AC_OFF_T_IS_LONG_LONG],
233 [AC_MSG_CHECKING(for long long off_t)
234 AC_CACHE_VAL(ac_cv_have_long_long_off_t,
235 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
236 main () {
237         if (sizeof (off_t) == sizeof (long long) &&
238             sizeof (off_t) > sizeof (long))
239             return 0;
240         return 1;
241 }
242 ]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no],[# Should try to guess here
243 ac_cv_have_long_long_off_t=no
244 ])])
245 AC_MSG_RESULT($ac_cv_have_long_long_off_t)
246 if test "$ac_cv_have_long_long_off_t" = yes
247 then
248         AC_DEFINE([HAVE_LONG_LONG_OFF_T], 1, [Define if off_t is a long long.])
249 fi
250 ])
251
252 dnl ### A macro to determine if rlim_t is a long long
253 AC_DEFUN([AC_RLIM_T_IS_LONG_LONG],
254 [AC_MSG_CHECKING(for long long rlim_t)
255 AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
256 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
257 #include <sys/time.h>
258 #include <sys/resource.h>
259 main () {
260         if (sizeof (rlim_t) == sizeof (long long) &&
261             sizeof (rlim_t) > sizeof (long))
262             return 0;
263         return 1;
264 }
265 ]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no],[# Should try to guess here
266 ac_cv_have_long_long_rlim_t=no
267 ])])
268 AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
269 if test "$ac_cv_have_long_long_rlim_t" = yes
270 then
271         AC_DEFINE([HAVE_LONG_LONG_RLIM_T], 1, [Define if rlim_t is a long long.])
272 fi
273 ])
274
275 dnl ### A macro to determine endianness of long long
276 AC_DEFUN([AC_LITTLE_ENDIAN_LONG_LONG],
277 [AC_MSG_CHECKING(for little endian long long)
278 AC_CACHE_VAL(ac_cv_have_little_endian_long_long,
279 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
280 int main () {
281         union {
282                 long long ll;
283                 long l [2];
284         } u;
285         u.ll = 0x12345678;
286         if (u.l[0] == 0x12345678)
287                 return 0;
288         return 1;
289 }
290 ]])],[ac_cv_have_little_endian_long_long=yes],[ac_cv_have_little_endian_long_long=no],[# Should try to guess here
291 ac_cv_have_little_endian_long_long=no
292 ])])
293 AC_MSG_RESULT($ac_cv_have_little_endian_long_long)
294 if test "$ac_cv_have_little_endian_long_long" = yes
295 then
296         AC_DEFINE([HAVE_LITTLE_ENDIAN_LONG_LONG], 1,
297 [Define if long long is little-endian.])
298 fi
299 ])