3 # AMANDA_CHECK_TYPE(type, replacement-type, header)
7 # Like AC_CHECK_TYPE, where action-if-not-found DEFINEs $1 to $2.
9 # 'header' must be a single header name, or blank to use the default
12 AC_DEFUN([AMANDA_CHECK_TYPE], [
13 AC_REQUIRE([AC_HEADER_STDC])
14 AC_CHECK_TYPE($1, [], [
15 AC_DEFINE($1, $2, [Type for $1, if it is not defined by the system])
16 ], ifelse($3, [], [], [
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
35 # Check whether pid_t is a long, int, or short. DEFINE PRINTF_PID_T to the
36 # corresponding printf format.
38 AC_DEFUN([AMANDA_TYPE_PID_T], [
39 AC_REQUIRE([AC_HEADER_STDC])
40 AC_REQUIRE([AC_TYPE_PID_T])
41 AC_CACHE_CHECK([for pid_t type], amanda_cv_pid_type,
43 amanda_cv_pid_type=unknown
44 if test "$ac_cv_type_pid_t" = no; then
45 amanda_cv_pid_type=int
47 for TEST_amanda_cv_pid_type in long short int; do
48 if test $amanda_cv_pid_type = unknown; then
49 AC_EGREP_CPP(typedef.*${TEST_amanda_cv_pid_type}.*pid_t,
51 #include <sys/types.h>
57 amanda_cv_pid_type=$TEST_amanda_cv_pid_type)
59 if test $amanda_cv_pid_type = unknown; then
60 AC_EGREP_CPP(ZZZZ.*${TEST_amanda_cv_pid_type},
62 #include <sys/types.h>
69 amanda_cv_pid_type=$TEST_amanda_cv_pid_type)
72 if test $amanda_cv_pid_type = unknown; then
73 amanda_cv_pid_type=int
77 case $amanda_cv_pid_type in
78 int) AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%d",[Define to printf formatting string to print a PID. ]) ;;
79 long) AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%ld") ;;
80 short) AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%d") ;;
91 # Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'.
92 # by T.E.Dickey" , Jim Spath <jspath@mail.bcpl.lib.md.us>
94 # DEFINEs WAIT_USES_UNION if 'union wait' is found. Note that many systems
95 # support *both* 'union wait' and 'int' using a transparent union.
99 # FIXME: These tests should have been in autoconf 1.11!
101 # Note that we cannot simply grep for 'union wait' in the wait.h file,
102 # because some Posix systems turn this on only when a BSD variable is
103 # defined. Since I'm trying to do without special defines, I'll live
104 # with the default behavior of the include-file.
106 # I do _2_ compile checks, because we may have union-wait, but the
107 # prototype for 'wait()' may want an int.
109 # Don't use HAVE_UNION_WAIT, because the autoconf documentation implies
110 # that if we've got union-wait, we'll automatically use it.
112 # Garrett Wollman adds:
113 # The tests described above don't quite do the right thing,
114 # since some systems have hacks which allow `union wait' to
115 # still work even though `int' is preferred (and generates
116 # fewer warnings). Since all of these systems use prototypes,
117 # we can use the prototype of wait(2) to disambiguate them.
119 # Alexandre Oliva adds:
120 # A single compile check is enough. If we don't have union wait,
121 # it's obvious that the test will fail, and that we must use int.
122 # If we do, the prototype (on STDC systems) and WIFEXITED will tell
123 # whether we're supposed to be using union wait instead of int.
125 AC_DEFUN([CF_WAIT], [
126 AC_REQUIRE([AC_TYPE_PID_T])
127 AC_HAVE_HEADERS(sys/wait.h wait.h)
128 AC_CACHE_CHECK([whether wait uses union wait], [cf_cv_arg_union_wait], [
130 #include <sys/types.h>
133 # include <sys/wait.h>
141 pid_t wait(union wait *);
145 wait(&x); i = WIFEXITED(x)
146 ], [cf_cv_arg_union_wait=yes], [cf_cv_arg_union_wait=no])])
147 if test $cf_cv_arg_union_wait = yes; then
148 AC_DEFINE(WAIT_USES_UNION,1,
149 [Defined if wait() puts the status in a union wait instead of int. ])
159 # Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'.
160 # by T.E.Dickey" , Jim Spath <jspath@mail.bcpl.lib.md.us>
162 # DEFINEs WAIT_USES_INT if an int result type is found.
164 AC_DEFUN([CF_WAIT_INT], [
165 AC_REQUIRE([AC_TYPE_PID_T])
166 AC_HAVE_HEADERS(sys/wait.h wait.h)
167 AC_CACHE_CHECK([whether wait uses int], [cf_cv_arg_int], [
169 #include <sys/types.h>
172 # include <sys/wait.h>
184 wait(&x); i = WIFEXITED(x)
185 ], [cf_cv_arg_int=yes], [cf_cv_arg_int=no])])
186 if test $cf_cv_arg_int = yes; then
187 AC_DEFINE(WAIT_USES_INT,1,
188 [Defined if wait() puts the status in a int instead of a union wait. ])