1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # As a special exception, the Free Software Foundation gives unlimited
20 # permission to copy, distribute and modify the configure scripts that
21 # are the output of Autoconf. You need not follow the terms of the GNU
22 # General Public License when using or distributing such scripts, even
23 # though portions of the text of Autoconf appear in them. The GNU
24 # General Public License (GPL) does govern all other use of the material
25 # that constitutes the Autoconf program.
27 # Certain portions of the Autoconf source text are designed to be copied
28 # (in certain cases, depending on the input) into the output of
29 # Autoconf. We call these the "data" portions. The rest of the Autoconf
30 # source text consists of comments plus executable code that decides which
31 # of the data portions to output in any given case. We call these
32 # comments and executable code the "non-data" portions. Autoconf never
33 # copies any of the non-data portions into its output.
35 # This special exception to the GPL applies to versions of Autoconf
36 # released by the Free Software Foundation. When you make and
37 # distribute a modified version of Autoconf, you may extend this special
38 # exception to the GPL to apply to your modified version as well, *unless*
39 # your modified version has the potential to copy into its output some
40 # of the text that was the non-data portion of the version that you started
41 # with. (In other words, unless your change moves or copies text from
42 # the non-data portions to the data portions.) If your modification has
43 # such potential, you must delete any notice of this special exception
44 # to the GPL from your modified version.
46 # Written by David MacKenzie, with help from
47 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
48 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
53 # 1. Generic tests for functions.
54 # 2. Functions to check with AC_CHECK_FUNCS
55 # 3. Tests for specific functions.
58 ## -------------------------------- ##
59 ## 1. Generic tests for functions. ##
60 ## -------------------------------- ##
63 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
64 # -----------------------------------------------------------------
65 AC_DEFUN([AC_CHECK_FUNC],
66 [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
67 AC_CACHE_CHECK([for $1], [ac_var],
68 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
69 [AS_VAR_SET([ac_var], [yes])],
70 [AS_VAR_SET([ac_var], [no])])])
71 AS_IF([test AS_VAR_GET([ac_var]) = yes], [$2], [$3])dnl
72 AS_VAR_POPDEF([ac_var])dnl
76 # _AH_CHECK_FUNCS(FUNCTION...)
77 # ----------------------------
78 m4_define([_AH_CHECK_FUNCS],
79 [m4_foreach_w([AC_Func], [$1],
80 [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Func])),
81 [Define to 1 if you have the `]m4_defn([AC_Func])[' function.])])])
84 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
85 # ---------------------------------------------------------------------
86 AC_DEFUN([AC_CHECK_FUNCS],
87 [_AH_CHECK_FUNCS([$1])dnl
90 AC_CHECK_FUNC($ac_func,
91 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2],
97 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
98 # --------------------------------
99 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
101 _AH_CHECK_FUNCS([$1])
102 m4_foreach_w([AC_Func], [$1],
103 [AC_DEFUN([_AC_Func_]m4_defn([AC_Func]),
104 [m4_divert_text([INIT_PREPARE],
105 [ac_func_list="$ac_func_list AC_Func"])
106 _AC_FUNCS_EXPANSION])
107 AC_REQUIRE([_AC_Func_]m4_defn([AC_Func]))])
109 m4_define([_AC_FUNCS_EXPANSION],
111 m4_divert_text([DEFAULTS], [ac_func_list=])
112 AC_CHECK_FUNCS([$ac_func_list])
113 m4_define([_AC_FUNCS_EXPANSION], [])
117 # AC_REPLACE_FUNCS(FUNCTION...)
118 # -----------------------------
119 AC_DEFUN([AC_REPLACE_FUNCS],
120 [m4_foreach_w([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
121 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
125 # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
126 # ------------------------------------------------------------
127 # Try to link a program that calls FUNC, handling GCC builtins. If
128 # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
129 # ACTION-IF-NOT-FOUND.
130 AC_DEFUN([AC_TRY_LINK_FUNC],
131 [AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
136 AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
141 AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
146 ## ------------------------------------------- ##
147 ## 2. Functions to check with AC_CHECK_FUNCS. ##
148 ## ------------------------------------------- ##
150 AN_FUNCTION([__argz_count], [AC_CHECK_FUNCS])
151 AN_FUNCTION([__argz_next], [AC_CHECK_FUNCS])
152 AN_FUNCTION([__argz_stringify], [AC_CHECK_FUNCS])
153 AN_FUNCTION([__fpending], [AC_CHECK_FUNCS])
154 AN_FUNCTION([acl], [AC_CHECK_FUNCS])
155 AN_FUNCTION([alarm], [AC_CHECK_FUNCS])
156 AN_FUNCTION([atexit], [AC_CHECK_FUNCS])
157 AN_FUNCTION([btowc], [AC_CHECK_FUNCS])
158 AN_FUNCTION([bzero], [AC_CHECK_FUNCS])
159 AN_FUNCTION([clock_gettime], [AC_CHECK_FUNCS])
160 AN_FUNCTION([doprnt], [AC_CHECK_FUNCS])
161 AN_FUNCTION([dup2], [AC_CHECK_FUNCS])
162 AN_FUNCTION([endgrent], [AC_CHECK_FUNCS])
163 AN_FUNCTION([endpwent], [AC_CHECK_FUNCS])
164 AN_FUNCTION([euidaccess], [AC_CHECK_FUNCS])
165 AN_FUNCTION([fchdir], [AC_CHECK_FUNCS])
166 AN_FUNCTION([fdatasync], [AC_CHECK_FUNCS])
167 AN_FUNCTION([fesetround], [AC_CHECK_FUNCS])
168 AN_FUNCTION([floor], [AC_CHECK_FUNCS])
169 AN_FUNCTION([fs_stat_dev], [AC_CHECK_FUNCS])
170 AN_FUNCTION([ftime], [AC_CHECK_FUNCS])
171 AN_FUNCTION([ftruncate], [AC_CHECK_FUNCS])
172 AN_FUNCTION([getcwd], [AC_CHECK_FUNCS])
173 AN_FUNCTION([getdelim], [AC_CHECK_FUNCS])
174 AN_FUNCTION([gethostbyaddr], [AC_CHECK_FUNCS])
175 AN_FUNCTION([gethostbyname], [AC_CHECK_FUNCS])
176 AN_FUNCTION([gethostname], [AC_CHECK_FUNCS])
177 AN_FUNCTION([gethrtime], [AC_CHECK_FUNCS])
178 AN_FUNCTION([getmntent], [AC_CHECK_FUNCS])
179 AN_FUNCTION([getmntinfo], [AC_CHECK_FUNCS])
180 AN_FUNCTION([getpagesize], [AC_CHECK_FUNCS])
181 AN_FUNCTION([getpass], [AC_CHECK_FUNCS])
182 AN_FUNCTION([getspnam], [AC_CHECK_FUNCS])
183 AN_FUNCTION([gettimeofday], [AC_CHECK_FUNCS])
184 AN_FUNCTION([getusershell], [AC_CHECK_FUNCS])
185 AN_FUNCTION([hasmntopt], [AC_CHECK_FUNCS])
186 AN_FUNCTION([inet_ntoa], [AC_CHECK_FUNCS])
187 AN_FUNCTION([isascii], [AC_CHECK_FUNCS])
188 AN_FUNCTION([iswprint], [AC_CHECK_FUNCS])
189 AN_FUNCTION([lchown], [AC_CHECK_FUNCS])
190 AN_FUNCTION([listmntent], [AC_CHECK_FUNCS])
191 AN_FUNCTION([localeconv], [AC_CHECK_FUNCS])
192 AN_FUNCTION([localtime_r], [AC_CHECK_FUNCS])
193 AN_FUNCTION([mblen], [AC_CHECK_FUNCS])
194 AN_FUNCTION([mbrlen], [AC_CHECK_FUNCS])
195 AN_FUNCTION([memchr], [AC_CHECK_FUNCS])
196 AN_FUNCTION([memmove], [AC_CHECK_FUNCS])
197 AN_FUNCTION([mempcpy], [AC_CHECK_FUNCS])
198 AN_FUNCTION([memset], [AC_CHECK_FUNCS])
199 AN_FUNCTION([mkdir], [AC_CHECK_FUNCS])
200 AN_FUNCTION([mkfifo], [AC_CHECK_FUNCS])
201 AN_FUNCTION([modf], [AC_CHECK_FUNCS])
202 AN_FUNCTION([munmap], [AC_CHECK_FUNCS])
203 AN_FUNCTION([next_dev], [AC_CHECK_FUNCS])
204 AN_FUNCTION([nl_langinfo], [AC_CHECK_FUNCS])
205 AN_FUNCTION([pathconf], [AC_CHECK_FUNCS])
206 AN_FUNCTION([pow], [AC_CHECK_FUNCS])
207 AN_FUNCTION([pstat_getdynamic], [AC_CHECK_FUNCS])
208 AN_FUNCTION([putenv], [AC_CHECK_FUNCS])
209 AN_FUNCTION([re_comp], [AC_CHECK_FUNCS])
210 AN_FUNCTION([realpath], [AC_CHECK_FUNCS])
211 AN_FUNCTION([regcmp], [AC_CHECK_FUNCS])
212 AN_FUNCTION([regcomp], [AC_CHECK_FUNCS])
213 AN_FUNCTION([resolvepath], [AC_CHECK_FUNCS])
214 AN_FUNCTION([rint], [AC_CHECK_FUNCS])
215 AN_FUNCTION([rmdir], [AC_CHECK_FUNCS])
216 AN_FUNCTION([rpmatch], [AC_CHECK_FUNCS])
217 AN_FUNCTION([select], [AC_CHECK_FUNCS])
218 AN_FUNCTION([setenv], [AC_CHECK_FUNCS])
219 AN_FUNCTION([sethostname], [AC_CHECK_FUNCS])
220 AN_FUNCTION([setlocale], [AC_CHECK_FUNCS])
221 AN_FUNCTION([socket], [AC_CHECK_FUNCS])
222 AN_FUNCTION([sqrt], [AC_CHECK_FUNCS])
223 AN_FUNCTION([stime], [AC_CHECK_FUNCS])
224 AN_FUNCTION([stpcpy], [AC_CHECK_FUNCS])
225 AN_FUNCTION([strcasecmp], [AC_CHECK_FUNCS])
226 AN_FUNCTION([strchr], [AC_CHECK_FUNCS])
227 AN_FUNCTION([strcspn], [AC_CHECK_FUNCS])
228 AN_FUNCTION([strdup], [AC_CHECK_FUNCS])
229 AN_FUNCTION([strerror], [AC_CHECK_FUNCS])
230 AN_FUNCTION([strncasecmp], [AC_CHECK_FUNCS])
231 AN_FUNCTION([strndup], [AC_CHECK_FUNCS])
232 AN_FUNCTION([strpbrk], [AC_CHECK_FUNCS])
233 AN_FUNCTION([strrchr], [AC_CHECK_FUNCS])
234 AN_FUNCTION([strspn], [AC_CHECK_FUNCS])
235 AN_FUNCTION([strstr], [AC_CHECK_FUNCS])
236 AN_FUNCTION([strtol], [AC_CHECK_FUNCS])
237 AN_FUNCTION([strtoul], [AC_CHECK_FUNCS])
238 AN_FUNCTION([strtoull], [AC_CHECK_FUNCS])
239 AN_FUNCTION([strtoumax], [AC_CHECK_FUNCS])
240 AN_FUNCTION([strverscmp], [AC_CHECK_FUNCS])
241 AN_FUNCTION([sysinfo], [AC_CHECK_FUNCS])
242 AN_FUNCTION([tzset], [AC_CHECK_FUNCS])
243 AN_FUNCTION([uname], [AC_CHECK_FUNCS])
244 AN_FUNCTION([utime], [AC_CHECK_FUNCS])
245 AN_FUNCTION([utmpname], [AC_CHECK_FUNCS])
246 AN_FUNCTION([utmpxname], [AC_CHECK_FUNCS])
247 AN_FUNCTION([wcwidth], [AC_CHECK_FUNCS])
250 AN_FUNCTION([dcgettext], [AM_GNU_GETTEXT])
251 AN_FUNCTION([getwd], [warn: getwd is deprecated, use getcwd instead])
254 ## --------------------------------- ##
255 ## 3. Tests for specific functions. ##
256 ## --------------------------------- ##
259 # The macros are sorted:
261 # 1. AC_FUNC_* macros are sorted by alphabetical order.
263 # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
266 # 3. Obsolete macros are right after the modern macro.
272 # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
273 # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
274 # Nevertheless, for Automake, AC_LIBSOURCES it.
275 m4_define([_AC_LIBOBJ_ALLOCA],
276 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
277 # that cause trouble. Some versions do not even contain alloca or
278 # contain a buggy version. If you still want to use their alloca,
279 # use ar to extract alloca.o from them instead of compiling alloca.c.
280 AC_LIBSOURCES(alloca.c)
281 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
282 AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
284 AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
285 [AC_EGREP_CPP(webecray,
286 [#if defined CRAY && ! defined CRAY2
291 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
292 if test $ac_cv_os_cray = yes; then
293 for ac_func in _getb67 GETB67 getb67; do
294 AC_CHECK_FUNC($ac_func,
295 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
296 [Define to one of `_getb67', `GETB67',
297 `getb67' for Cray-2 and Cray-YMP
298 systems. This function is required for
299 `alloca.c' support on those systems.])
304 AC_CACHE_CHECK([stack direction for C alloca],
305 [ac_cv_c_stack_direction],
306 [AC_RUN_IFELSE([AC_LANG_SOURCE(
309 find_stack_direction ()
311 static char *addr = 0;
316 return find_stack_direction ();
319 return (&dummy > addr) ? 1 : -1;
325 return find_stack_direction () < 0;
327 [ac_cv_c_stack_direction=1],
328 [ac_cv_c_stack_direction=-1],
329 [ac_cv_c_stack_direction=0])])
330 AH_VERBATIM([STACK_DIRECTION],
331 [/* If using the C implementation of alloca, define if you know the
332 direction of stack growth for your system; otherwise it will be
333 automatically deduced at runtime.
334 STACK_DIRECTION > 0 => grows toward higher addresses
335 STACK_DIRECTION < 0 => grows toward lower addresses
336 STACK_DIRECTION = 0 => direction of growth unknown */
337 @%:@undef STACK_DIRECTION])dnl
338 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
339 ])# _AC_LIBOBJ_ALLOCA
344 AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
345 AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
346 AC_DEFUN([AC_FUNC_ALLOCA],
347 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
348 # for constant arguments. Useless!
349 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
351 [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
352 [[char *p = (char *) alloca (2 * sizeof (int));
353 if (p) return 0;]])],
354 [ac_cv_working_alloca_h=yes],
355 [ac_cv_working_alloca_h=no])])
356 if test $ac_cv_working_alloca_h = yes; then
357 AC_DEFINE(HAVE_ALLOCA_H, 1,
358 [Define to 1 if you have <alloca.h> and it should be used
362 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
363 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
365 # define alloca __builtin_alloca
369 # define alloca _alloca
371 # ifdef HAVE_ALLOCA_H
377 # ifndef alloca /* predefined by HP cc +Olibcalls */
384 ]], [[char *p = (char *) alloca (1);
385 if (p) return 0;]])],
386 [ac_cv_func_alloca_works=yes],
387 [ac_cv_func_alloca_works=no])])
389 if test $ac_cv_func_alloca_works = yes; then
390 AC_DEFINE(HAVE_ALLOCA, 1,
391 [Define to 1 if you have `alloca', as a function or macro.])
400 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
405 # Determine whether chown accepts arguments of -1 for uid and gid.
406 AN_FUNCTION([chown], [AC_FUNC_CHOWN])
407 AC_DEFUN([AC_FUNC_CHOWN],
408 [AC_REQUIRE([AC_TYPE_UID_T])dnl
409 AC_CHECK_HEADERS(unistd.h)
410 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
411 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
414 [[ char *f = "conftest.chown";
415 struct stat before, after;
417 if (creat (f, 0600) < 0)
419 if (stat (f, &before) < 0)
421 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
423 if (stat (f, &after) < 0)
425 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
427 [ac_cv_func_chown_works=yes],
428 [ac_cv_func_chown_works=no],
429 [ac_cv_func_chown_works=no])
432 if test $ac_cv_func_chown_works = yes; then
433 AC_DEFINE(HAVE_CHOWN, 1,
434 [Define to 1 if your system has a working `chown' function.])
439 # AC_FUNC_CLOSEDIR_VOID
440 # ---------------------
441 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
443 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
444 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
445 AC_CACHE_CHECK([whether closedir returns void],
446 [ac_cv_func_closedir_void],
447 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
448 #include <$ac_header_dirent>
453 [[return closedir (opendir (".")) != 0;]])],
454 [ac_cv_func_closedir_void=no],
455 [ac_cv_func_closedir_void=yes],
456 [ac_cv_func_closedir_void=yes])])
457 if test $ac_cv_func_closedir_void = yes; then
458 AC_DEFINE(CLOSEDIR_VOID, 1,
459 [Define to 1 if the `closedir' function returns void instead
465 # AC_FUNC_ERROR_AT_LINE
466 # ---------------------
467 AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
468 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
469 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
470 [AC_LIBSOURCES([error.h, error.c])dnl
471 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
472 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
473 [error_at_line (0, 0, "", 0, "an error occurred");])],
474 [ac_cv_lib_error_at_line=yes],
475 [ac_cv_lib_error_at_line=no])])
476 if test $ac_cv_lib_error_at_line = no; then
482 # AU::AM_FUNC_ERROR_AT_LINE
483 # -------------------------
484 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
487 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
488 # -------------------------------------------------------------------------
489 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
490 # IF-FALSE. Use CACHE_VAR.
491 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
493 [for working $1 fnmatch],
495 [# Some versions of Solaris, SCO, and the GNU C Library
496 # have a broken or incompatible fnmatch.
497 # So we run a test program. If we are cross-compiling, take no chance.
498 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
501 [#include <fnmatch.h>
502 # define y(a, b, c) (fnmatch (a, b, c) == 0)
503 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
506 (!(y ("a*", "abc", 0)
507 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
508 && y ("a\\\\bc", "abc", 0)
509 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
511 && n ("*x", ".x", FNM_PERIOD)
512 && m4_if([$1], [GNU],
513 [y ("xxXX", "xXxX", FNM_CASEFOLD)
514 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
515 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
516 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
517 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
518 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
523 AS_IF([test $$2 = yes], [$3], [$4])
524 ])# _AC_FUNC_FNMATCH_IF
529 AC_DEFUN([AC_FUNC_FNMATCH],
530 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
531 [AC_DEFINE([HAVE_FNMATCH], 1,
532 [Define to 1 if your system has a working POSIX `fnmatch'
539 # Prepare the replacement of fnmatch.
540 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
541 [AC_REQUIRE([AC_C_CONST])dnl
542 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
543 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
544 AC_CHECK_DECLS([getenv])
545 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
546 AC_CHECK_HEADERS([wchar.h wctype.h])
548 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
549 AC_DEFINE(fnmatch, rpl_fnmatch,
550 [Define to rpl_fnmatch if the replacement function should be used.])
551 ])# _AC_LIBOBJ_FNMATCH
556 AC_DEFUN([AC_REPLACE_FNMATCH],
557 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
558 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
559 [_AC_LIBOBJ_FNMATCH])
560 ])# AC_REPLACE_FNMATCH
563 # AC_FUNC_FNMATCH_GNU
564 # -------------------
565 AC_DEFUN([AC_FUNC_FNMATCH_GNU],
566 [AC_REQUIRE([AC_GNU_SOURCE])
567 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
568 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
569 [_AC_LIBOBJ_FNMATCH])
570 ])# AC_FUNC_FNMATCH_GNU
573 # AU::AM_FUNC_FNMATCH
574 # AU::fp_FUNC_FNMATCH
575 # -------------------
576 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
577 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
582 AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
583 AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
584 AC_DEFUN([AC_FUNC_FSEEKO],
585 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
586 [ac_cv_sys_largefile_source],
587 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
588 [[#include <sys/types.h> /* for off_t */
589 #include <stdio.h>]],
590 [[int (*fp) (FILE *, off_t, int) = fseeko;
591 return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
593 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
594 # in glibc 2.1.3, but that breaks too many other things.
595 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
596 if test $ac_cv_sys_largefile_source != unknown; then
597 AC_DEFINE(HAVE_FSEEKO, 1,
598 [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
605 # Try to find `getgroups', and check that it works.
606 # When cross-compiling, assume getgroups is broken.
607 AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
608 AC_DEFUN([AC_FUNC_GETGROUPS],
609 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
610 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
611 AC_CHECK_FUNC(getgroups)
613 # If we don't yet have getgroups, see if it's in -lbsd.
614 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
616 if test $ac_cv_func_getgroups = no; then
617 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
620 # Run the program to test the functionality of the system-supplied
621 # getgroups function only if there is such a function.
622 if test $ac_cv_func_getgroups = yes; then
623 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
624 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
625 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
626 return getgroups (0, 0) == -1;]])],
627 [ac_cv_func_getgroups_works=yes],
628 [ac_cv_func_getgroups_works=no],
629 [ac_cv_func_getgroups_works=no])
631 if test $ac_cv_func_getgroups_works = yes; then
632 AC_DEFINE(HAVE_GETGROUPS, 1,
633 [Define to 1 if your system has a working `getgroups' function.])
637 ])# AC_FUNC_GETGROUPS
640 # _AC_LIBOBJ_GETLOADAVG
641 # ---------------------
642 # Set up the AC_LIBOBJ replacement of `getloadavg'.
643 m4_define([_AC_LIBOBJ_GETLOADAVG],
644 [AC_LIBOBJ(getloadavg)
645 AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
646 # Figure out what our getloadavg.c needs.
648 AC_CHECK_HEADER(sys/dg_sys_info.h,
650 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
651 AC_CHECK_LIB(dgc, dg_sys_info)])
653 AC_CHECK_HEADER(locale.h)
654 AC_CHECK_FUNCS(setlocale)
656 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
657 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
658 # Irix 4.0.5F has the header but not the library.
659 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
661 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
664 if test $ac_have_func = no; then
665 AC_CHECK_HEADER(inq_stats/cpustats.h,
667 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
668 AC_DEFINE(UMAX4_3, 1,
669 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
670 instead of <sys/cpustats.h>.])])
673 if test $ac_have_func = no; then
674 AC_CHECK_HEADER(sys/cpustats.h,
675 [ac_have_func=yes; AC_DEFINE(UMAX)])
678 if test $ac_have_func = no; then
679 AC_CHECK_HEADERS(mach/mach.h)
682 AC_CHECK_HEADERS(nlist.h,
683 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
684 [AC_DEFINE(NLIST_NAME_UNION, 1,
685 [Define to 1 if your `struct nlist' has an
686 `n_un' member. Obsolete, depend on
687 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
688 [@%:@include <nlist.h>])
690 ])# _AC_LIBOBJ_GETLOADAVG
695 AC_DEFUN([AC_FUNC_GETLOADAVG],
696 [ac_have_func=no # yes means we've found a way to get the load average.
698 # Make sure getloadavg.c is where it belongs, at configure-time.
699 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
700 AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
704 # Check for getloadavg, but be sure not to touch the cache variable.
705 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
707 # On HPUX9, an unprivileged user can get load averages through this function.
708 AC_CHECK_FUNCS(pstat_getdynamic)
710 # Solaris has libkstat which does not require root.
711 AC_CHECK_LIB(kstat, kstat_open)
712 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
714 # Some systems with -lutil have (and need) -lkvm as well, some do not.
715 # On Solaris, -lkvm requires nlist from -lelf, so check that first
716 # to get the right answer into the cache.
717 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
718 if test $ac_have_func = no; then
719 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
721 if test $ac_have_func = no; then
722 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
723 # Check for the 4.4BSD definition of getloadavg.
724 AC_CHECK_LIB(util, getloadavg,
725 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
728 if test $ac_have_func = no; then
729 # There is a commonly available library for RS/6000 AIX.
730 # Since it is not a standard part of AIX, it might be installed locally.
731 ac_getloadavg_LIBS=$LIBS
732 LIBS="-L/usr/local/lib $LIBS"
733 AC_CHECK_LIB(getloadavg, getloadavg,
734 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
737 # Make sure it is really in the library, if we think we found it,
738 # otherwise set up the replacement function.
739 AC_CHECK_FUNCS(getloadavg, [],
740 [_AC_LIBOBJ_GETLOADAVG])
742 # Some definitions of getloadavg require that the program be installed setgid.
743 AC_CACHE_CHECK(whether getloadavg requires setgid,
744 ac_cv_func_getloadavg_setgid,
745 [AC_EGREP_CPP([Yowza Am I SETGID yet],
746 [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
747 #ifdef LDAV_PRIVILEGED
748 Yowza Am I SETGID yet
750 ac_cv_func_getloadavg_setgid=yes,
751 ac_cv_func_getloadavg_setgid=no)])
752 if test $ac_cv_func_getloadavg_setgid = yes; then
754 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
755 [Define to 1 if the `getloadavg' function needs to be run setuid
760 AC_SUBST(NEED_SETGID)dnl
762 if test $ac_cv_func_getloadavg_setgid = yes; then
763 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
764 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
765 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
766 # If we got an error (system does not support symlinks), try without -L.
767 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
768 ac_cv_group_kmem=`AS_ECHO(["$ac_ls_output"]) \
769 | sed -ne ['s/[ ][ ]*/ /g;
770 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
773 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
775 if test "x$ac_save_LIBS" = x; then
776 GETLOADAVG_LIBS=$LIBS
778 GETLOADAVG_LIBS=`AS_ECHO(["$LIBS"]) | sed "s|$ac_save_LIBS||"`
782 AC_SUBST(GETLOADAVG_LIBS)dnl
783 ])# AC_FUNC_GETLOADAVG
788 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
793 AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
794 AC_DEFUN([AC_FUNC_GETMNTENT],
795 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
796 # -lseq on Dynix/PTX, -lgen on Unixware.
797 AC_SEARCH_LIBS(getmntent, [sun seq gen],
798 [ac_cv_func_getmntent=yes
799 AC_DEFINE([HAVE_GETMNTENT], 1,
800 [Define to 1 if you have the `getmntent' function.])],
801 [ac_cv_func_getmntent=no])
807 # Figure out whether getpgrp requires zero arguments.
808 AC_DEFUN([AC_FUNC_GETPGRP],
809 [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
810 ac_cv_func_getpgrp_void,
811 [# Use it with a single arg.
812 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
813 [ac_cv_func_getpgrp_void=no],
814 [ac_cv_func_getpgrp_void=yes])
816 if test $ac_cv_func_getpgrp_void = yes; then
817 AC_DEFINE(GETPGRP_VOID, 1,
818 [Define to 1 if the `getpgrp' function requires zero arguments.])
823 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
824 # -------------------------------------
825 # When cross-compiling, be pessimistic so we will end up using the
826 # replacement version of lstat that checks for trailing slashes and
827 # calls lstat a second time when necessary.
828 AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
829 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
831 [whether lstat dereferences a symlink specified with a trailing slash],
832 [ac_cv_func_lstat_dereferences_slashed_symlink],
833 [rm -f conftest.sym conftest.file
835 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
836 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
838 /* Linux will dereference the symlink and fail.
839 That is better in the sense that it means we will not
840 have to compile and use the lstat wrapper. */
841 return lstat ("conftest.sym/", &sbuf) == 0;])],
842 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
843 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
844 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
846 # If the `ln -s' command failed, then we probably don't even
847 # have an lstat function.
848 ac_cv_func_lstat_dereferences_slashed_symlink=no
850 rm -f conftest.sym conftest.file
853 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
854 AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
855 [Define to 1 if `lstat' dereferences a symlink specified
856 with a trailing slash.])
858 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
864 # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
865 # ------------------------------------
866 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
867 AC_DEFUN([_AC_FUNC_MALLOC_IF],
868 [AC_REQUIRE([AC_HEADER_STDC])dnl
869 AC_CHECK_HEADERS(stdlib.h)
870 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
873 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
879 [return ! malloc (0);])],
880 [ac_cv_func_malloc_0_nonnull=yes],
881 [ac_cv_func_malloc_0_nonnull=no],
882 [ac_cv_func_malloc_0_nonnull=no])])
883 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
884 ])# _AC_FUNC_MALLOC_IF
889 # Report whether `malloc (0)' properly handled, and replace malloc if
891 AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
892 AC_DEFUN([AC_FUNC_MALLOC],
894 [AC_DEFINE([HAVE_MALLOC], 1,
895 [Define to 1 if your system has a GNU libc compatible `malloc'
896 function, and to 0 otherwise.])],
897 [AC_DEFINE([HAVE_MALLOC], 0)
899 AC_DEFINE([malloc], [rpl_malloc],
900 [Define to rpl_malloc if the replacement function should be used.])])
906 AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
907 AC_DEFUN([AC_FUNC_MBRTOWC],
909 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
913 [[@%:@include <wchar.h>]],
918 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
919 ac_cv_func_mbrtowc=yes,
920 ac_cv_func_mbrtowc=no)])
921 if test $ac_cv_func_mbrtowc = yes; then
922 AC_DEFINE([HAVE_MBRTOWC], 1,
923 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
930 AC_DEFUN([AC_FUNC_MEMCMP],
931 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
932 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
933 /* Some versions of memcmp are not 8-bit clean. */
934 char c0 = '\100', c1 = '\200', c2 = '\201';
935 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
938 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
939 or more and with at least one buffer not starting on a 4-byte boundary.
940 William Lewis provided this test program. */
945 for (i = 0; i < 4; i++)
949 strcpy (a, "--------01111111");
950 strcpy (b, "--------10000000");
951 if (memcmp (a, b, 16) >= 0)
957 [ac_cv_func_memcmp_working=yes],
958 [ac_cv_func_memcmp_working=no],
959 [ac_cv_func_memcmp_working=no])])
960 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
966 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
967 AC_DEFUN([AC_FUNC_MKTIME],
968 [AC_REQUIRE([AC_HEADER_TIME])dnl
969 AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
970 AC_CHECK_FUNCS_ONCE(alarm)
971 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
972 [AC_RUN_IFELSE([AC_LANG_SOURCE(
973 [[/* Test program from Paul Eggert and Tony Leneis. */
974 #ifdef TIME_WITH_SYS_TIME
975 # include <sys/time.h>
978 # ifdef HAVE_SYS_TIME_H
979 # include <sys/time.h>
993 # define alarm(X) /* empty */
996 /* Work around redefinition to rpl_putenv by other config tests. */
999 static time_t time_t_max;
1000 static time_t time_t_min;
1002 /* Values we'll use to set the TZ environment variable. */
1003 static char *tz_strings[] = {
1004 (char *) 0, "TZ=GMT0", "TZ=JST-9",
1005 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
1007 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
1009 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
1010 Based on a problem report from Andreas Jaeger. */
1012 spring_forward_gap ()
1014 /* glibc (up to about 1998-10-07) failed this test. */
1017 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1018 instead of "TZ=America/Vancouver" in order to detect the bug even
1019 on systems that don't support the Olson extension, or don't have the
1020 full zoneinfo tables installed. */
1021 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1030 return mktime (&tm) != (time_t) -1;
1038 return ! (lt = localtime (&now)) || mktime (lt) == now;
1045 return (mktime_test1 (now)
1046 && mktime_test1 ((time_t) (time_t_max - now))
1047 && mktime_test1 ((time_t) (time_t_min + now)));
1053 /* Based on code from Ariel Faigon. */
1063 return tm.tm_mon == 2 && tm.tm_mday == 31;
1072 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
1074 if (now != (time_t) -1)
1076 struct tm *lt = localtime (&now);
1078 && lt->tm_year == tm.tm_year
1079 && lt->tm_mon == tm.tm_mon
1080 && lt->tm_mday == tm.tm_mday
1081 && lt->tm_hour == tm.tm_hour
1082 && lt->tm_min == tm.tm_min
1083 && lt->tm_sec == tm.tm_sec
1084 && lt->tm_yday == tm.tm_yday
1085 && lt->tm_wday == tm.tm_wday
1086 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
1087 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
1096 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
1097 ignoring leap seconds. */
1098 unsigned long int answer = 2527315200UL;
1102 tm.tm_year = 2050 - 1900;
1105 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
1108 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1109 instead of "TZ=America/Vancouver" in order to detect the bug even
1110 on systems that don't support the Olson extension, or don't have the
1111 full zoneinfo tables installed. */
1112 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1116 /* Check that the result is either a failure, or close enough
1117 to the correct answer that we can assume the discrepancy is
1118 due to leap seconds. */
1119 return (t == (time_t) -1
1120 || (0 < t && answer - 120 <= t && t <= answer + 120));
1129 /* This test makes some buggy mktime implementations loop.
1130 Give up after 60 seconds; a mktime slower than that
1131 isn't worth using anyway. */
1136 t = (time_t_max << 1) + 1;
1137 if (t <= time_t_max)
1141 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
1143 delta = time_t_max / 997; /* a suitable prime number */
1144 for (i = 0; i < N_STRINGS; i++)
1147 putenv (tz_strings[i]);
1149 for (t = 0; t <= time_t_max - delta; t += delta)
1150 if (! mktime_test (t))
1152 if (! (mktime_test ((time_t) 1)
1153 && mktime_test ((time_t) (60 * 60))
1154 && mktime_test ((time_t) (60 * 60 * 24))))
1157 for (j = 1; ; j <<= 1)
1158 if (! bigtime_test (j))
1160 else if (INT_MAX / 2 < j)
1162 if (! bigtime_test (INT_MAX))
1165 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
1167 [ac_cv_func_working_mktime=yes],
1168 [ac_cv_func_working_mktime=no],
1169 [ac_cv_func_working_mktime=no])])
1170 if test $ac_cv_func_working_mktime = no; then
1176 # AU::AM_FUNC_MKTIME
1177 # ------------------
1178 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
1183 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
1184 AC_DEFUN([AC_FUNC_MMAP],
1185 [AC_CHECK_HEADERS(stdlib.h unistd.h)
1186 AC_CHECK_FUNCS(getpagesize)
1187 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
1188 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
1189 [[/* malloc might have been renamed as rpl_malloc. */
1192 /* Thanks to Mike Haertel and Jim Avera for this test.
1193 Here is a matrix of mmap possibilities:
1194 mmap private not fixed
1195 mmap private fixed at somewhere currently unmapped
1196 mmap private fixed at somewhere already mapped
1197 mmap shared not fixed
1198 mmap shared fixed at somewhere currently unmapped
1199 mmap shared fixed at somewhere already mapped
1200 For private mappings, we should verify that changes cannot be read()
1201 back from the file, nor mmap's back from the file at a different
1202 address. (There have been systems where private was not correctly
1203 implemented like the infamous i386 svr4.0, and systems where the
1204 VM page cache was not coherent with the file system buffer cache
1205 like early versions of FreeBSD and possibly contemporary NetBSD.)
1206 For shared mappings, we should conversely verify that changes get
1207 propagated back to all the places they're supposed to be.
1209 Grep wants private fixed already mapped.
1210 The main things grep needs to know about mmap are:
1211 * does it exist and is it safe to write into the mmap'd area
1212 * how to use it (BSD variants) */
1215 #include <sys/mman.h>
1217 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
1221 /* This mess was copied from the GNU getpagesize.h. */
1222 #ifndef HAVE_GETPAGESIZE
1223 /* Assume that all systems that can run configure have sys/param.h. */
1224 # ifndef HAVE_SYS_PARAM_H
1225 # define HAVE_SYS_PARAM_H 1
1228 # ifdef _SC_PAGESIZE
1229 # define getpagesize() sysconf(_SC_PAGESIZE)
1230 # else /* no _SC_PAGESIZE */
1231 # ifdef HAVE_SYS_PARAM_H
1232 # include <sys/param.h>
1233 # ifdef EXEC_PAGESIZE
1234 # define getpagesize() EXEC_PAGESIZE
1235 # else /* no EXEC_PAGESIZE */
1237 # define getpagesize() NBPG * CLSIZE
1240 # endif /* no CLSIZE */
1241 # else /* no NBPG */
1243 # define getpagesize() NBPC
1244 # else /* no NBPC */
1246 # define getpagesize() PAGESIZE
1247 # endif /* PAGESIZE */
1248 # endif /* no NBPC */
1249 # endif /* no NBPG */
1250 # endif /* no EXEC_PAGESIZE */
1251 # else /* no HAVE_SYS_PARAM_H */
1252 # define getpagesize() 8192 /* punt totally */
1253 # endif /* no HAVE_SYS_PARAM_H */
1254 # endif /* no _SC_PAGESIZE */
1256 #endif /* no HAVE_GETPAGESIZE */
1261 char *data, *data2, *data3;
1265 pagesize = getpagesize ();
1267 /* First, make a file with some known garbage in it. */
1268 data = (char *) malloc (pagesize);
1271 for (i = 0; i < pagesize; ++i)
1272 *(data + i) = rand ();
1274 fd = creat ("conftest.mmap", 0600);
1277 if (write (fd, data, pagesize) != pagesize)
1281 /* Next, try to mmap the file at a fixed address which already has
1282 something else allocated at it. If we can, also make sure that
1283 we see the same garbage. */
1284 fd = open ("conftest.mmap", O_RDWR);
1287 data2 = (char *) malloc (2 * pagesize);
1290 data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1);
1291 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1292 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1294 for (i = 0; i < pagesize; ++i)
1295 if (*(data + i) != *(data2 + i))
1298 /* Finally, make sure that changes to the mapped area do not
1299 percolate back to the file as seen by read(). (This is a bug on
1300 some variants of i386 svr4.0.) */
1301 for (i = 0; i < pagesize; ++i)
1302 *(data2 + i) = *(data2 + i) + 1;
1303 data3 = (char *) malloc (pagesize);
1306 if (read (fd, data3, pagesize) != pagesize)
1308 for (i = 0; i < pagesize; ++i)
1309 if (*(data + i) != *(data3 + i))
1314 [ac_cv_func_mmap_fixed_mapped=yes],
1315 [ac_cv_func_mmap_fixed_mapped=no],
1316 [ac_cv_func_mmap_fixed_mapped=no])])
1317 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1318 AC_DEFINE(HAVE_MMAP, 1,
1319 [Define to 1 if you have a working `mmap' system call.])
1327 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1332 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1333 AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
1334 AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
1335 AC_DEFUN([AC_FUNC_OBSTACK],
1336 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1337 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1339 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1340 [@%:@include "obstack.h"]],
1341 [[struct obstack mem;
1342 @%:@define obstack_chunk_alloc malloc
1343 @%:@define obstack_chunk_free free
1344 obstack_init (&mem);
1345 obstack_free (&mem, 0);]])],
1346 [ac_cv_func_obstack=yes],
1347 [ac_cv_func_obstack=no])])
1348 if test $ac_cv_func_obstack = yes; then
1349 AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1356 # AU::AM_FUNC_OBSTACK
1357 # -------------------
1358 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1362 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
1363 # -------------------------------------
1364 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
1365 AC_DEFUN([_AC_FUNC_REALLOC_IF],
1366 [AC_REQUIRE([AC_HEADER_STDC])dnl
1367 AC_CHECK_HEADERS(stdlib.h)
1368 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
1371 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1372 # include <stdlib.h>
1377 [return ! realloc (0, 0);])],
1378 [ac_cv_func_realloc_0_nonnull=yes],
1379 [ac_cv_func_realloc_0_nonnull=no],
1380 [ac_cv_func_realloc_0_nonnull=no])])
1381 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
1387 # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
1389 AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
1390 AC_DEFUN([AC_FUNC_REALLOC],
1391 [_AC_FUNC_REALLOC_IF(
1392 [AC_DEFINE([HAVE_REALLOC], 1,
1393 [Define to 1 if your system has a GNU libc compatible `realloc'
1394 function, and to 0 otherwise.])],
1395 [AC_DEFINE([HAVE_REALLOC], 0)
1396 AC_LIBOBJ([realloc])
1397 AC_DEFINE([realloc], [rpl_realloc],
1398 [Define to rpl_realloc if the replacement function should be used.])])
1402 # AC_FUNC_SELECT_ARGTYPES
1403 # -----------------------
1404 # Determine the correct type to be passed to each of the `select'
1405 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1406 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1407 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1408 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1409 AC_CACHE_CHECK([types of arguments for select],
1410 [ac_cv_func_select_args],
1411 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1412 for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
1413 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1416 [AC_INCLUDES_DEFAULT
1417 #ifdef HAVE_SYS_SELECT_H
1418 # include <sys/select.h>
1420 #ifdef HAVE_SYS_SOCKET_H
1421 # include <sys/socket.h>
1424 [extern int select ($ac_arg1,
1425 $ac_arg234, $ac_arg234, $ac_arg234,
1427 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1431 # Provide a safe default value.
1432 : ${ac_cv_func_select_args='int,int *,struct timeval *'}
1434 ac_save_IFS=$IFS; IFS=','
1435 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1438 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1439 [Define to the type of arg 1 for `select'.])
1440 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1441 [Define to the type of args 2, 3 and 4 for `select'.])
1442 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1443 [Define to the type of arg 5 for `select'.])
1445 ])# AC_FUNC_SELECT_ARGTYPES
1450 AC_DEFUN([AC_FUNC_SETPGRP],
1451 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1453 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1454 [/* If this system has a BSD-style setpgrp which takes arguments,
1455 setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1456 exit successfully. */
1457 return setpgrp (1,1) != -1;])],
1458 [ac_cv_func_setpgrp_void=no],
1459 [ac_cv_func_setpgrp_void=yes],
1460 [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1461 if test $ac_cv_func_setpgrp_void = yes; then
1462 AC_DEFINE(SETPGRP_VOID, 1,
1463 [Define to 1 if the `setpgrp' function takes no argument.])
1468 # _AC_FUNC_STAT(STAT | LSTAT)
1469 # ---------------------------
1470 # Determine whether stat or lstat have the bug that it succeeds when
1471 # given the zero-length file name argument. The stat and lstat from
1472 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1474 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1475 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1477 m4_define([_AC_FUNC_STAT],
1478 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1479 AC_CACHE_CHECK([whether $1 accepts an empty string],
1480 [ac_cv_func_$1_empty_string_bug],
1481 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1483 return $1 ("", &sbuf) == 0;]])],
1484 [ac_cv_func_$1_empty_string_bug=no],
1485 [ac_cv_func_$1_empty_string_bug=yes],
1486 [ac_cv_func_$1_empty_string_bug=yes])])
1487 if test $ac_cv_func_$1_empty_string_bug = yes; then
1489 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1490 [Define to 1 if `$1' has the bug that it succeeds when
1491 given the zero-length file name argument.])
1496 # AC_FUNC_STAT & AC_FUNC_LSTAT
1497 # ----------------------------
1498 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1499 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1504 m4_define([_AC_LIBOBJ_STRTOD],
1507 if test $ac_cv_func_pow = no; then
1508 AC_CHECK_LIB(m, pow,
1510 [AC_MSG_WARN([cannot find library containing definition of pow])])
1512 ])# _AC_LIBOBJ_STRTOD
1517 AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
1518 AC_DEFUN([AC_FUNC_STRTOD],
1519 [AC_SUBST(POW_LIB)dnl
1520 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1521 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1522 ]AC_INCLUDES_DEFAULT[
1530 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1531 char *string = " +69";
1534 value = strtod (string, &term);
1535 if (value != 69 || term != (string + 4))
1540 /* Under Solaris 2.4, strtod returns the wrong value for the
1541 terminating character under some conditions. */
1542 char *string = "NaN";
1544 strtod (string, &term);
1545 if (term != string && *(term - 1) == 0)
1551 ac_cv_func_strtod=yes,
1552 ac_cv_func_strtod=no,
1553 ac_cv_func_strtod=no)])
1554 if test $ac_cv_func_strtod = no; then
1562 AC_DEFUN([AC_FUNC_STRTOLD],
1564 AC_CACHE_CHECK([whether strtold conforms to C99],
1565 [ac_cv_func_strtold],
1568 [[/* On HP-UX before 11.23, strtold returns a struct instead of
1569 long double. Reject implementations like that, by requiring
1570 compatibility with the C99 prototype. */
1571 # include <stdlib.h>
1572 static long double (*p) (char const *, char **) = strtold;
1574 test (char const *nptr, char **endptr)
1577 r = strtold (nptr, endptr);
1580 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
1581 [ac_cv_func_strtold=yes],
1582 [ac_cv_func_strtold=no])])
1583 if test $ac_cv_func_strtold = yes; then
1584 AC_DEFINE([HAVE_STRTOLD], 1,
1585 [Define to 1 if strtold exists and conforms to C99.])
1590 # AU::AM_FUNC_STRTOD
1591 # ------------------
1592 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1595 # AC_FUNC_STRERROR_R
1596 # ------------------
1597 AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
1598 AC_DEFUN([AC_FUNC_STRERROR_R],
1599 [AC_CHECK_DECLS([strerror_r])
1600 AC_CHECK_FUNCS([strerror_r])
1601 AC_CACHE_CHECK([whether strerror_r returns char *],
1602 ac_cv_func_strerror_r_char_p,
1604 ac_cv_func_strerror_r_char_p=no
1605 if test $ac_cv_have_decl_strerror_r = yes; then
1606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1609 char x = *strerror_r (0, buf, sizeof buf);
1610 char *p = strerror_r (0, buf, sizeof buf);
1613 ac_cv_func_strerror_r_char_p=yes)
1615 # strerror_r is not declared. Choose between
1616 # systems that have relatively inaccessible declarations for the
1617 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1618 # former has a strerror_r that returns char*, while the latter
1619 # has a strerror_r that returns `int'.
1620 # This test should segfault on the DEC system.
1621 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1622 extern char *strerror_r ();],
1624 char x = *strerror_r (0, buf, sizeof buf);
1625 return ! isalpha (x);]])],
1626 ac_cv_func_strerror_r_char_p=yes, , :)
1629 if test $ac_cv_func_strerror_r_char_p = yes; then
1630 AC_DEFINE([STRERROR_R_CHAR_P], 1,
1631 [Define to 1 if strerror_r returns char *.])
1633 ])# AC_FUNC_STRERROR_R
1638 AC_DEFUN([AC_FUNC_STRFTIME],
1639 [AC_CHECK_FUNCS(strftime, [],
1640 [# strftime is in -lintl on SCO UNIX.
1641 AC_CHECK_LIB(intl, strftime,
1642 [AC_DEFINE(HAVE_STRFTIME)
1643 LIBS="-lintl $LIBS"])])dnl
1644 ])# AC_FUNC_STRFTIME
1649 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
1650 AC_DEFUN([AC_FUNC_STRNLEN],
1651 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
1652 AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1653 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1655 #define S_LEN (sizeof S - 1)
1657 /* At least one implementation is buggy: that of AIX 4.3 would
1658 give strnlen (S, 1) == 3. */
1661 for (i = 0; i < S_LEN + 1; ++i)
1663 int expected = i <= S_LEN ? i : S_LEN;
1664 if (strnlen (S, i) != expected)
1669 [ac_cv_func_strnlen_working=yes],
1670 [ac_cv_func_strnlen_working=no],
1671 [ac_cv_func_strnlen_working=no])])
1672 test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1676 # AC_FUNC_SETVBUF_REVERSED
1677 # ------------------------
1678 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1679 [AC_DIAGNOSE([obsolete],
1680 [The macro `$0' is obsolete. Remove it and all references to SETVBUF_REVERSED.])dnl
1681 AC_CACHE_VAL([ac_cv_func_setvbuf_reversed], [ac_cv_func_setvbuf_reversed=no])
1682 ])# AC_FUNC_SETVBUF_REVERSED
1685 # AU::AC_SETVBUF_REVERSED
1686 # -----------------------
1687 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1692 AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
1693 AC_DEFUN([AC_FUNC_STRCOLL],
1694 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1695 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1696 [[return (strcoll ("abc", "def") >= 0 ||
1697 strcoll ("ABC", "DEF") >= 0 ||
1698 strcoll ("123", "456") >= 0)]])],
1699 ac_cv_func_strcoll_works=yes,
1700 ac_cv_func_strcoll_works=no,
1701 ac_cv_func_strcoll_works=no)])
1702 if test $ac_cv_func_strcoll_works = yes; then
1703 AC_DEFINE(HAVE_STRCOLL, 1,
1704 [Define to 1 if you have the `strcoll' function and it is properly
1712 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1715 # AC_FUNC_UTIME_NULL
1716 # ------------------
1717 AC_DEFUN([AC_FUNC_UTIME_NULL],
1718 [AC_CHECK_HEADERS_ONCE(utime.h)
1719 AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1720 [rm -f conftest.data; >conftest.data
1721 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1722 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1727 return ! (stat ("conftest.data", &s) == 0
1728 && utime ("conftest.data", 0) == 0
1729 && stat ("conftest.data", &t) == 0
1730 && t.st_mtime >= s.st_mtime
1731 && t.st_mtime - s.st_mtime < 120);]])],
1732 ac_cv_func_utime_null=yes,
1733 ac_cv_func_utime_null=no,
1734 ac_cv_func_utime_null=no)])
1735 if test $ac_cv_func_utime_null = yes; then
1736 AC_DEFINE(HAVE_UTIME_NULL, 1,
1737 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1741 ])# AC_FUNC_UTIME_NULL
1746 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1751 AN_FUNCTION([fork], [AC_FUNC_FORK])
1752 AN_FUNCTION([vfork], [AC_FUNC_FORK])
1753 AC_DEFUN([AC_FUNC_FORK],
1754 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1755 AC_CHECK_HEADERS(vfork.h)
1756 AC_CHECK_FUNCS(fork vfork)
1757 if test "x$ac_cv_func_fork" = xyes; then
1760 ac_cv_func_fork_works=$ac_cv_func_fork
1762 if test "x$ac_cv_func_fork_works" = xcross; then
1764 *-*-amigaos* | *-*-msdosdjgpp*)
1765 # Override, as these systems have only a dummy fork() stub
1766 ac_cv_func_fork_works=no
1769 ac_cv_func_fork_works=yes
1772 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1774 ac_cv_func_vfork_works=$ac_cv_func_vfork
1775 if test "x$ac_cv_func_vfork" = xyes; then
1778 if test "x$ac_cv_func_fork_works" = xcross; then
1779 ac_cv_func_vfork_works=$ac_cv_func_vfork
1780 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1783 if test "x$ac_cv_func_vfork_works" = xyes; then
1784 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1786 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1788 if test "x$ac_cv_func_fork_works" = xyes; then
1789 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1796 AC_DEFUN([_AC_FUNC_FORK],
1797 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1799 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1801 /* By Ruediger Kuhlmann. */
1804 [ac_cv_func_fork_works=yes],
1805 [ac_cv_func_fork_works=no],
1806 [ac_cv_func_fork_works=cross])])]
1812 AC_DEFUN([_AC_FUNC_VFORK],
1813 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1814 [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
1815 ]AC_INCLUDES_DEFAULT[
1816 #include <sys/wait.h>
1820 /* On some sparc systems, changes by the child to local and incoming
1821 argument registers are propagated back to the parent. The compiler
1822 is told about this with #include <vfork.h>, but some compilers
1823 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1824 static variable whose address is put into a register that is
1825 clobbered by the vfork. */
1828 sparc_address_test (int arg)
1830 sparc_address_test (arg) int arg;
1851 pid_t parent = getpid ();
1854 sparc_address_test (0);
1859 /* Here is another test for sparc vfork register problems. This
1860 test uses lots of local variables, at least as many local
1861 variables as main has allocated so far including compiler
1862 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1863 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1864 reuse the register of parent for one of the local variables,
1865 since it will think that parent can't possibly be used any more
1866 in this routine. Assigning to the local variable will thus
1867 munge parent in the parent process. */
1869 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1870 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1871 /* Convince the compiler that p..p7 are live; otherwise, it might
1872 use the same hardware register for all 8 local variables. */
1873 if (p != p1 || p != p2 || p != p3 || p != p4
1874 || p != p5 || p != p6 || p != p7)
1877 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1878 from child file descriptors. If the child closes a descriptor
1879 before it execs or exits, this munges the parent's descriptor
1880 as well. Test for this by closing stdout in the child. */
1881 _exit(close(fileno(stdout)) != 0);
1886 while (wait(&status) != child)
1889 /* Was there some problem with vforking? */
1892 /* Did the child fail? (This shouldn't happen.) */
1895 /* Did the vfork/compiler bug occur? */
1896 || parent != getpid()
1898 /* Did the file descriptor bug occur? */
1899 || fstat(fileno(stdout), &st) != 0
1903 [ac_cv_func_vfork_works=yes],
1904 [ac_cv_func_vfork_works=no],
1905 [ac_cv_func_vfork_works=cross])])
1911 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1915 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1920 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1921 # That the logical name!
1922 AC_DEFUN([AC_FUNC_VPRINTF],
1923 [AC_CHECK_FUNCS(vprintf, []
1924 [AC_CHECK_FUNC(_doprnt,
1925 [AC_DEFINE(HAVE_DOPRNT, 1,
1926 [Define to 1 if you don't have `vprintf' but do have
1933 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1938 # Don't bother too hard maintaining this macro, as it's obsoleted.
1939 # We don't AU define it, since we don't have any alternative to propose,
1940 # any invocation should be removed, and the code adjusted.
1941 AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
1942 AC_DEFUN([AC_FUNC_WAIT3],
1943 [AC_DIAGNOSE([obsolete],
1944 [$0: `wait3' has been removed from POSIX.
1945 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1946 AC_CACHE_CHECK([for wait3 that fills in rusage],
1947 [ac_cv_func_wait3_rusage],
1948 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1949 [AC_INCLUDES_DEFAULT[
1950 #include <sys/time.h>
1951 #include <sys/resource.h>
1952 #include <sys/wait.h>
1953 /* HP-UX has wait3 but does not fill in rusage at all. */
1959 /* Use a field that we can force nonzero --
1960 voluntary context switches.
1961 For systems like NeXT and OSF/1 that don't set it,
1962 also use the system CPU time. And page faults (I/O) for Linux. */
1964 r.ru_stime.tv_sec = 0;
1965 r.ru_stime.tv_usec = 0;
1966 r.ru_majflt = r.ru_minflt = 0;
1969 case 0: /* Child. */
1970 sleep(1); /* Give up the CPU. */
1973 case -1: /* What can we do? */
1976 default: /* Parent. */
1978 /* Avoid "text file busy" from rm on fast HP-UX machines. */
1980 return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1981 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1984 [ac_cv_func_wait3_rusage=yes],
1985 [ac_cv_func_wait3_rusage=no],
1986 [ac_cv_func_wait3_rusage=no])])
1987 if test $ac_cv_func_wait3_rusage = yes; then
1988 AC_DEFINE(HAVE_WAIT3, 1,
1989 [Define to 1 if you have the `wait3' system call.
1990 Deprecated, you should no longer depend upon `wait3'.])
1997 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])