~ubuntu-branches/ubuntu/saucy/strace/saucy-proposed

0.1.1 by Roland McGrath
Import upstream version 4.5.4
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([[#ifdef LINUX
200
#include <linux/types.h>
201
#include <asm/stat.h>
202
#else
203
#include <sys/stat.h>
204
#endif]], [[struct stat64 st;]])],[ac_cv_type_stat64=yes],[ac_cv_type_stat64=no])])
205
AC_MSG_RESULT($ac_cv_type_stat64)
206
if test "$ac_cv_type_stat64" = yes
207
then
208
	AC_DEFINE([HAVE_STAT64], 1,
209
[Define if stat64 is available in asm/stat.h.])
210
fi
211
])
212
213
dnl ### A macro to determine if off_t is a long long
214
AC_DEFUN([AC_OFF_T_IS_LONG_LONG],
215
[AC_MSG_CHECKING(for long long off_t)
216
AC_CACHE_VAL(ac_cv_have_long_long_off_t,
217
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
218
main () {
219
	if (sizeof (off_t) == sizeof (long long) &&
220
	    sizeof (off_t) > sizeof (long))
221
	    return 0;
222
	return 1;
223
}
224
]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no],[# Should try to guess here
225
ac_cv_have_long_long_off_t=no
226
])])
227
AC_MSG_RESULT($ac_cv_have_long_long_off_t)
228
if test "$ac_cv_have_long_long_off_t" = yes
229
then
230
	AC_DEFINE([HAVE_LONG_LONG_OFF_T], 1, [Define if off_t is a long long.])
231
fi
232
])
233
234
dnl ### A macro to determine if rlim_t is a long long
235
AC_DEFUN([AC_RLIM_T_IS_LONG_LONG],
236
[AC_MSG_CHECKING(for long long rlim_t)
237
AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
238
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
239
#include <sys/time.h>
240
#include <sys/resource.h>
241
main () {
242
	if (sizeof (rlim_t) == sizeof (long long) &&
243
	    sizeof (rlim_t) > sizeof (long))
244
	    return 0;
245
	return 1;
246
}
247
]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no],[# Should try to guess here
248
ac_cv_have_long_long_rlim_t=no
249
])])
250
AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
251
if test "$ac_cv_have_long_long_rlim_t" = yes
252
then
253
	AC_DEFINE([HAVE_LONG_LONG_RLIM_T], 1, [Define if rlim_t is a long long.])
254
fi
255
])
256
257
dnl ### A macro to determine endianness of long long
258
AC_DEFUN([AC_LITTLE_ENDIAN_LONG_LONG],
259
[AC_MSG_CHECKING(for little endian long long)
260
AC_CACHE_VAL(ac_cv_have_little_endian_long_long,
261
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
262
int main () {
263
	union {
264
		long long ll;
265
		long l [2];
266
	} u;
267
	u.ll = 0x12345678;
268
	if (u.l[0] == 0x12345678)
269
		return 0;
270
	return 1;
271
}
272
]])],[ac_cv_have_little_endian_long_long=yes],[ac_cv_have_little_endian_long_long=no],[# Should try to guess here
273
ac_cv_have_little_endian_long_long=no
274
])])
275
AC_MSG_RESULT($ac_cv_have_little_endian_long_long)
276
if test "$ac_cv_have_little_endian_long_long" = yes
277
then
278
	AC_DEFINE([HAVE_LITTLE_ENDIAN_LONG_LONG], 1,
279
[Define if long long is little-endian.])
280
fi
281
])