1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 # Free Software Foundation, Inc.
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 2, or (at your option)
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, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
55 # 1. Generic tests for functions.
56 # 2. Functions to check with AC_CHECK_FUNCS
57 # 3. Tests for specific functions.
60 ## -------------------------------- ##
61 ## 1. Generic tests for functions. ##
62 ## -------------------------------- ##
65 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
66 # -----------------------------------------------------------------
67 AC_DEFUN([AC_CHECK_FUNC],
68 [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
69 AC_CACHE_CHECK([for $1], [ac_var],
70 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
71 [AS_VAR_SET([ac_var], [yes])],
72 [AS_VAR_SET([ac_var], [no])])])
73 AS_VAR_IF([ac_var], [yes], [$2], [$3])dnl
74 AS_VAR_POPDEF([ac_var])dnl
78 # _AH_CHECK_FUNCS(FUNCTION...)
79 # ----------------------------
80 m4_define([_AH_CHECK_FUNCS],
81 [m4_foreach_w([AC_Func], [$1],
82 [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Func])),
83 [Define to 1 if you have the `]m4_defn([AC_Func])[' function.])])])
86 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
87 # ---------------------------------------------------------------------
88 AC_DEFUN([AC_CHECK_FUNCS],
89 [_AH_CHECK_FUNCS([$1])dnl
92 AC_CHECK_FUNC($ac_func,
93 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2],
99 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
100 # --------------------------------
101 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
103 _AH_CHECK_FUNCS([$1])
104 m4_foreach_w([AC_Func], [$1],
105 [AC_DEFUN([_AC_Func_]m4_defn([AC_Func]),
106 [m4_divert_text([INIT_PREPARE],
107 [AS_VAR_APPEND([ac_func_list], [" AC_Func"])])
108 _AC_FUNCS_EXPANSION])
109 AC_REQUIRE([_AC_Func_]m4_defn([AC_Func]))])
111 m4_define([_AC_FUNCS_EXPANSION],
113 m4_divert_text([DEFAULTS], [ac_func_list=])
114 AC_CHECK_FUNCS([$ac_func_list])
115 m4_define([_AC_FUNCS_EXPANSION], [])
119 # AC_REPLACE_FUNCS(FUNCTION...)
120 # -----------------------------
121 AC_DEFUN([AC_REPLACE_FUNCS],
122 [m4_foreach_w([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
123 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
127 # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
128 # ------------------------------------------------------------
129 # Try to link a program that calls FUNC, handling GCC builtins. If
130 # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
131 # ACTION-IF-NOT-FOUND.
132 AC_DEFUN([AC_TRY_LINK_FUNC],
133 [AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
138 AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
143 AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
148 ## ------------------------------------------- ##
149 ## 2. Functions to check with AC_CHECK_FUNCS. ##
150 ## ------------------------------------------- ##
152 AN_FUNCTION([__argz_count], [AC_CHECK_FUNCS])
153 AN_FUNCTION([__argz_next], [AC_CHECK_FUNCS])
154 AN_FUNCTION([__argz_stringify], [AC_CHECK_FUNCS])
155 AN_FUNCTION([__fpending], [AC_CHECK_FUNCS])
156 AN_FUNCTION([acl], [AC_CHECK_FUNCS])
157 AN_FUNCTION([alarm], [AC_CHECK_FUNCS])
158 AN_FUNCTION([atexit], [AC_CHECK_FUNCS])
159 AN_FUNCTION([btowc], [AC_CHECK_FUNCS])
160 AN_FUNCTION([bzero], [AC_CHECK_FUNCS])
161 AN_FUNCTION([clock_gettime], [AC_CHECK_FUNCS])
162 AN_FUNCTION([doprnt], [AC_CHECK_FUNCS])
163 AN_FUNCTION([dup2], [AC_CHECK_FUNCS])
164 AN_FUNCTION([endgrent], [AC_CHECK_FUNCS])
165 AN_FUNCTION([endpwent], [AC_CHECK_FUNCS])
166 AN_FUNCTION([euidaccess], [AC_CHECK_FUNCS])
167 AN_FUNCTION([fchdir], [AC_CHECK_FUNCS])
168 AN_FUNCTION([fdatasync], [AC_CHECK_FUNCS])
169 AN_FUNCTION([fesetround], [AC_CHECK_FUNCS])
170 AN_FUNCTION([floor], [AC_CHECK_FUNCS])
171 AN_FUNCTION([fs_stat_dev], [AC_CHECK_FUNCS])
172 AN_FUNCTION([ftime], [AC_CHECK_FUNCS])
173 AN_FUNCTION([ftruncate], [AC_CHECK_FUNCS])
174 AN_FUNCTION([getcwd], [AC_CHECK_FUNCS])
175 AN_FUNCTION([getdelim], [AC_CHECK_FUNCS])
176 AN_FUNCTION([gethostbyaddr], [AC_CHECK_FUNCS])
177 AN_FUNCTION([gethostbyname], [AC_CHECK_FUNCS])
178 AN_FUNCTION([gethostname], [AC_CHECK_FUNCS])
179 AN_FUNCTION([gethrtime], [AC_CHECK_FUNCS])
180 AN_FUNCTION([getmntent], [AC_CHECK_FUNCS])
181 AN_FUNCTION([getmntinfo], [AC_CHECK_FUNCS])
182 AN_FUNCTION([getpagesize], [AC_CHECK_FUNCS])
183 AN_FUNCTION([getpass], [AC_CHECK_FUNCS])
184 AN_FUNCTION([getspnam], [AC_CHECK_FUNCS])
185 AN_FUNCTION([gettimeofday], [AC_CHECK_FUNCS])
186 AN_FUNCTION([getusershell], [AC_CHECK_FUNCS])
187 AN_FUNCTION([hasmntopt], [AC_CHECK_FUNCS])
188 AN_FUNCTION([inet_ntoa], [AC_CHECK_FUNCS])
189 AN_FUNCTION([isascii], [AC_CHECK_FUNCS])
190 AN_FUNCTION([iswprint], [AC_CHECK_FUNCS])
191 AN_FUNCTION([lchown], [AC_CHECK_FUNCS])
192 AN_FUNCTION([listmntent], [AC_CHECK_FUNCS])
193 AN_FUNCTION([localeconv], [AC_CHECK_FUNCS])
194 AN_FUNCTION([localtime_r], [AC_CHECK_FUNCS])
195 AN_FUNCTION([mblen], [AC_CHECK_FUNCS])
196 AN_FUNCTION([mbrlen], [AC_CHECK_FUNCS])
197 AN_FUNCTION([memchr], [AC_CHECK_FUNCS])
198 AN_FUNCTION([memmove], [AC_CHECK_FUNCS])
199 AN_FUNCTION([mempcpy], [AC_CHECK_FUNCS])
200 AN_FUNCTION([memset], [AC_CHECK_FUNCS])
201 AN_FUNCTION([mkdir], [AC_CHECK_FUNCS])
202 AN_FUNCTION([mkfifo], [AC_CHECK_FUNCS])
203 AN_FUNCTION([modf], [AC_CHECK_FUNCS])
204 AN_FUNCTION([munmap], [AC_CHECK_FUNCS])
205 AN_FUNCTION([next_dev], [AC_CHECK_FUNCS])
206 AN_FUNCTION([nl_langinfo], [AC_CHECK_FUNCS])
207 AN_FUNCTION([pathconf], [AC_CHECK_FUNCS])
208 AN_FUNCTION([pow], [AC_CHECK_FUNCS])
209 AN_FUNCTION([pstat_getdynamic], [AC_CHECK_FUNCS])
210 AN_FUNCTION([putenv], [AC_CHECK_FUNCS])
211 AN_FUNCTION([re_comp], [AC_CHECK_FUNCS])
212 AN_FUNCTION([realpath], [AC_CHECK_FUNCS])
213 AN_FUNCTION([regcmp], [AC_CHECK_FUNCS])
214 AN_FUNCTION([regcomp], [AC_CHECK_FUNCS])
215 AN_FUNCTION([resolvepath], [AC_CHECK_FUNCS])
216 AN_FUNCTION([rint], [AC_CHECK_FUNCS])
217 AN_FUNCTION([rmdir], [AC_CHECK_FUNCS])
218 AN_FUNCTION([rpmatch], [AC_CHECK_FUNCS])
219 AN_FUNCTION([select], [AC_CHECK_FUNCS])
220 AN_FUNCTION([setenv], [AC_CHECK_FUNCS])
221 AN_FUNCTION([sethostname], [AC_CHECK_FUNCS])
222 AN_FUNCTION([setlocale], [AC_CHECK_FUNCS])
223 AN_FUNCTION([socket], [AC_CHECK_FUNCS])
224 AN_FUNCTION([sqrt], [AC_CHECK_FUNCS])
225 AN_FUNCTION([stime], [AC_CHECK_FUNCS])
226 AN_FUNCTION([stpcpy], [AC_CHECK_FUNCS])
227 AN_FUNCTION([strcasecmp], [AC_CHECK_FUNCS])
228 AN_FUNCTION([strchr], [AC_CHECK_FUNCS])
229 AN_FUNCTION([strcspn], [AC_CHECK_FUNCS])
230 AN_FUNCTION([strdup], [AC_CHECK_FUNCS])
231 AN_FUNCTION([strerror], [AC_CHECK_FUNCS])
232 AN_FUNCTION([strncasecmp], [AC_CHECK_FUNCS])
233 AN_FUNCTION([strndup], [AC_CHECK_FUNCS])
234 AN_FUNCTION([strpbrk], [AC_CHECK_FUNCS])
235 AN_FUNCTION([strrchr], [AC_CHECK_FUNCS])
236 AN_FUNCTION([strspn], [AC_CHECK_FUNCS])
237 AN_FUNCTION([strstr], [AC_CHECK_FUNCS])
238 AN_FUNCTION([strtol], [AC_CHECK_FUNCS])
239 AN_FUNCTION([strtoul], [AC_CHECK_FUNCS])
240 AN_FUNCTION([strtoull], [AC_CHECK_FUNCS])
241 AN_FUNCTION([strtoumax], [AC_CHECK_FUNCS])
242 AN_FUNCTION([strverscmp], [AC_CHECK_FUNCS])
243 AN_FUNCTION([sysinfo], [AC_CHECK_FUNCS])
244 AN_FUNCTION([tzset], [AC_CHECK_FUNCS])
245 AN_FUNCTION([uname], [AC_CHECK_FUNCS])
246 AN_FUNCTION([utime], [AC_CHECK_FUNCS])
247 AN_FUNCTION([utmpname], [AC_CHECK_FUNCS])
248 AN_FUNCTION([utmpxname], [AC_CHECK_FUNCS])
249 AN_FUNCTION([wcwidth], [AC_CHECK_FUNCS])
252 AN_FUNCTION([dcgettext], [AM_GNU_GETTEXT])
253 AN_FUNCTION([getwd], [warn: getwd is deprecated, use getcwd instead])
256 ## --------------------------------- ##
257 ## 3. Tests for specific functions. ##
258 ## --------------------------------- ##
261 # The macros are sorted:
263 # 1. AC_FUNC_* macros are sorted by alphabetical order.
265 # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
268 # 3. Obsolete macros are right after the modern macro.
274 # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
275 # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
276 # Nevertheless, for Automake, AC_LIBSOURCES it.
277 m4_define([_AC_LIBOBJ_ALLOCA],
278 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
279 # that cause trouble. Some versions do not even contain alloca or
280 # contain a buggy version. If you still want to use their alloca,
281 # use ar to extract alloca.o from them instead of compiling alloca.c.
282 AC_LIBSOURCES(alloca.c)
283 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
284 AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
286 AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
287 [AC_EGREP_CPP(webecray,
288 [#if defined CRAY && ! defined CRAY2
293 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
294 if test $ac_cv_os_cray = yes; then
295 for ac_func in _getb67 GETB67 getb67; do
296 AC_CHECK_FUNC($ac_func,
297 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
298 [Define to one of `_getb67', `GETB67',
299 `getb67' for Cray-2 and Cray-YMP
300 systems. This function is required for
301 `alloca.c' support on those systems.])
306 AC_CACHE_CHECK([stack direction for C alloca],
307 [ac_cv_c_stack_direction],
308 [AC_RUN_IFELSE([AC_LANG_SOURCE(
311 find_stack_direction ()
313 static char *addr = 0;
318 return find_stack_direction ();
321 return (&dummy > addr) ? 1 : -1;
327 return find_stack_direction () < 0;
329 [ac_cv_c_stack_direction=1],
330 [ac_cv_c_stack_direction=-1],
331 [ac_cv_c_stack_direction=0])])
332 AH_VERBATIM([STACK_DIRECTION],
333 [/* If using the C implementation of alloca, define if you know the
334 direction of stack growth for your system; otherwise it will be
335 automatically deduced at runtime.
336 STACK_DIRECTION > 0 => grows toward higher addresses
337 STACK_DIRECTION < 0 => grows toward lower addresses
338 STACK_DIRECTION = 0 => direction of growth unknown */
339 @%:@undef STACK_DIRECTION])dnl
340 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
341 ])# _AC_LIBOBJ_ALLOCA
346 AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
347 AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
348 AC_DEFUN([AC_FUNC_ALLOCA],
349 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
350 # for constant arguments. Useless!
351 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
353 [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
354 [[char *p = (char *) alloca (2 * sizeof (int));
355 if (p) return 0;]])],
356 [ac_cv_working_alloca_h=yes],
357 [ac_cv_working_alloca_h=no])])
358 if test $ac_cv_working_alloca_h = yes; then
359 AC_DEFINE(HAVE_ALLOCA_H, 1,
360 [Define to 1 if you have <alloca.h> and it should be used
364 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
365 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
367 # define alloca __builtin_alloca
371 # define alloca _alloca
373 # ifdef HAVE_ALLOCA_H
379 # ifndef alloca /* predefined by HP cc +Olibcalls */
386 ]], [[char *p = (char *) alloca (1);
387 if (p) return 0;]])],
388 [ac_cv_func_alloca_works=yes],
389 [ac_cv_func_alloca_works=no])])
391 if test $ac_cv_func_alloca_works = yes; then
392 AC_DEFINE(HAVE_ALLOCA, 1,
393 [Define to 1 if you have `alloca', as a function or macro.])
402 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
407 # Determine whether chown accepts arguments of -1 for uid and gid.
408 AN_FUNCTION([chown], [AC_FUNC_CHOWN])
409 AC_DEFUN([AC_FUNC_CHOWN],
410 [AC_REQUIRE([AC_TYPE_UID_T])dnl
411 AC_CHECK_HEADERS(unistd.h)
412 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
413 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
416 [[ char *f = "conftest.chown";
417 struct stat before, after;
419 if (creat (f, 0600) < 0)
421 if (stat (f, &before) < 0)
423 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
425 if (stat (f, &after) < 0)
427 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
429 [ac_cv_func_chown_works=yes],
430 [ac_cv_func_chown_works=no],
431 [ac_cv_func_chown_works=no])
434 if test $ac_cv_func_chown_works = yes; then
435 AC_DEFINE(HAVE_CHOWN, 1,
436 [Define to 1 if your system has a working `chown' function.])
441 # AC_FUNC_CLOSEDIR_VOID
442 # ---------------------
443 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
445 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
446 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
447 AC_CACHE_CHECK([whether closedir returns void],
448 [ac_cv_func_closedir_void],
449 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
450 #include <$ac_header_dirent>
455 [[return closedir (opendir (".")) != 0;]])],
456 [ac_cv_func_closedir_void=no],
457 [ac_cv_func_closedir_void=yes],
458 [ac_cv_func_closedir_void=yes])])
459 if test $ac_cv_func_closedir_void = yes; then
460 AC_DEFINE(CLOSEDIR_VOID, 1,
461 [Define to 1 if the `closedir' function returns void instead
467 # AC_FUNC_ERROR_AT_LINE
468 # ---------------------
469 AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
470 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
471 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
472 [AC_LIBSOURCES([error.h, error.c])dnl
473 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
474 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
475 [error_at_line (0, 0, "", 0, "an error occurred");])],
476 [ac_cv_lib_error_at_line=yes],
477 [ac_cv_lib_error_at_line=no])])
478 if test $ac_cv_lib_error_at_line = no; then
484 # AU::AM_FUNC_ERROR_AT_LINE
485 # -------------------------
486 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
489 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
490 # -------------------------------------------------------------------------
491 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
492 # IF-FALSE. Use CACHE_VAR.
493 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
495 [for working $1 fnmatch],
497 [# Some versions of Solaris, SCO, and the GNU C Library
498 # have a broken or incompatible fnmatch.
499 # So we run a test program. If we are cross-compiling, take no chance.
500 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
503 [#include <fnmatch.h>
504 # define y(a, b, c) (fnmatch (a, b, c) == 0)
505 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
508 (!(y ("a*", "abc", 0)
509 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
510 && y ("a\\\\bc", "abc", 0)
511 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
513 && n ("*x", ".x", FNM_PERIOD)
514 && m4_if([$1], [GNU],
515 [y ("xxXX", "xXxX", FNM_CASEFOLD)
516 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
517 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
518 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
519 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
520 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
525 AS_IF([test $$2 = yes], [$3], [$4])
526 ])# _AC_FUNC_FNMATCH_IF
531 AC_DEFUN([AC_FUNC_FNMATCH],
532 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
533 [AC_DEFINE([HAVE_FNMATCH], 1,
534 [Define to 1 if your system has a working POSIX `fnmatch'
541 # Prepare the replacement of fnmatch.
542 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
543 [AC_REQUIRE([AC_C_CONST])dnl
544 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
545 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
546 AC_CHECK_DECLS([getenv])
547 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
548 AC_CHECK_HEADERS([wchar.h wctype.h])
550 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
551 AC_DEFINE(fnmatch, rpl_fnmatch,
552 [Define to rpl_fnmatch if the replacement function should be used.])
553 ])# _AC_LIBOBJ_FNMATCH
558 AC_DEFUN([AC_REPLACE_FNMATCH],
559 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
560 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
561 [_AC_LIBOBJ_FNMATCH])
562 ])# AC_REPLACE_FNMATCH
565 # AC_FUNC_FNMATCH_GNU
566 # -------------------
567 AC_DEFUN([AC_FUNC_FNMATCH_GNU],
568 [AC_REQUIRE([AC_GNU_SOURCE])
569 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
570 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
571 [_AC_LIBOBJ_FNMATCH])
572 ])# AC_FUNC_FNMATCH_GNU
575 # AU::AM_FUNC_FNMATCH
576 # AU::fp_FUNC_FNMATCH
577 # -------------------
578 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
579 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
584 AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
585 AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
586 AC_DEFUN([AC_FUNC_FSEEKO],
587 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
588 [ac_cv_sys_largefile_source],
589 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
590 [[#include <sys/types.h> /* for off_t */
591 #include <stdio.h>]],
592 [[int (*fp) (FILE *, off_t, int) = fseeko;
593 return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
595 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
596 # in glibc 2.1.3, but that breaks too many other things.
597 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
598 if test $ac_cv_sys_largefile_source != unknown; then
599 AC_DEFINE(HAVE_FSEEKO, 1,
600 [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
607 # Try to find `getgroups', and check that it works.
608 # When cross-compiling, assume getgroups is broken.
609 AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
610 AC_DEFUN([AC_FUNC_GETGROUPS],
611 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
612 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
613 AC_CHECK_FUNC(getgroups)
615 # If we don't yet have getgroups, see if it's in -lbsd.
616 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
618 if test $ac_cv_func_getgroups = no; then
619 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
622 # Run the program to test the functionality of the system-supplied
623 # getgroups function only if there is such a function.
624 if test $ac_cv_func_getgroups = yes; then
625 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
626 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
627 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
628 return getgroups (0, 0) == -1;]])],
629 [ac_cv_func_getgroups_works=yes],
630 [ac_cv_func_getgroups_works=no],
631 [ac_cv_func_getgroups_works=no])
633 if test $ac_cv_func_getgroups_works = yes; then
634 AC_DEFINE(HAVE_GETGROUPS, 1,
635 [Define to 1 if your system has a working `getgroups' function.])
639 ])# AC_FUNC_GETGROUPS
642 # _AC_LIBOBJ_GETLOADAVG
643 # ---------------------
644 # Set up the AC_LIBOBJ replacement of `getloadavg'.
645 m4_define([_AC_LIBOBJ_GETLOADAVG],
646 [AC_LIBOBJ(getloadavg)
647 AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
648 # Figure out what our getloadavg.c needs.
650 AC_CHECK_HEADER(sys/dg_sys_info.h,
652 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
653 AC_CHECK_LIB(dgc, dg_sys_info)])
655 AC_CHECK_HEADER(locale.h)
656 AC_CHECK_FUNCS(setlocale)
658 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
659 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
660 # Irix 4.0.5F has the header but not the library.
661 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
663 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
666 if test $ac_have_func = no; then
667 AC_CHECK_HEADER(inq_stats/cpustats.h,
669 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
670 AC_DEFINE(UMAX4_3, 1,
671 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
672 instead of <sys/cpustats.h>.])])
675 if test $ac_have_func = no; then
676 AC_CHECK_HEADER(sys/cpustats.h,
677 [ac_have_func=yes; AC_DEFINE(UMAX)])
680 if test $ac_have_func = no; then
681 AC_CHECK_HEADERS(mach/mach.h)
684 AC_CHECK_HEADERS(nlist.h,
685 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
686 [AC_DEFINE(NLIST_NAME_UNION, 1,
687 [Define to 1 if your `struct nlist' has an
688 `n_un' member. Obsolete, depend on
689 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
690 [@%:@include <nlist.h>])
692 ])# _AC_LIBOBJ_GETLOADAVG
697 AC_DEFUN([AC_FUNC_GETLOADAVG],
698 [ac_have_func=no # yes means we've found a way to get the load average.
700 # Make sure getloadavg.c is where it belongs, at configure-time.
701 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
702 AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
706 # Check for getloadavg, but be sure not to touch the cache variable.
707 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
709 # On HPUX9, an unprivileged user can get load averages through this function.
710 AC_CHECK_FUNCS(pstat_getdynamic)
712 # Solaris has libkstat which does not require root.
713 AC_CHECK_LIB(kstat, kstat_open)
714 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
716 # Some systems with -lutil have (and need) -lkvm as well, some do not.
717 # On Solaris, -lkvm requires nlist from -lelf, so check that first
718 # to get the right answer into the cache.
719 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
720 if test $ac_have_func = no; then
721 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
723 if test $ac_have_func = no; then
724 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
725 # Check for the 4.4BSD definition of getloadavg.
726 AC_CHECK_LIB(util, getloadavg,
727 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
730 if test $ac_have_func = no; then
731 # There is a commonly available library for RS/6000 AIX.
732 # Since it is not a standard part of AIX, it might be installed locally.
733 ac_getloadavg_LIBS=$LIBS
734 LIBS="-L/usr/local/lib $LIBS"
735 AC_CHECK_LIB(getloadavg, getloadavg,
736 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
739 # Make sure it is really in the library, if we think we found it,
740 # otherwise set up the replacement function.
741 AC_CHECK_FUNCS(getloadavg, [],
742 [_AC_LIBOBJ_GETLOADAVG])
744 # Some definitions of getloadavg require that the program be installed setgid.
745 AC_CACHE_CHECK(whether getloadavg requires setgid,
746 ac_cv_func_getloadavg_setgid,
747 [AC_EGREP_CPP([Yowza Am I SETGID yet],
748 [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
749 #ifdef LDAV_PRIVILEGED
750 Yowza Am I SETGID yet
752 ac_cv_func_getloadavg_setgid=yes,
753 ac_cv_func_getloadavg_setgid=no)])
754 if test $ac_cv_func_getloadavg_setgid = yes; then
756 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
757 [Define to 1 if the `getloadavg' function needs to be run setuid
762 AC_SUBST(NEED_SETGID)dnl
764 if test $ac_cv_func_getloadavg_setgid = yes; then
765 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
766 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
767 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
768 # If we got an error (system does not support symlinks), try without -L.
769 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
770 ac_cv_group_kmem=`AS_ECHO(["$ac_ls_output"]) \
771 | sed -ne ['s/[ ][ ]*/ /g;
772 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
775 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
777 if test "x$ac_save_LIBS" = x; then
778 GETLOADAVG_LIBS=$LIBS
780 GETLOADAVG_LIBS=`AS_ECHO(["$LIBS"]) | sed "s|$ac_save_LIBS||"`
784 AC_SUBST(GETLOADAVG_LIBS)dnl
785 ])# AC_FUNC_GETLOADAVG
790 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
795 AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
796 AC_DEFUN([AC_FUNC_GETMNTENT],
797 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
798 # -lseq on Dynix/PTX, -lgen on Unixware.
799 AC_SEARCH_LIBS(getmntent, [sun seq gen],
800 [ac_cv_func_getmntent=yes
801 AC_DEFINE([HAVE_GETMNTENT], 1,
802 [Define to 1 if you have the `getmntent' function.])],
803 [ac_cv_func_getmntent=no])
809 # Figure out whether getpgrp requires zero arguments.
810 AC_DEFUN([AC_FUNC_GETPGRP],
811 [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
812 ac_cv_func_getpgrp_void,
813 [# Use it with a single arg.
814 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
815 [ac_cv_func_getpgrp_void=no],
816 [ac_cv_func_getpgrp_void=yes])
818 if test $ac_cv_func_getpgrp_void = yes; then
819 AC_DEFINE(GETPGRP_VOID, 1,
820 [Define to 1 if the `getpgrp' function requires zero arguments.])
825 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
826 # -------------------------------------
827 # When cross-compiling, be pessimistic so we will end up using the
828 # replacement version of lstat that checks for trailing slashes and
829 # calls lstat a second time when necessary.
830 AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
831 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
833 [whether lstat dereferences a symlink specified with a trailing slash],
834 [ac_cv_func_lstat_dereferences_slashed_symlink],
835 [rm -f conftest.sym conftest.file
837 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
838 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
840 /* Linux will dereference the symlink and fail.
841 That is better in the sense that it means we will not
842 have to compile and use the lstat wrapper. */
843 return lstat ("conftest.sym/", &sbuf) == 0;])],
844 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
845 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
846 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
848 # If the `ln -s' command failed, then we probably don't even
849 # have an lstat function.
850 ac_cv_func_lstat_dereferences_slashed_symlink=no
852 rm -f conftest.sym conftest.file
855 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
856 AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
857 [Define to 1 if `lstat' dereferences a symlink specified
858 with a trailing slash.])
860 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
866 # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
867 # ------------------------------------
868 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
869 AC_DEFUN([_AC_FUNC_MALLOC_IF],
870 [AC_REQUIRE([AC_HEADER_STDC])dnl
871 AC_CHECK_HEADERS(stdlib.h)
872 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
875 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
881 [return ! malloc (0);])],
882 [ac_cv_func_malloc_0_nonnull=yes],
883 [ac_cv_func_malloc_0_nonnull=no],
884 [ac_cv_func_malloc_0_nonnull=no])])
885 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
886 ])# _AC_FUNC_MALLOC_IF
891 # Report whether `malloc (0)' properly handled, and replace malloc if
893 AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
894 AC_DEFUN([AC_FUNC_MALLOC],
896 [AC_DEFINE([HAVE_MALLOC], 1,
897 [Define to 1 if your system has a GNU libc compatible `malloc'
898 function, and to 0 otherwise.])],
899 [AC_DEFINE([HAVE_MALLOC], 0)
901 AC_DEFINE([malloc], [rpl_malloc],
902 [Define to rpl_malloc if the replacement function should be used.])])
908 AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
909 AC_DEFUN([AC_FUNC_MBRTOWC],
911 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
915 [[@%:@include <wchar.h>]],
920 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
921 ac_cv_func_mbrtowc=yes,
922 ac_cv_func_mbrtowc=no)])
923 if test $ac_cv_func_mbrtowc = yes; then
924 AC_DEFINE([HAVE_MBRTOWC], 1,
925 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
932 AC_DEFUN([AC_FUNC_MEMCMP],
933 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
934 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
935 /* Some versions of memcmp are not 8-bit clean. */
936 char c0 = '\100', c1 = '\200', c2 = '\201';
937 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
940 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
941 or more and with at least one buffer not starting on a 4-byte boundary.
942 William Lewis provided this test program. */
947 for (i = 0; i < 4; i++)
951 strcpy (a, "--------01111111");
952 strcpy (b, "--------10000000");
953 if (memcmp (a, b, 16) >= 0)
959 [ac_cv_func_memcmp_working=yes],
960 [ac_cv_func_memcmp_working=no],
961 [ac_cv_func_memcmp_working=no])])
962 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
968 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
969 AC_DEFUN([AC_FUNC_MKTIME],
970 [AC_REQUIRE([AC_HEADER_TIME])dnl
971 AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
972 AC_CHECK_FUNCS_ONCE(alarm)
973 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
974 [AC_RUN_IFELSE([AC_LANG_SOURCE(
975 [[/* Test program from Paul Eggert and Tony Leneis. */
976 #ifdef TIME_WITH_SYS_TIME
977 # include <sys/time.h>
980 # ifdef HAVE_SYS_TIME_H
981 # include <sys/time.h>
995 # define alarm(X) /* empty */
998 /* Work around redefinition to rpl_putenv by other config tests. */
1001 static time_t time_t_max;
1002 static time_t time_t_min;
1004 /* Values we'll use to set the TZ environment variable. */
1005 static char *tz_strings[] = {
1006 (char *) 0, "TZ=GMT0", "TZ=JST-9",
1007 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
1009 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
1011 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
1012 Based on a problem report from Andreas Jaeger. */
1014 spring_forward_gap ()
1016 /* glibc (up to about 1998-10-07) failed this test. */
1019 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1020 instead of "TZ=America/Vancouver" in order to detect the bug even
1021 on systems that don't support the Olson extension, or don't have the
1022 full zoneinfo tables installed. */
1023 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1032 return mktime (&tm) != (time_t) -1;
1040 return ! (lt = localtime (&now)) || mktime (lt) == now;
1047 return (mktime_test1 (now)
1048 && mktime_test1 ((time_t) (time_t_max - now))
1049 && mktime_test1 ((time_t) (time_t_min + now)));
1055 /* Based on code from Ariel Faigon. */
1065 return tm.tm_mon == 2 && tm.tm_mday == 31;
1074 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
1076 if (now != (time_t) -1)
1078 struct tm *lt = localtime (&now);
1080 && lt->tm_year == tm.tm_year
1081 && lt->tm_mon == tm.tm_mon
1082 && lt->tm_mday == tm.tm_mday
1083 && lt->tm_hour == tm.tm_hour
1084 && lt->tm_min == tm.tm_min
1085 && lt->tm_sec == tm.tm_sec
1086 && lt->tm_yday == tm.tm_yday
1087 && lt->tm_wday == tm.tm_wday
1088 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
1089 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
1098 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
1099 ignoring leap seconds. */
1100 unsigned long int answer = 2527315200UL;
1104 tm.tm_year = 2050 - 1900;
1107 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
1110 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1111 instead of "TZ=America/Vancouver" in order to detect the bug even
1112 on systems that don't support the Olson extension, or don't have the
1113 full zoneinfo tables installed. */
1114 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1118 /* Check that the result is either a failure, or close enough
1119 to the correct answer that we can assume the discrepancy is
1120 due to leap seconds. */
1121 return (t == (time_t) -1
1122 || (0 < t && answer - 120 <= t && t <= answer + 120));
1131 /* This test makes some buggy mktime implementations loop.
1132 Give up after 60 seconds; a mktime slower than that
1133 isn't worth using anyway. */
1138 t = (time_t_max << 1) + 1;
1139 if (t <= time_t_max)
1143 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
1145 delta = time_t_max / 997; /* a suitable prime number */
1146 for (i = 0; i < N_STRINGS; i++)
1149 putenv (tz_strings[i]);
1151 for (t = 0; t <= time_t_max - delta; t += delta)
1152 if (! mktime_test (t))
1154 if (! (mktime_test ((time_t) 1)
1155 && mktime_test ((time_t) (60 * 60))
1156 && mktime_test ((time_t) (60 * 60 * 24))))
1159 for (j = 1; ; j <<= 1)
1160 if (! bigtime_test (j))
1162 else if (INT_MAX / 2 < j)
1164 if (! bigtime_test (INT_MAX))
1167 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
1169 [ac_cv_func_working_mktime=yes],
1170 [ac_cv_func_working_mktime=no],
1171 [ac_cv_func_working_mktime=no])])
1172 if test $ac_cv_func_working_mktime = no; then
1178 # AU::AM_FUNC_MKTIME
1179 # ------------------
1180 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
1185 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
1186 AC_DEFUN([AC_FUNC_MMAP],
1187 [AC_CHECK_HEADERS(stdlib.h unistd.h)
1188 AC_CHECK_FUNCS(getpagesize)
1189 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
1190 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
1191 [[/* malloc might have been renamed as rpl_malloc. */
1194 /* Thanks to Mike Haertel and Jim Avera for this test.
1195 Here is a matrix of mmap possibilities:
1196 mmap private not fixed
1197 mmap private fixed at somewhere currently unmapped
1198 mmap private fixed at somewhere already mapped
1199 mmap shared not fixed
1200 mmap shared fixed at somewhere currently unmapped
1201 mmap shared fixed at somewhere already mapped
1202 For private mappings, we should verify that changes cannot be read()
1203 back from the file, nor mmap's back from the file at a different
1204 address. (There have been systems where private was not correctly
1205 implemented like the infamous i386 svr4.0, and systems where the
1206 VM page cache was not coherent with the file system buffer cache
1207 like early versions of FreeBSD and possibly contemporary NetBSD.)
1208 For shared mappings, we should conversely verify that changes get
1209 propagated back to all the places they're supposed to be.
1211 Grep wants private fixed already mapped.
1212 The main things grep needs to know about mmap are:
1213 * does it exist and is it safe to write into the mmap'd area
1214 * how to use it (BSD variants) */
1217 #include <sys/mman.h>
1219 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
1223 /* This mess was copied from the GNU getpagesize.h. */
1224 #ifndef HAVE_GETPAGESIZE
1225 /* Assume that all systems that can run configure have sys/param.h. */
1226 # ifndef HAVE_SYS_PARAM_H
1227 # define HAVE_SYS_PARAM_H 1
1230 # ifdef _SC_PAGESIZE
1231 # define getpagesize() sysconf(_SC_PAGESIZE)
1232 # else /* no _SC_PAGESIZE */
1233 # ifdef HAVE_SYS_PARAM_H
1234 # include <sys/param.h>
1235 # ifdef EXEC_PAGESIZE
1236 # define getpagesize() EXEC_PAGESIZE
1237 # else /* no EXEC_PAGESIZE */
1239 # define getpagesize() NBPG * CLSIZE
1242 # endif /* no CLSIZE */
1243 # else /* no NBPG */
1245 # define getpagesize() NBPC
1246 # else /* no NBPC */
1248 # define getpagesize() PAGESIZE
1249 # endif /* PAGESIZE */
1250 # endif /* no NBPC */
1251 # endif /* no NBPG */
1252 # endif /* no EXEC_PAGESIZE */
1253 # else /* no HAVE_SYS_PARAM_H */
1254 # define getpagesize() 8192 /* punt totally */
1255 # endif /* no HAVE_SYS_PARAM_H */
1256 # endif /* no _SC_PAGESIZE */
1258 #endif /* no HAVE_GETPAGESIZE */
1263 char *data, *data2, *data3;
1267 pagesize = getpagesize ();
1269 /* First, make a file with some known garbage in it. */
1270 data = (char *) malloc (pagesize);
1273 for (i = 0; i < pagesize; ++i)
1274 *(data + i) = rand ();
1276 fd = creat ("conftest.mmap", 0600);
1279 if (write (fd, data, pagesize) != pagesize)
1283 /* Next, try to mmap the file at a fixed address which already has
1284 something else allocated at it. If we can, also make sure that
1285 we see the same garbage. */
1286 fd = open ("conftest.mmap", O_RDWR);
1289 data2 = (char *) malloc (2 * pagesize);
1292 data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1);
1293 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1294 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1296 for (i = 0; i < pagesize; ++i)
1297 if (*(data + i) != *(data2 + i))
1300 /* Finally, make sure that changes to the mapped area do not
1301 percolate back to the file as seen by read(). (This is a bug on
1302 some variants of i386 svr4.0.) */
1303 for (i = 0; i < pagesize; ++i)
1304 *(data2 + i) = *(data2 + i) + 1;
1305 data3 = (char *) malloc (pagesize);
1308 if (read (fd, data3, pagesize) != pagesize)
1310 for (i = 0; i < pagesize; ++i)
1311 if (*(data + i) != *(data3 + i))
1316 [ac_cv_func_mmap_fixed_mapped=yes],
1317 [ac_cv_func_mmap_fixed_mapped=no],
1318 [ac_cv_func_mmap_fixed_mapped=no])])
1319 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1320 AC_DEFINE(HAVE_MMAP, 1,
1321 [Define to 1 if you have a working `mmap' system call.])
1329 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1334 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1335 AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
1336 AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
1337 AC_DEFUN([AC_FUNC_OBSTACK],
1338 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1339 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1341 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1342 [@%:@include "obstack.h"]],
1343 [[struct obstack mem;
1344 @%:@define obstack_chunk_alloc malloc
1345 @%:@define obstack_chunk_free free
1346 obstack_init (&mem);
1347 obstack_free (&mem, 0);]])],
1348 [ac_cv_func_obstack=yes],
1349 [ac_cv_func_obstack=no])])
1350 if test $ac_cv_func_obstack = yes; then
1351 AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1358 # AU::AM_FUNC_OBSTACK
1359 # -------------------
1360 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1364 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
1365 # -------------------------------------
1366 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
1367 AC_DEFUN([_AC_FUNC_REALLOC_IF],
1368 [AC_REQUIRE([AC_HEADER_STDC])dnl
1369 AC_CHECK_HEADERS(stdlib.h)
1370 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
1373 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1374 # include <stdlib.h>
1379 [return ! realloc (0, 0);])],
1380 [ac_cv_func_realloc_0_nonnull=yes],
1381 [ac_cv_func_realloc_0_nonnull=no],
1382 [ac_cv_func_realloc_0_nonnull=no])])
1383 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
1389 # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
1391 AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
1392 AC_DEFUN([AC_FUNC_REALLOC],
1393 [_AC_FUNC_REALLOC_IF(
1394 [AC_DEFINE([HAVE_REALLOC], 1,
1395 [Define to 1 if your system has a GNU libc compatible `realloc'
1396 function, and to 0 otherwise.])],
1397 [AC_DEFINE([HAVE_REALLOC], 0)
1398 AC_LIBOBJ([realloc])
1399 AC_DEFINE([realloc], [rpl_realloc],
1400 [Define to rpl_realloc if the replacement function should be used.])])
1404 # AC_FUNC_SELECT_ARGTYPES
1405 # -----------------------
1406 # Determine the correct type to be passed to each of the `select'
1407 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1408 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1409 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1410 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1411 AC_CACHE_CHECK([types of arguments for select],
1412 [ac_cv_func_select_args],
1413 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1414 for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
1415 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1418 [AC_INCLUDES_DEFAULT
1419 #ifdef HAVE_SYS_SELECT_H
1420 # include <sys/select.h>
1422 #ifdef HAVE_SYS_SOCKET_H
1423 # include <sys/socket.h>
1426 [extern int select ($ac_arg1,
1427 $ac_arg234, $ac_arg234, $ac_arg234,
1429 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1433 # Provide a safe default value.
1434 : ${ac_cv_func_select_args='int,int *,struct timeval *'}
1436 ac_save_IFS=$IFS; IFS=','
1437 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1440 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1441 [Define to the type of arg 1 for `select'.])
1442 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1443 [Define to the type of args 2, 3 and 4 for `select'.])
1444 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1445 [Define to the type of arg 5 for `select'.])
1447 ])# AC_FUNC_SELECT_ARGTYPES
1452 AC_DEFUN([AC_FUNC_SETPGRP],
1453 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1455 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1456 [/* If this system has a BSD-style setpgrp which takes arguments,
1457 setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1458 exit successfully. */
1459 return setpgrp (1,1) != -1;])],
1460 [ac_cv_func_setpgrp_void=no],
1461 [ac_cv_func_setpgrp_void=yes],
1462 [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1463 if test $ac_cv_func_setpgrp_void = yes; then
1464 AC_DEFINE(SETPGRP_VOID, 1,
1465 [Define to 1 if the `setpgrp' function takes no argument.])
1470 # _AC_FUNC_STAT(STAT | LSTAT)
1471 # ---------------------------
1472 # Determine whether stat or lstat have the bug that it succeeds when
1473 # given the zero-length file name argument. The stat and lstat from
1474 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1476 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1477 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1479 m4_define([_AC_FUNC_STAT],
1480 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1481 AC_CACHE_CHECK([whether $1 accepts an empty string],
1482 [ac_cv_func_$1_empty_string_bug],
1483 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1485 return $1 ("", &sbuf) == 0;]])],
1486 [ac_cv_func_$1_empty_string_bug=no],
1487 [ac_cv_func_$1_empty_string_bug=yes],
1488 [ac_cv_func_$1_empty_string_bug=yes])])
1489 if test $ac_cv_func_$1_empty_string_bug = yes; then
1491 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1492 [Define to 1 if `$1' has the bug that it succeeds when
1493 given the zero-length file name argument.])
1498 # AC_FUNC_STAT & AC_FUNC_LSTAT
1499 # ----------------------------
1500 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1501 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1506 m4_define([_AC_LIBOBJ_STRTOD],
1509 if test $ac_cv_func_pow = no; then
1510 AC_CHECK_LIB(m, pow,
1512 [AC_MSG_WARN([cannot find library containing definition of pow])])
1514 ])# _AC_LIBOBJ_STRTOD
1519 AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
1520 AC_DEFUN([AC_FUNC_STRTOD],
1521 [AC_SUBST(POW_LIB)dnl
1522 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1523 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1524 ]AC_INCLUDES_DEFAULT[
1532 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1533 char *string = " +69";
1536 value = strtod (string, &term);
1537 if (value != 69 || term != (string + 4))
1542 /* Under Solaris 2.4, strtod returns the wrong value for the
1543 terminating character under some conditions. */
1544 char *string = "NaN";
1546 strtod (string, &term);
1547 if (term != string && *(term - 1) == 0)
1553 ac_cv_func_strtod=yes,
1554 ac_cv_func_strtod=no,
1555 ac_cv_func_strtod=no)])
1556 if test $ac_cv_func_strtod = no; then
1564 AC_DEFUN([AC_FUNC_STRTOLD],
1566 AC_CACHE_CHECK([whether strtold conforms to C99],
1567 [ac_cv_func_strtold],
1570 [[/* On HP-UX before 11.23, strtold returns a struct instead of
1571 long double. Reject implementations like that, by requiring
1572 compatibility with the C99 prototype. */
1573 # include <stdlib.h>
1574 static long double (*p) (char const *, char **) = strtold;
1576 test (char const *nptr, char **endptr)
1579 r = strtold (nptr, endptr);
1582 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
1583 [ac_cv_func_strtold=yes],
1584 [ac_cv_func_strtold=no])])
1585 if test $ac_cv_func_strtold = yes; then
1586 AC_DEFINE([HAVE_STRTOLD], 1,
1587 [Define to 1 if strtold exists and conforms to C99.])
1592 # AU::AM_FUNC_STRTOD
1593 # ------------------
1594 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1597 # AC_FUNC_STRERROR_R
1598 # ------------------
1599 AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
1600 AC_DEFUN([AC_FUNC_STRERROR_R],
1601 [AC_CHECK_DECLS([strerror_r])
1602 AC_CHECK_FUNCS([strerror_r])
1603 AC_CACHE_CHECK([whether strerror_r returns char *],
1604 ac_cv_func_strerror_r_char_p,
1606 ac_cv_func_strerror_r_char_p=no
1607 if test $ac_cv_have_decl_strerror_r = yes; then
1608 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1611 char x = *strerror_r (0, buf, sizeof buf);
1612 char *p = strerror_r (0, buf, sizeof buf);
1615 ac_cv_func_strerror_r_char_p=yes)
1617 # strerror_r is not declared. Choose between
1618 # systems that have relatively inaccessible declarations for the
1619 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1620 # former has a strerror_r that returns char*, while the latter
1621 # has a strerror_r that returns `int'.
1622 # This test should segfault on the DEC system.
1623 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1624 extern char *strerror_r ();],
1626 char x = *strerror_r (0, buf, sizeof buf);
1627 return ! isalpha (x);]])],
1628 ac_cv_func_strerror_r_char_p=yes, , :)
1631 if test $ac_cv_func_strerror_r_char_p = yes; then
1632 AC_DEFINE([STRERROR_R_CHAR_P], 1,
1633 [Define to 1 if strerror_r returns char *.])
1635 ])# AC_FUNC_STRERROR_R
1640 AC_DEFUN([AC_FUNC_STRFTIME],
1641 [AC_CHECK_FUNCS(strftime, [],
1642 [# strftime is in -lintl on SCO UNIX.
1643 AC_CHECK_LIB(intl, strftime,
1644 [AC_DEFINE(HAVE_STRFTIME)
1645 LIBS="-lintl $LIBS"])])dnl
1646 ])# AC_FUNC_STRFTIME
1651 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
1652 AC_DEFUN([AC_FUNC_STRNLEN],
1653 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
1654 AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1655 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1657 #define S_LEN (sizeof S - 1)
1659 /* At least one implementation is buggy: that of AIX 4.3 would
1660 give strnlen (S, 1) == 3. */
1663 for (i = 0; i < S_LEN + 1; ++i)
1665 int expected = i <= S_LEN ? i : S_LEN;
1666 if (strnlen (S, i) != expected)
1671 [ac_cv_func_strnlen_working=yes],
1672 [ac_cv_func_strnlen_working=no],
1673 [ac_cv_func_strnlen_working=no])])
1674 test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1678 # AC_FUNC_SETVBUF_REVERSED
1679 # ------------------------
1680 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1681 [AC_DIAGNOSE([obsolete],
1682 [The macro `$0' is obsolete. Remove it and all references to SETVBUF_REVERSED.])dnl
1683 AC_CACHE_VAL([ac_cv_func_setvbuf_reversed], [ac_cv_func_setvbuf_reversed=no])
1684 ])# AC_FUNC_SETVBUF_REVERSED
1687 # AU::AC_SETVBUF_REVERSED
1688 # -----------------------
1689 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1694 AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
1695 AC_DEFUN([AC_FUNC_STRCOLL],
1696 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1697 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1698 [[return (strcoll ("abc", "def") >= 0 ||
1699 strcoll ("ABC", "DEF") >= 0 ||
1700 strcoll ("123", "456") >= 0)]])],
1701 ac_cv_func_strcoll_works=yes,
1702 ac_cv_func_strcoll_works=no,
1703 ac_cv_func_strcoll_works=no)])
1704 if test $ac_cv_func_strcoll_works = yes; then
1705 AC_DEFINE(HAVE_STRCOLL, 1,
1706 [Define to 1 if you have the `strcoll' function and it is properly
1714 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1717 # AC_FUNC_UTIME_NULL
1718 # ------------------
1719 AC_DEFUN([AC_FUNC_UTIME_NULL],
1720 [AC_CHECK_HEADERS_ONCE(utime.h)
1721 AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1722 [rm -f conftest.data; >conftest.data
1723 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1724 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1729 return ! (stat ("conftest.data", &s) == 0
1730 && utime ("conftest.data", 0) == 0
1731 && stat ("conftest.data", &t) == 0
1732 && t.st_mtime >= s.st_mtime
1733 && t.st_mtime - s.st_mtime < 120);]])],
1734 ac_cv_func_utime_null=yes,
1735 ac_cv_func_utime_null=no,
1736 ac_cv_func_utime_null=no)])
1737 if test $ac_cv_func_utime_null = yes; then
1738 AC_DEFINE(HAVE_UTIME_NULL, 1,
1739 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1743 ])# AC_FUNC_UTIME_NULL
1748 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1753 AN_FUNCTION([fork], [AC_FUNC_FORK])
1754 AN_FUNCTION([vfork], [AC_FUNC_FORK])
1755 AC_DEFUN([AC_FUNC_FORK],
1756 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1757 AC_CHECK_HEADERS(vfork.h)
1758 AC_CHECK_FUNCS(fork vfork)
1759 if test "x$ac_cv_func_fork" = xyes; then
1762 ac_cv_func_fork_works=$ac_cv_func_fork
1764 if test "x$ac_cv_func_fork_works" = xcross; then
1766 *-*-amigaos* | *-*-msdosdjgpp*)
1767 # Override, as these systems have only a dummy fork() stub
1768 ac_cv_func_fork_works=no
1771 ac_cv_func_fork_works=yes
1774 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1776 ac_cv_func_vfork_works=$ac_cv_func_vfork
1777 if test "x$ac_cv_func_vfork" = xyes; then
1780 if test "x$ac_cv_func_fork_works" = xcross; then
1781 ac_cv_func_vfork_works=$ac_cv_func_vfork
1782 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1785 if test "x$ac_cv_func_vfork_works" = xyes; then
1786 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1788 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1790 if test "x$ac_cv_func_fork_works" = xyes; then
1791 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1798 AC_DEFUN([_AC_FUNC_FORK],
1799 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1801 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1803 /* By Ruediger Kuhlmann. */
1806 [ac_cv_func_fork_works=yes],
1807 [ac_cv_func_fork_works=no],
1808 [ac_cv_func_fork_works=cross])])]
1814 AC_DEFUN([_AC_FUNC_VFORK],
1815 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1816 [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
1817 ]AC_INCLUDES_DEFAULT[
1818 #include <sys/wait.h>
1822 /* On some sparc systems, changes by the child to local and incoming
1823 argument registers are propagated back to the parent. The compiler
1824 is told about this with #include <vfork.h>, but some compilers
1825 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1826 static variable whose address is put into a register that is
1827 clobbered by the vfork. */
1830 sparc_address_test (int arg)
1832 sparc_address_test (arg) int arg;
1853 pid_t parent = getpid ();
1856 sparc_address_test (0);
1861 /* Here is another test for sparc vfork register problems. This
1862 test uses lots of local variables, at least as many local
1863 variables as main has allocated so far including compiler
1864 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1865 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1866 reuse the register of parent for one of the local variables,
1867 since it will think that parent can't possibly be used any more
1868 in this routine. Assigning to the local variable will thus
1869 munge parent in the parent process. */
1871 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1872 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1873 /* Convince the compiler that p..p7 are live; otherwise, it might
1874 use the same hardware register for all 8 local variables. */
1875 if (p != p1 || p != p2 || p != p3 || p != p4
1876 || p != p5 || p != p6 || p != p7)
1879 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1880 from child file descriptors. If the child closes a descriptor
1881 before it execs or exits, this munges the parent's descriptor
1882 as well. Test for this by closing stdout in the child. */
1883 _exit(close(fileno(stdout)) != 0);
1888 while (wait(&status) != child)
1891 /* Was there some problem with vforking? */
1894 /* Did the child fail? (This shouldn't happen.) */
1897 /* Did the vfork/compiler bug occur? */
1898 || parent != getpid()
1900 /* Did the file descriptor bug occur? */
1901 || fstat(fileno(stdout), &st) != 0
1905 [ac_cv_func_vfork_works=yes],
1906 [ac_cv_func_vfork_works=no],
1907 [ac_cv_func_vfork_works=cross])])
1913 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1917 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1922 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1923 # That the logical name!
1924 AC_DEFUN([AC_FUNC_VPRINTF],
1925 [AC_CHECK_FUNCS(vprintf, []
1926 [AC_CHECK_FUNC(_doprnt,
1927 [AC_DEFINE(HAVE_DOPRNT, 1,
1928 [Define to 1 if you don't have `vprintf' but do have
1935 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1940 # Don't bother too hard maintaining this macro, as it's obsoleted.
1941 # We don't AU define it, since we don't have any alternative to propose,
1942 # any invocation should be removed, and the code adjusted.
1943 AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
1944 AC_DEFUN([AC_FUNC_WAIT3],
1945 [AC_DIAGNOSE([obsolete],
1946 [$0: `wait3' has been removed from POSIX.
1947 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1948 AC_CACHE_CHECK([for wait3 that fills in rusage],
1949 [ac_cv_func_wait3_rusage],
1950 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1951 [AC_INCLUDES_DEFAULT[
1952 #include <sys/time.h>
1953 #include <sys/resource.h>
1954 #include <sys/wait.h>
1955 /* HP-UX has wait3 but does not fill in rusage at all. */
1961 /* Use a field that we can force nonzero --
1962 voluntary context switches.
1963 For systems like NeXT and OSF/1 that don't set it,
1964 also use the system CPU time. And page faults (I/O) for Linux. */
1966 r.ru_stime.tv_sec = 0;
1967 r.ru_stime.tv_usec = 0;
1968 r.ru_majflt = r.ru_minflt = 0;
1971 case 0: /* Child. */
1972 sleep(1); /* Give up the CPU. */
1975 case -1: /* What can we do? */
1978 default: /* Parent. */
1980 /* Avoid "text file busy" from rm on fast HP-UX machines. */
1982 return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1983 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1986 [ac_cv_func_wait3_rusage=yes],
1987 [ac_cv_func_wait3_rusage=no],
1988 [ac_cv_func_wait3_rusage=no])])
1989 if test $ac_cv_func_wait3_rusage = yes; then
1990 AC_DEFINE(HAVE_WAIT3, 1,
1991 [Define to 1 if you have the `wait3' system call.
1992 Deprecated, you should no longer depend upon `wait3'.])
1999 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])