1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
3 # Copyright (C) 2000-2012 Free Software Foundation, Inc.
5 # This file is part of Autoconf. This program is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # 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 # Under Section 7 of GPL version 3, you are granted additional
17 # permissions described in the Autoconf Configure Script Exception,
18 # version 3.0, as published by the Free Software Foundation.
20 # You should have received a copy of the GNU General Public License
21 # and a copy of the Autoconf Configure Script Exception along with
22 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
23 # respectively. If not, see <http://www.gnu.org/licenses/>.
25 # Written by David MacKenzie, with help from
26 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
27 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
32 # 1. Generic tests for functions.
33 # 2. Functions to check with AC_CHECK_FUNCS
34 # 3. Tests for specific functions.
37 ## -------------------------------- ##
38 ## 1. Generic tests for functions. ##
39 ## -------------------------------- ##
43 # Shell function body for AC_CHECK_FUNC.
44 m4_define([_AC_CHECK_FUNC_BODY],
45 [ AS_LINENO_PUSH([$[]1])
46 AC_CACHE_CHECK([for $[]2], [$[]3],
47 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY($[]2)],
48 [AS_VAR_SET([$[]3], [yes])],
49 [AS_VAR_SET([$[]3], [no])])])
51 ])# _AC_CHECK_FUNC_BODY
54 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
55 # -----------------------------------------------------------------
56 # Check whether FUNCTION links in the current language. Set the cache
57 # variable ac_cv_func_FUNCTION accordingly, then execute
58 # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
59 AC_DEFUN([AC_CHECK_FUNC],
60 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_func],
61 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_func],
63 [Tests whether FUNC exists, setting the cache variable VAR accordingly])],
65 [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])]dnl
66 [ac_fn_[]_AC_LANG_ABBREV[]_check_func "$LINENO" "$1" "ac_var"
67 AS_VAR_IF([ac_var], [yes], [$2], [$3])
68 AS_VAR_POPDEF([ac_var])])# AC_CHECK_FUNC
71 # _AH_CHECK_FUNC(FUNCTION)
72 # ------------------------
73 # Prepare the autoheader snippet for FUNCTION.
74 m4_define([_AH_CHECK_FUNC],
75 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
76 [Define to 1 if you have the `$1' function.])])
79 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
80 # ---------------------------------------------------------------------
81 # Check for each whitespace-separated FUNCTION, and perform
82 # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each function.
83 # Additionally, make the preprocessor definition HAVE_FUNCTION
84 # available for each found function. Either ACTION may include
85 # `break' to stop the search.
86 AC_DEFUN([AC_CHECK_FUNCS],
87 [m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
88 [AS_FOR([AC_func], [ac_func], [$1],
89 [AC_CHECK_FUNC(AC_func,
90 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_func)) $2],
95 # _AC_CHECK_FUNC_ONCE(FUNCTION)
96 # -----------------------------
97 # Check for a single FUNCTION once.
98 m4_define([_AC_CHECK_FUNC_ONCE],
99 [_AH_CHECK_FUNC([$1])AC_DEFUN([_AC_Func_$1],
100 [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_func_list], [" $1"])])
101 _AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
103 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
104 # --------------------------------
105 # Add each whitespace-separated name in FUNCTION to the list of functions
107 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
108 [m4_map_args_w([$1], [_AC_CHECK_FUNC_ONCE(], [)])])
110 m4_define([_AC_FUNCS_EXPANSION],
112 m4_divert_text([DEFAULTS], [ac_func_list=])
113 AC_CHECK_FUNCS([$ac_func_list])
114 m4_define([_AC_FUNCS_EXPANSION], [])
118 # _AC_REPLACE_FUNC(FUNCTION)
119 # --------------------------
120 # If FUNCTION exists, define HAVE_FUNCTION; else add FUNCTION.c
121 # to the list of library objects. FUNCTION must be literal.
122 m4_define([_AC_REPLACE_FUNC],
124 [_AH_CHECK_FUNC([$1])AC_DEFINE(AS_TR_CPP([HAVE_$1]))],
125 [_AC_LIBOBJ([$1])AC_LIBSOURCE([$1.c])])])
127 # AC_REPLACE_FUNCS(FUNCTION...)
128 # -----------------------------
129 # For each FUNCTION in the whitespace separated list, perform the
130 # equivalent of AC_CHECK_FUNC, then call AC_LIBOBJ if the function
132 AC_DEFUN([AC_REPLACE_FUNCS],
133 [_$0(m4_flatten([$1]))])
135 m4_define([_AC_REPLACE_FUNCS],
137 [m4_map_args_w([$1], [_AC_REPLACE_FUNC(], [)
139 [AC_CHECK_FUNCS([$1],
140 [_AH_CHECK_FUNC([$ac_func])],
141 [_AC_LIBOBJ([$ac_func])])])])
144 # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
145 # ------------------------------------------------------------
146 # Try to link a program that calls FUNC, handling GCC builtins. If
147 # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
148 # ACTION-IF-NOT-FOUND.
149 AC_DEFUN([AC_TRY_LINK_FUNC],
150 [AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
155 AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
160 AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
165 ## ------------------------------------------- ##
166 ## 2. Functions to check with AC_CHECK_FUNCS. ##
167 ## ------------------------------------------- ##
169 AN_FUNCTION([__argz_count], [AC_CHECK_FUNCS])
170 AN_FUNCTION([__argz_next], [AC_CHECK_FUNCS])
171 AN_FUNCTION([__argz_stringify], [AC_CHECK_FUNCS])
172 AN_FUNCTION([__fpending], [AC_CHECK_FUNCS])
173 AN_FUNCTION([acl], [AC_CHECK_FUNCS])
174 AN_FUNCTION([alarm], [AC_CHECK_FUNCS])
175 AN_FUNCTION([atexit], [AC_CHECK_FUNCS])
176 AN_FUNCTION([btowc], [AC_CHECK_FUNCS])
177 AN_FUNCTION([bzero], [AC_CHECK_FUNCS])
178 AN_FUNCTION([clock_gettime], [AC_CHECK_FUNCS])
179 AN_FUNCTION([doprnt], [AC_CHECK_FUNCS])
180 AN_FUNCTION([dup2], [AC_CHECK_FUNCS])
181 AN_FUNCTION([endgrent], [AC_CHECK_FUNCS])
182 AN_FUNCTION([endpwent], [AC_CHECK_FUNCS])
183 AN_FUNCTION([euidaccess], [AC_CHECK_FUNCS])
184 AN_FUNCTION([fchdir], [AC_CHECK_FUNCS])
185 AN_FUNCTION([fdatasync], [AC_CHECK_FUNCS])
186 AN_FUNCTION([fesetround], [AC_CHECK_FUNCS])
187 AN_FUNCTION([floor], [AC_CHECK_FUNCS])
188 AN_FUNCTION([fs_stat_dev], [AC_CHECK_FUNCS])
189 AN_FUNCTION([ftime], [AC_CHECK_FUNCS])
190 AN_FUNCTION([ftruncate], [AC_CHECK_FUNCS])
191 AN_FUNCTION([getcwd], [AC_CHECK_FUNCS])
192 AN_FUNCTION([getdelim], [AC_CHECK_FUNCS])
193 AN_FUNCTION([gethostbyaddr], [AC_CHECK_FUNCS])
194 AN_FUNCTION([gethostbyname], [AC_CHECK_FUNCS])
195 AN_FUNCTION([gethostname], [AC_CHECK_FUNCS])
196 AN_FUNCTION([gethrtime], [AC_CHECK_FUNCS])
197 AN_FUNCTION([getmntent], [AC_CHECK_FUNCS])
198 AN_FUNCTION([getmntinfo], [AC_CHECK_FUNCS])
199 AN_FUNCTION([getpagesize], [AC_CHECK_FUNCS])
200 AN_FUNCTION([getpass], [AC_CHECK_FUNCS])
201 AN_FUNCTION([getspnam], [AC_CHECK_FUNCS])
202 AN_FUNCTION([gettimeofday], [AC_CHECK_FUNCS])
203 AN_FUNCTION([getusershell], [AC_CHECK_FUNCS])
204 AN_FUNCTION([hasmntopt], [AC_CHECK_FUNCS])
205 AN_FUNCTION([inet_ntoa], [AC_CHECK_FUNCS])
206 AN_FUNCTION([isascii], [AC_CHECK_FUNCS])
207 AN_FUNCTION([iswprint], [AC_CHECK_FUNCS])
208 AN_FUNCTION([lchown], [AC_CHECK_FUNCS])
209 AN_FUNCTION([listmntent], [AC_CHECK_FUNCS])
210 AN_FUNCTION([localeconv], [AC_CHECK_FUNCS])
211 AN_FUNCTION([localtime_r], [AC_CHECK_FUNCS])
212 AN_FUNCTION([mblen], [AC_CHECK_FUNCS])
213 AN_FUNCTION([mbrlen], [AC_CHECK_FUNCS])
214 AN_FUNCTION([memchr], [AC_CHECK_FUNCS])
215 AN_FUNCTION([memmove], [AC_CHECK_FUNCS])
216 AN_FUNCTION([mempcpy], [AC_CHECK_FUNCS])
217 AN_FUNCTION([memset], [AC_CHECK_FUNCS])
218 AN_FUNCTION([mkdir], [AC_CHECK_FUNCS])
219 AN_FUNCTION([mkfifo], [AC_CHECK_FUNCS])
220 AN_FUNCTION([modf], [AC_CHECK_FUNCS])
221 AN_FUNCTION([munmap], [AC_CHECK_FUNCS])
222 AN_FUNCTION([next_dev], [AC_CHECK_FUNCS])
223 AN_FUNCTION([nl_langinfo], [AC_CHECK_FUNCS])
224 AN_FUNCTION([pathconf], [AC_CHECK_FUNCS])
225 AN_FUNCTION([pow], [AC_CHECK_FUNCS])
226 AN_FUNCTION([pstat_getdynamic], [AC_CHECK_FUNCS])
227 AN_FUNCTION([putenv], [AC_CHECK_FUNCS])
228 AN_FUNCTION([re_comp], [AC_CHECK_FUNCS])
229 AN_FUNCTION([realpath], [AC_CHECK_FUNCS])
230 AN_FUNCTION([regcmp], [AC_CHECK_FUNCS])
231 AN_FUNCTION([regcomp], [AC_CHECK_FUNCS])
232 AN_FUNCTION([resolvepath], [AC_CHECK_FUNCS])
233 AN_FUNCTION([rint], [AC_CHECK_FUNCS])
234 AN_FUNCTION([rmdir], [AC_CHECK_FUNCS])
235 AN_FUNCTION([rpmatch], [AC_CHECK_FUNCS])
236 AN_FUNCTION([select], [AC_CHECK_FUNCS])
237 AN_FUNCTION([setenv], [AC_CHECK_FUNCS])
238 AN_FUNCTION([sethostname], [AC_CHECK_FUNCS])
239 AN_FUNCTION([setlocale], [AC_CHECK_FUNCS])
240 AN_FUNCTION([socket], [AC_CHECK_FUNCS])
241 AN_FUNCTION([sqrt], [AC_CHECK_FUNCS])
242 AN_FUNCTION([stime], [AC_CHECK_FUNCS])
243 AN_FUNCTION([stpcpy], [AC_CHECK_FUNCS])
244 AN_FUNCTION([strcasecmp], [AC_CHECK_FUNCS])
245 AN_FUNCTION([strchr], [AC_CHECK_FUNCS])
246 AN_FUNCTION([strcspn], [AC_CHECK_FUNCS])
247 AN_FUNCTION([strdup], [AC_CHECK_FUNCS])
248 AN_FUNCTION([strerror], [AC_CHECK_FUNCS])
249 AN_FUNCTION([strncasecmp], [AC_CHECK_FUNCS])
250 AN_FUNCTION([strndup], [AC_CHECK_FUNCS])
251 AN_FUNCTION([strpbrk], [AC_CHECK_FUNCS])
252 AN_FUNCTION([strrchr], [AC_CHECK_FUNCS])
253 AN_FUNCTION([strspn], [AC_CHECK_FUNCS])
254 AN_FUNCTION([strstr], [AC_CHECK_FUNCS])
255 AN_FUNCTION([strtol], [AC_CHECK_FUNCS])
256 AN_FUNCTION([strtoul], [AC_CHECK_FUNCS])
257 AN_FUNCTION([strtoull], [AC_CHECK_FUNCS])
258 AN_FUNCTION([strtoumax], [AC_CHECK_FUNCS])
259 AN_FUNCTION([strverscmp], [AC_CHECK_FUNCS])
260 AN_FUNCTION([sysinfo], [AC_CHECK_FUNCS])
261 AN_FUNCTION([tzset], [AC_CHECK_FUNCS])
262 AN_FUNCTION([uname], [AC_CHECK_FUNCS])
263 AN_FUNCTION([utime], [AC_CHECK_FUNCS])
264 AN_FUNCTION([utmpname], [AC_CHECK_FUNCS])
265 AN_FUNCTION([utmpxname], [AC_CHECK_FUNCS])
266 AN_FUNCTION([wcwidth], [AC_CHECK_FUNCS])
269 AN_FUNCTION([dcgettext], [AM_GNU_GETTEXT])
270 AN_FUNCTION([getwd], [warn: getwd is deprecated, use getcwd instead])
273 ## --------------------------------- ##
274 ## 3. Tests for specific functions. ##
275 ## --------------------------------- ##
278 # The macros are sorted:
280 # 1. AC_FUNC_* macros are sorted by alphabetical order.
282 # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
285 # 3. Obsolete macros are right after the modern macro.
291 # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
292 # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
293 # Nevertheless, for Automake, AC_LIBSOURCES it.
294 m4_define([_AC_LIBOBJ_ALLOCA],
295 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
296 # that cause trouble. Some versions do not even contain alloca or
297 # contain a buggy version. If you still want to use their alloca,
298 # use ar to extract alloca.o from them instead of compiling alloca.c.
299 AC_LIBSOURCES(alloca.c)
300 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
301 AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
303 AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
304 [AC_EGREP_CPP(webecray,
305 [#if defined CRAY && ! defined CRAY2
310 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
311 if test $ac_cv_os_cray = yes; then
312 for ac_func in _getb67 GETB67 getb67; do
313 AC_CHECK_FUNC($ac_func,
314 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
315 [Define to one of `_getb67', `GETB67',
316 `getb67' for Cray-2 and Cray-YMP
317 systems. This function is required for
318 `alloca.c' support on those systems.])
323 AC_CACHE_CHECK([stack direction for C alloca],
324 [ac_cv_c_stack_direction],
325 [AC_RUN_IFELSE([AC_LANG_SOURCE(
328 find_stack_direction (int *addr, int depth)
333 *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
334 dir = depth ? find_stack_direction (addr, depth - 1) : 0;
339 main (int argc, char **argv)
341 return find_stack_direction (0, argc + !argv + 20) < 0;
343 [ac_cv_c_stack_direction=1],
344 [ac_cv_c_stack_direction=-1],
345 [ac_cv_c_stack_direction=0])])
346 AH_VERBATIM([STACK_DIRECTION],
347 [/* If using the C implementation of alloca, define if you know the
348 direction of stack growth for your system; otherwise it will be
349 automatically deduced at runtime.
350 STACK_DIRECTION > 0 => grows toward higher addresses
351 STACK_DIRECTION < 0 => grows toward lower addresses
352 STACK_DIRECTION = 0 => direction of growth unknown */
353 @%:@undef STACK_DIRECTION])dnl
354 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
355 ])# _AC_LIBOBJ_ALLOCA
360 AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
361 AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
362 AC_DEFUN([AC_FUNC_ALLOCA],
363 [AC_REQUIRE([AC_TYPE_SIZE_T])]dnl
364 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
365 # for constant arguments. Useless!
366 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
368 [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
369 [[char *p = (char *) alloca (2 * sizeof (int));
370 if (p) return 0;]])],
371 [ac_cv_working_alloca_h=yes],
372 [ac_cv_working_alloca_h=no])])
373 if test $ac_cv_working_alloca_h = yes; then
374 AC_DEFINE(HAVE_ALLOCA_H, 1,
375 [Define to 1 if you have <alloca.h> and it should be used
379 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
380 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
382 # define alloca __builtin_alloca
386 # define alloca _alloca
388 # ifdef HAVE_ALLOCA_H
394 # ifndef alloca /* predefined by HP cc +Olibcalls */
395 void *alloca (size_t);
401 ]], [[char *p = (char *) alloca (1);
402 if (p) return 0;]])],
403 [ac_cv_func_alloca_works=yes],
404 [ac_cv_func_alloca_works=no])])
406 if test $ac_cv_func_alloca_works = yes; then
407 AC_DEFINE(HAVE_ALLOCA, 1,
408 [Define to 1 if you have `alloca', as a function or macro.])
417 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
422 # Determine whether chown accepts arguments of -1 for uid and gid.
423 AN_FUNCTION([chown], [AC_FUNC_CHOWN])
424 AC_DEFUN([AC_FUNC_CHOWN],
425 [AC_REQUIRE([AC_TYPE_UID_T])dnl
426 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
427 AC_CHECK_HEADERS(unistd.h)
428 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
429 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
432 [[ char *f = "conftest.chown";
433 struct stat before, after;
435 if (creat (f, 0600) < 0)
437 if (stat (f, &before) < 0)
439 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
441 if (stat (f, &after) < 0)
443 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
445 [ac_cv_func_chown_works=yes],
446 [ac_cv_func_chown_works=no],
447 [case "$host_os" in # ((
448 # Guess yes on glibc systems.
449 *-gnu*) ac_cv_func_chown_works=yes ;;
450 # If we don't know, assume the worst.
451 *) ac_cv_func_chown_works=no ;;
455 if test $ac_cv_func_chown_works = yes; then
456 AC_DEFINE(HAVE_CHOWN, 1,
457 [Define to 1 if your system has a working `chown' function.])
462 # AC_FUNC_CLOSEDIR_VOID
463 # ---------------------
464 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
466 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
467 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
468 AC_CACHE_CHECK([whether closedir returns void],
469 [ac_cv_func_closedir_void],
470 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
471 #include <$ac_header_dirent>
476 [[return closedir (opendir (".")) != 0;]])],
477 [ac_cv_func_closedir_void=no],
478 [ac_cv_func_closedir_void=yes],
479 [ac_cv_func_closedir_void=yes])])
480 if test $ac_cv_func_closedir_void = yes; then
481 AC_DEFINE(CLOSEDIR_VOID, 1,
482 [Define to 1 if the `closedir' function returns void instead
488 # AC_FUNC_ERROR_AT_LINE
489 # ---------------------
490 AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
491 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
492 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
493 [AC_LIBSOURCES([error.h, error.c])dnl
494 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
495 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
496 [error_at_line (0, 0, "", 0, "an error occurred");])],
497 [ac_cv_lib_error_at_line=yes],
498 [ac_cv_lib_error_at_line=no])])
499 if test $ac_cv_lib_error_at_line = no; then
505 # AU::AM_FUNC_ERROR_AT_LINE
506 # -------------------------
507 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
510 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
511 # -------------------------------------------------------------------------
512 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
513 # IF-FALSE. Use CACHE_VAR.
514 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
516 [for working $1 fnmatch],
518 [# Some versions of Solaris, SCO, and the GNU C Library
519 # have a broken or incompatible fnmatch.
520 # So we run a test program. If we are cross-compiling, take no chance.
521 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
524 [#include <fnmatch.h>
525 # define y(a, b, c) (fnmatch (a, b, c) == 0)
526 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
529 (!(y ("a*", "abc", 0)
530 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
531 && y ("a\\\\bc", "abc", 0)
532 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
534 && n ("*x", ".x", FNM_PERIOD)
535 && m4_if([$1], [GNU],
536 [y ("xxXX", "xXxX", FNM_CASEFOLD)
537 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
538 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
539 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
540 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
541 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
546 AS_IF([test $$2 = yes], [$3], [$4])
547 ])# _AC_FUNC_FNMATCH_IF
552 AC_DEFUN([AC_FUNC_FNMATCH],
553 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
554 [AC_DEFINE([HAVE_FNMATCH], 1,
555 [Define to 1 if your system has a working POSIX `fnmatch'
562 # Prepare the replacement of fnmatch.
563 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
564 [AC_REQUIRE([AC_C_CONST])dnl
565 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
566 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
567 AC_CHECK_DECLS([getenv])
568 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
569 AC_CHECK_HEADERS([wchar.h wctype.h])
571 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
572 AC_DEFINE(fnmatch, rpl_fnmatch,
573 [Define to rpl_fnmatch if the replacement function should be used.])
574 ])# _AC_LIBOBJ_FNMATCH
579 AC_DEFUN([AC_REPLACE_FNMATCH],
580 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
581 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
582 [_AC_LIBOBJ_FNMATCH])
583 ])# AC_REPLACE_FNMATCH
586 # AC_FUNC_FNMATCH_GNU
587 # -------------------
588 AC_DEFUN([AC_FUNC_FNMATCH_GNU],
589 [AC_REQUIRE([AC_GNU_SOURCE])
590 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
591 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
592 [_AC_LIBOBJ_FNMATCH])
593 ])# AC_FUNC_FNMATCH_GNU
596 # AU::AM_FUNC_FNMATCH
597 # AU::fp_FUNC_FNMATCH
598 # -------------------
599 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
600 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
605 AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
606 AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
607 AC_DEFUN([AC_FUNC_FSEEKO],
608 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
609 [ac_cv_sys_largefile_source],
610 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
611 [[#include <sys/types.h> /* for off_t */
612 #include <stdio.h>]],
613 [[int (*fp) (FILE *, off_t, int) = fseeko;
614 return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
616 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
617 # in glibc 2.1.3, but that breaks too many other things.
618 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
619 if test $ac_cv_sys_largefile_source != unknown; then
620 AC_DEFINE(HAVE_FSEEKO, 1,
621 [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
628 # Try to find `getgroups', and check that it works.
629 # When cross-compiling, assume getgroups is broken.
630 AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
631 AC_DEFUN([AC_FUNC_GETGROUPS],
632 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
633 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
634 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
635 AC_CHECK_FUNC(getgroups)
637 # If we don't yet have getgroups, see if it's in -lbsd.
638 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
640 if test $ac_cv_func_getgroups = no; then
641 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
644 # Run the program to test the functionality of the system-supplied
645 # getgroups function only if there is such a function.
646 if test $ac_cv_func_getgroups = yes; then
647 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
648 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
649 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
650 return getgroups (0, 0) == -1;]])],
651 [ac_cv_func_getgroups_works=yes],
652 [ac_cv_func_getgroups_works=no],
653 [case "$host_os" in # ((
654 # Guess yes on glibc systems.
655 *-gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
656 # If we don't know, assume the worst.
657 *) ac_cv_func_getgroups_works="guessing no" ;;
661 ac_cv_func_getgroups_works=no
663 case "$ac_cv_func_getgroups_works" in
665 AC_DEFINE(HAVE_GETGROUPS, 1,
666 [Define to 1 if your system has a working `getgroups' function.])
670 ])# AC_FUNC_GETGROUPS
673 # _AC_LIBOBJ_GETLOADAVG
674 # ---------------------
675 # Set up the AC_LIBOBJ replacement of `getloadavg'.
676 m4_define([_AC_LIBOBJ_GETLOADAVG],
677 [AC_LIBOBJ(getloadavg)
678 AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
679 # Figure out what our getloadavg.c needs.
681 AC_CHECK_HEADER(sys/dg_sys_info.h,
683 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
684 AC_CHECK_LIB(dgc, dg_sys_info)])
686 AC_CHECK_HEADER(locale.h)
687 AC_CHECK_FUNCS(setlocale)
689 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
690 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
691 # Irix 4.0.5F has the header but not the library.
692 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
693 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
695 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
698 if test $ac_have_func = no; then
699 AC_CHECK_HEADER(inq_stats/cpustats.h,
701 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
702 AC_DEFINE(UMAX4_3, 1,
703 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
704 instead of <sys/cpustats.h>.])])
707 if test $ac_have_func = no; then
708 AC_CHECK_HEADER(sys/cpustats.h,
709 [ac_have_func=yes; AC_DEFINE(UMAX)])
712 if test $ac_have_func = no; then
713 AC_CHECK_HEADERS(mach/mach.h)
716 AC_CHECK_HEADERS(nlist.h,
717 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
718 [AC_DEFINE(NLIST_NAME_UNION, 1,
719 [Define to 1 if your `struct nlist' has an
720 `n_un' member. Obsolete, depend on
721 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
722 [@%:@include <nlist.h>])
724 ])# _AC_LIBOBJ_GETLOADAVG
729 AC_DEFUN([AC_FUNC_GETLOADAVG],
730 [ac_have_func=no # yes means we've found a way to get the load average.
732 # Make sure getloadavg.c is where it belongs, at configure-time.
733 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
734 AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
738 # Check for getloadavg, but be sure not to touch the cache variable.
739 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
741 # On HPUX9, an unprivileged user can get load averages through this function.
742 AC_CHECK_FUNCS(pstat_getdynamic)
744 # Solaris has libkstat which does not require root.
745 AC_CHECK_LIB(kstat, kstat_open)
746 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
748 # Some systems with -lutil have (and need) -lkvm as well, some do not.
749 # On Solaris, -lkvm requires nlist from -lelf, so check that first
750 # to get the right answer into the cache.
751 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
752 if test $ac_have_func = no; then
753 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
755 if test $ac_have_func = no; then
756 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
757 # Check for the 4.4BSD definition of getloadavg.
758 AC_CHECK_LIB(util, getloadavg,
759 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
762 if test $ac_have_func = no; then
763 # There is a commonly available library for RS/6000 AIX.
764 # Since it is not a standard part of AIX, it might be installed locally.
765 ac_getloadavg_LIBS=$LIBS
766 LIBS="-L/usr/local/lib $LIBS"
767 AC_CHECK_LIB(getloadavg, getloadavg,
768 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
771 # Make sure it is really in the library, if we think we found it,
772 # otherwise set up the replacement function.
773 AC_CHECK_FUNCS(getloadavg, [],
774 [_AC_LIBOBJ_GETLOADAVG])
776 # Some definitions of getloadavg require that the program be installed setgid.
777 AC_CACHE_CHECK(whether getloadavg requires setgid,
778 ac_cv_func_getloadavg_setgid,
779 [AC_EGREP_CPP([Yowza Am I SETGID yet],
780 [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
781 #ifdef LDAV_PRIVILEGED
782 Yowza Am I SETGID yet
784 ac_cv_func_getloadavg_setgid=yes,
785 ac_cv_func_getloadavg_setgid=no)])
786 if test $ac_cv_func_getloadavg_setgid = yes; then
788 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
789 [Define to 1 if the `getloadavg' function needs to be run setuid
794 AC_SUBST(NEED_SETGID)dnl
796 if test $ac_cv_func_getloadavg_setgid = yes; then
797 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
798 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
799 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
800 # If we got an error (system does not support symlinks), try without -L.
801 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
802 ac_cv_group_kmem=`AS_ECHO(["$ac_ls_output"]) \
803 | sed -ne ['s/[ ][ ]*/ /g;
804 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
807 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
809 if test "x$ac_save_LIBS" = x; then
810 GETLOADAVG_LIBS=$LIBS
812 GETLOADAVG_LIBS=`AS_ECHO(["$LIBS"]) | sed "s|$ac_save_LIBS||"`
816 AC_SUBST(GETLOADAVG_LIBS)dnl
817 ])# AC_FUNC_GETLOADAVG
822 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
827 AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
828 AC_DEFUN([AC_FUNC_GETMNTENT],
829 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
830 # -lseq on Dynix/PTX, -lgen on Unixware.
831 AC_SEARCH_LIBS(getmntent, [sun seq gen],
832 [ac_cv_func_getmntent=yes
833 AC_DEFINE([HAVE_GETMNTENT], 1,
834 [Define to 1 if you have the `getmntent' function.])],
835 [ac_cv_func_getmntent=no])
841 # Figure out whether getpgrp requires zero arguments.
842 AC_DEFUN([AC_FUNC_GETPGRP],
843 [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
844 ac_cv_func_getpgrp_void,
845 [# Use it with a single arg.
846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
847 [ac_cv_func_getpgrp_void=no],
848 [ac_cv_func_getpgrp_void=yes])
850 if test $ac_cv_func_getpgrp_void = yes; then
851 AC_DEFINE(GETPGRP_VOID, 1,
852 [Define to 1 if the `getpgrp' function requires zero arguments.])
857 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
858 # -------------------------------------
859 # When cross-compiling, be pessimistic so we will end up using the
860 # replacement version of lstat that checks for trailing slashes and
861 # calls lstat a second time when necessary.
862 AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
863 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
864 [AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
866 [whether lstat correctly handles trailing slash],
867 [ac_cv_func_lstat_dereferences_slashed_symlink],
868 [rm -f conftest.sym conftest.file
870 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
871 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
873 /* Linux will dereference the symlink and fail, as required by POSIX.
874 That is better in the sense that it means we will not
875 have to compile and use the lstat wrapper. */
876 return lstat ("conftest.sym/", &sbuf) == 0;])],
877 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
878 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
879 [case "$host_os" in # ((
880 # Guess yes on glibc systems.
881 *-gnu*) ac_cv_func_lstat_dereferences_slashed_symlink=yes ;;
882 # If we don't know, assume the worst.
883 *) ac_cv_func_lstat_dereferences_slashed_symlink=no ;;
886 # If the `ln -s' command failed, then we probably don't even
887 # have an lstat function.
888 ac_cv_func_lstat_dereferences_slashed_symlink=no
890 rm -f conftest.sym conftest.file
893 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
894 AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
895 [Define to 1 if `lstat' dereferences a symlink specified
896 with a trailing slash.])
898 if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
904 # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
905 # ------------------------------------
906 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
907 AC_DEFUN([_AC_FUNC_MALLOC_IF],
908 [AC_REQUIRE([AC_HEADER_STDC])dnl
909 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
910 AC_CHECK_HEADERS(stdlib.h)
911 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
914 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
920 [return ! malloc (0);])],
921 [ac_cv_func_malloc_0_nonnull=yes],
922 [ac_cv_func_malloc_0_nonnull=no],
923 [case "$host_os" in # ((
924 # Guess yes on platforms where we know the result.
925 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
926 | hpux* | solaris* | cygwin* | mingw*)
927 ac_cv_func_malloc_0_nonnull=yes ;;
928 # If we don't know, assume the worst.
929 *) ac_cv_func_malloc_0_nonnull=no ;;
931 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
932 ])# _AC_FUNC_MALLOC_IF
937 # Report whether `malloc (0)' properly handled, and replace malloc if
939 AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
940 AC_DEFUN([AC_FUNC_MALLOC],
942 [AC_DEFINE([HAVE_MALLOC], 1,
943 [Define to 1 if your system has a GNU libc compatible `malloc'
944 function, and to 0 otherwise.])],
945 [AC_DEFINE([HAVE_MALLOC], 0)
947 AC_DEFINE([malloc], [rpl_malloc],
948 [Define to rpl_malloc if the replacement function should be used.])])
954 AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
955 AC_DEFUN([AC_FUNC_MBRTOWC],
957 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
961 [[@%:@include <wchar.h>]],
966 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
967 ac_cv_func_mbrtowc=yes,
968 ac_cv_func_mbrtowc=no)])
969 if test $ac_cv_func_mbrtowc = yes; then
970 AC_DEFINE([HAVE_MBRTOWC], 1,
971 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
978 AC_DEFUN([AC_FUNC_MEMCMP],
979 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
980 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
981 /* Some versions of memcmp are not 8-bit clean. */
982 char c0 = '\100', c1 = '\200', c2 = '\201';
983 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
986 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
987 or more and with at least one buffer not starting on a 4-byte boundary.
988 William Lewis provided this test program. */
993 for (i = 0; i < 4; i++)
997 strcpy (a, "--------01111111");
998 strcpy (b, "--------10000000");
999 if (memcmp (a, b, 16) >= 0)
1005 [ac_cv_func_memcmp_working=yes],
1006 [ac_cv_func_memcmp_working=no],
1007 [ac_cv_func_memcmp_working=no])])
1008 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
1014 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
1015 AC_DEFUN([AC_FUNC_MKTIME],
1016 [AC_REQUIRE([AC_HEADER_TIME])dnl
1017 AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
1018 AC_CHECK_FUNCS_ONCE(alarm)
1019 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
1020 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1021 [[/* Test program from Paul Eggert and Tony Leneis. */
1022 #ifdef TIME_WITH_SYS_TIME
1023 # include <sys/time.h>
1026 # ifdef HAVE_SYS_TIME_H
1027 # include <sys/time.h>
1036 #ifdef HAVE_UNISTD_H
1037 # include <unistd.h>
1041 # define alarm(X) /* empty */
1044 /* Work around redefinition to rpl_putenv by other config tests. */
1047 static time_t time_t_max;
1048 static time_t time_t_min;
1050 /* Values we'll use to set the TZ environment variable. */
1051 static const char *tz_strings[] = {
1052 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
1053 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
1055 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
1057 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
1058 Based on a problem report from Andreas Jaeger. */
1060 spring_forward_gap ()
1062 /* glibc (up to about 1998-10-07) failed this test. */
1065 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1066 instead of "TZ=America/Vancouver" in order to detect the bug even
1067 on systems that don't support the Olson extension, or don't have the
1068 full zoneinfo tables installed. */
1069 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
1078 return mktime (&tm) != (time_t) -1;
1082 mktime_test1 (time_t now)
1085 return ! (lt = localtime (&now)) || mktime (lt) == now;
1089 mktime_test (time_t now)
1091 return (mktime_test1 (now)
1092 && mktime_test1 ((time_t) (time_t_max - now))
1093 && mktime_test1 ((time_t) (time_t_min + now)));
1099 /* Based on code from Ariel Faigon. */
1109 return tm.tm_mon == 2 && tm.tm_mday == 31;
1113 bigtime_test (int j)
1117 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
1119 if (now != (time_t) -1)
1121 struct tm *lt = localtime (&now);
1123 && lt->tm_year == tm.tm_year
1124 && lt->tm_mon == tm.tm_mon
1125 && lt->tm_mday == tm.tm_mday
1126 && lt->tm_hour == tm.tm_hour
1127 && lt->tm_min == tm.tm_min
1128 && lt->tm_sec == tm.tm_sec
1129 && lt->tm_yday == tm.tm_yday
1130 && lt->tm_wday == tm.tm_wday
1131 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
1132 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
1141 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
1142 ignoring leap seconds. */
1143 unsigned long int answer = 2527315200UL;
1147 tm.tm_year = 2050 - 1900;
1150 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
1153 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1154 instead of "TZ=America/Vancouver" in order to detect the bug even
1155 on systems that don't support the Olson extension, or don't have the
1156 full zoneinfo tables installed. */
1157 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
1161 /* Check that the result is either a failure, or close enough
1162 to the correct answer that we can assume the discrepancy is
1163 due to leap seconds. */
1164 return (t == (time_t) -1
1165 || (0 < t && answer - 120 <= t && t <= answer + 120));
1174 /* This test makes some buggy mktime implementations loop.
1175 Give up after 60 seconds; a mktime slower than that
1176 isn't worth using anyway. */
1181 t = (time_t_max << 1) + 1;
1182 if (t <= time_t_max)
1186 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
1188 delta = time_t_max / 997; /* a suitable prime number */
1189 for (i = 0; i < N_STRINGS; i++)
1192 putenv ((char*) tz_strings[i]);
1194 for (t = 0; t <= time_t_max - delta; t += delta)
1195 if (! mktime_test (t))
1197 if (! (mktime_test ((time_t) 1)
1198 && mktime_test ((time_t) (60 * 60))
1199 && mktime_test ((time_t) (60 * 60 * 24))))
1202 for (j = 1; ; j <<= 1)
1203 if (! bigtime_test (j))
1205 else if (INT_MAX / 2 < j)
1207 if (! bigtime_test (INT_MAX))
1210 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
1212 [ac_cv_func_working_mktime=yes],
1213 [ac_cv_func_working_mktime=no],
1214 [ac_cv_func_working_mktime=no])])
1215 if test $ac_cv_func_working_mktime = no; then
1221 # AU::AM_FUNC_MKTIME
1222 # ------------------
1223 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
1228 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
1229 AC_DEFUN([AC_FUNC_MMAP],
1230 [AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
1231 AC_CHECK_HEADERS_ONCE([stdlib.h unistd.h sys/param.h])
1232 AC_CHECK_FUNCS([getpagesize])
1233 AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
1234 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
1235 [[/* malloc might have been renamed as rpl_malloc. */
1238 /* Thanks to Mike Haertel and Jim Avera for this test.
1239 Here is a matrix of mmap possibilities:
1240 mmap private not fixed
1241 mmap private fixed at somewhere currently unmapped
1242 mmap private fixed at somewhere already mapped
1243 mmap shared not fixed
1244 mmap shared fixed at somewhere currently unmapped
1245 mmap shared fixed at somewhere already mapped
1246 For private mappings, we should verify that changes cannot be read()
1247 back from the file, nor mmap's back from the file at a different
1248 address. (There have been systems where private was not correctly
1249 implemented like the infamous i386 svr4.0, and systems where the
1250 VM page cache was not coherent with the file system buffer cache
1251 like early versions of FreeBSD and possibly contemporary NetBSD.)
1252 For shared mappings, we should conversely verify that changes get
1253 propagated back to all the places they're supposed to be.
1255 Grep wants private fixed already mapped.
1256 The main things grep needs to know about mmap are:
1257 * does it exist and is it safe to write into the mmap'd area
1258 * how to use it (BSD variants) */
1261 #include <sys/mman.h>
1263 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
1267 /* This mess was copied from the GNU getpagesize.h. */
1268 #ifndef HAVE_GETPAGESIZE
1269 # ifdef _SC_PAGESIZE
1270 # define getpagesize() sysconf(_SC_PAGESIZE)
1271 # else /* no _SC_PAGESIZE */
1272 # ifdef HAVE_SYS_PARAM_H
1273 # include <sys/param.h>
1274 # ifdef EXEC_PAGESIZE
1275 # define getpagesize() EXEC_PAGESIZE
1276 # else /* no EXEC_PAGESIZE */
1278 # define getpagesize() NBPG * CLSIZE
1281 # endif /* no CLSIZE */
1282 # else /* no NBPG */
1284 # define getpagesize() NBPC
1285 # else /* no NBPC */
1287 # define getpagesize() PAGESIZE
1288 # endif /* PAGESIZE */
1289 # endif /* no NBPC */
1290 # endif /* no NBPG */
1291 # endif /* no EXEC_PAGESIZE */
1292 # else /* no HAVE_SYS_PARAM_H */
1293 # define getpagesize() 8192 /* punt totally */
1294 # endif /* no HAVE_SYS_PARAM_H */
1295 # endif /* no _SC_PAGESIZE */
1297 #endif /* no HAVE_GETPAGESIZE */
1302 char *data, *data2, *data3;
1307 pagesize = getpagesize ();
1309 /* First, make a file with some known garbage in it. */
1310 data = (char *) malloc (pagesize);
1313 for (i = 0; i < pagesize; ++i)
1314 *(data + i) = rand ();
1316 fd = creat ("conftest.mmap", 0600);
1319 if (write (fd, data, pagesize) != pagesize)
1323 /* Next, check that the tail of a page is zero-filled. File must have
1324 non-zero length, otherwise we risk SIGBUS for entire page. */
1325 fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
1329 if (write (fd2, cdata2, 1) != 1)
1331 data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
1332 if (data2 == MAP_FAILED)
1334 for (i = 0; i < pagesize; ++i)
1338 if (munmap (data2, pagesize))
1341 /* Next, try to mmap the file at a fixed address which already has
1342 something else allocated at it. If we can, also make sure that
1343 we see the same garbage. */
1344 fd = open ("conftest.mmap", O_RDWR);
1347 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1348 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1350 for (i = 0; i < pagesize; ++i)
1351 if (*(data + i) != *(data2 + i))
1354 /* Finally, make sure that changes to the mapped area do not
1355 percolate back to the file as seen by read(). (This is a bug on
1356 some variants of i386 svr4.0.) */
1357 for (i = 0; i < pagesize; ++i)
1358 *(data2 + i) = *(data2 + i) + 1;
1359 data3 = (char *) malloc (pagesize);
1362 if (read (fd, data3, pagesize) != pagesize)
1364 for (i = 0; i < pagesize; ++i)
1365 if (*(data + i) != *(data3 + i))
1370 [ac_cv_func_mmap_fixed_mapped=yes],
1371 [ac_cv_func_mmap_fixed_mapped=no],
1372 [case "$host_os" in # ((
1373 # Guess yes on platforms where we know the result.
1374 linux*) ac_cv_func_mmap_fixed_mapped=yes ;;
1375 # If we don't know, assume the worst.
1376 *) ac_cv_func_mmap_fixed_mapped=no ;;
1378 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1379 AC_DEFINE([HAVE_MMAP], [1],
1380 [Define to 1 if you have a working `mmap' system call.])
1382 rm -f conftest.mmap conftest.txt
1388 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1393 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1394 AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
1395 AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
1396 AC_DEFUN([AC_FUNC_OBSTACK],
1397 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1398 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1400 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1401 [@%:@include "obstack.h"]],
1402 [[struct obstack mem;
1403 @%:@define obstack_chunk_alloc malloc
1404 @%:@define obstack_chunk_free free
1405 obstack_init (&mem);
1406 obstack_free (&mem, 0);]])],
1407 [ac_cv_func_obstack=yes],
1408 [ac_cv_func_obstack=no])])
1409 if test $ac_cv_func_obstack = yes; then
1410 AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1417 # AU::AM_FUNC_OBSTACK
1418 # -------------------
1419 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1423 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
1424 # -------------------------------------
1425 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
1426 AC_DEFUN([_AC_FUNC_REALLOC_IF],
1427 [AC_REQUIRE([AC_HEADER_STDC])dnl
1428 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
1429 AC_CHECK_HEADERS(stdlib.h)
1430 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
1433 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1434 # include <stdlib.h>
1439 [return ! realloc (0, 0);])],
1440 [ac_cv_func_realloc_0_nonnull=yes],
1441 [ac_cv_func_realloc_0_nonnull=no],
1442 [case "$host_os" in # ((
1443 # Guess yes on platforms where we know the result.
1444 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
1445 | hpux* | solaris* | cygwin* | mingw*)
1446 ac_cv_func_realloc_0_nonnull=yes ;;
1447 # If we don't know, assume the worst.
1448 *) ac_cv_func_realloc_0_nonnull=no ;;
1450 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
1456 # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
1458 AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
1459 AC_DEFUN([AC_FUNC_REALLOC],
1460 [_AC_FUNC_REALLOC_IF(
1461 [AC_DEFINE([HAVE_REALLOC], 1,
1462 [Define to 1 if your system has a GNU libc compatible `realloc'
1463 function, and to 0 otherwise.])],
1464 [AC_DEFINE([HAVE_REALLOC], 0)
1465 AC_LIBOBJ([realloc])
1466 AC_DEFINE([realloc], [rpl_realloc],
1467 [Define to rpl_realloc if the replacement function should be used.])])
1471 # AC_FUNC_SELECT_ARGTYPES
1472 # -----------------------
1473 # Determine the correct type to be passed to each of the `select'
1474 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1475 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1476 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1477 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1478 AC_CACHE_CHECK([types of arguments for select],
1479 [ac_cv_func_select_args],
1480 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1481 for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
1482 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1485 [AC_INCLUDES_DEFAULT
1486 #ifdef HAVE_SYS_SELECT_H
1487 # include <sys/select.h>
1489 #ifdef HAVE_SYS_SOCKET_H
1490 # include <sys/socket.h>
1493 [extern int select ($ac_arg1,
1494 $ac_arg234, $ac_arg234, $ac_arg234,
1496 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1500 # Provide a safe default value.
1501 : "${ac_cv_func_select_args=int,int *,struct timeval *}"
1503 ac_save_IFS=$IFS; IFS=','
1504 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1507 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1508 [Define to the type of arg 1 for `select'.])
1509 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1510 [Define to the type of args 2, 3 and 4 for `select'.])
1511 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1512 [Define to the type of arg 5 for `select'.])
1514 ])# AC_FUNC_SELECT_ARGTYPES
1519 AC_DEFUN([AC_FUNC_SETPGRP],
1520 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1522 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1523 [/* If this system has a BSD-style setpgrp which takes arguments,
1524 setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1525 exit successfully. */
1526 return setpgrp (1,1) != -1;])],
1527 [ac_cv_func_setpgrp_void=no],
1528 [ac_cv_func_setpgrp_void=yes],
1529 [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1530 if test $ac_cv_func_setpgrp_void = yes; then
1531 AC_DEFINE(SETPGRP_VOID, 1,
1532 [Define to 1 if the `setpgrp' function takes no argument.])
1537 # _AC_FUNC_STAT(STAT | LSTAT)
1538 # ---------------------------
1539 # Determine whether stat or lstat have the bug that it succeeds when
1540 # given the zero-length file name argument. The stat and lstat from
1541 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1543 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1544 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1546 m4_define([_AC_FUNC_STAT],
1547 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1548 AC_CACHE_CHECK([whether $1 accepts an empty string],
1549 [ac_cv_func_$1_empty_string_bug],
1550 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1552 return $1 ("", &sbuf) == 0;]])],
1553 [ac_cv_func_$1_empty_string_bug=no],
1554 [ac_cv_func_$1_empty_string_bug=yes],
1555 [ac_cv_func_$1_empty_string_bug=yes])])
1556 if test $ac_cv_func_$1_empty_string_bug = yes; then
1558 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1559 [Define to 1 if `$1' has the bug that it succeeds when
1560 given the zero-length file name argument.])
1565 # AC_FUNC_STAT & AC_FUNC_LSTAT
1566 # ----------------------------
1567 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1568 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1573 m4_define([_AC_LIBOBJ_STRTOD],
1576 if test $ac_cv_func_pow = no; then
1577 AC_CHECK_LIB(m, pow,
1579 [AC_MSG_WARN([cannot find library containing definition of pow])])
1581 ])# _AC_LIBOBJ_STRTOD
1586 AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
1587 AC_DEFUN([AC_FUNC_STRTOD],
1588 [AC_SUBST(POW_LIB)dnl
1589 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1590 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1591 ]AC_INCLUDES_DEFAULT[
1599 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1600 char *string = " +69";
1603 value = strtod (string, &term);
1604 if (value != 69 || term != (string + 4))
1609 /* Under Solaris 2.4, strtod returns the wrong value for the
1610 terminating character under some conditions. */
1611 char *string = "NaN";
1613 strtod (string, &term);
1614 if (term != string && *(term - 1) == 0)
1620 ac_cv_func_strtod=yes,
1621 ac_cv_func_strtod=no,
1622 ac_cv_func_strtod=no)])
1623 if test $ac_cv_func_strtod = no; then
1631 AC_DEFUN([AC_FUNC_STRTOLD],
1633 AC_CACHE_CHECK([whether strtold conforms to C99],
1634 [ac_cv_func_strtold],
1637 [[/* On HP-UX before 11.23, strtold returns a struct instead of
1638 long double. Reject implementations like that, by requiring
1639 compatibility with the C99 prototype. */
1640 # include <stdlib.h>
1641 static long double (*p) (char const *, char **) = strtold;
1643 test (char const *nptr, char **endptr)
1646 r = strtold (nptr, endptr);
1649 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
1650 [ac_cv_func_strtold=yes],
1651 [ac_cv_func_strtold=no])])
1652 if test $ac_cv_func_strtold = yes; then
1653 AC_DEFINE([HAVE_STRTOLD], 1,
1654 [Define to 1 if strtold exists and conforms to C99.])
1659 # AU::AM_FUNC_STRTOD
1660 # ------------------
1661 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1664 # AC_FUNC_STRERROR_R
1665 # ------------------
1666 AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
1667 AC_DEFUN([AC_FUNC_STRERROR_R],
1668 [AC_CHECK_DECLS([strerror_r])
1669 AC_CHECK_FUNCS([strerror_r])
1670 AC_CACHE_CHECK([whether strerror_r returns char *],
1671 ac_cv_func_strerror_r_char_p,
1673 ac_cv_func_strerror_r_char_p=no
1674 if test $ac_cv_have_decl_strerror_r = yes; then
1675 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1678 char x = *strerror_r (0, buf, sizeof buf);
1679 char *p = strerror_r (0, buf, sizeof buf);
1682 ac_cv_func_strerror_r_char_p=yes)
1684 # strerror_r is not declared. Choose between
1685 # systems that have relatively inaccessible declarations for the
1686 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1687 # former has a strerror_r that returns char*, while the latter
1688 # has a strerror_r that returns `int'.
1689 # This test should segfault on the DEC system.
1690 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1691 extern char *strerror_r ();],
1693 char x = *strerror_r (0, buf, sizeof buf);
1694 return ! isalpha (x);]])],
1695 ac_cv_func_strerror_r_char_p=yes, , :)
1698 if test $ac_cv_func_strerror_r_char_p = yes; then
1699 AC_DEFINE([STRERROR_R_CHAR_P], 1,
1700 [Define to 1 if strerror_r returns char *.])
1702 ])# AC_FUNC_STRERROR_R
1707 AC_DEFUN([AC_FUNC_STRFTIME],
1708 [AC_CHECK_FUNCS(strftime, [],
1709 [# strftime is in -lintl on SCO UNIX.
1710 AC_CHECK_LIB(intl, strftime,
1711 [AC_DEFINE(HAVE_STRFTIME)
1712 LIBS="-lintl $LIBS"])])dnl
1713 ])# AC_FUNC_STRFTIME
1718 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
1719 AC_DEFUN([AC_FUNC_STRNLEN],
1720 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
1721 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1722 AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1723 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1725 #define S_LEN (sizeof S - 1)
1727 /* At least one implementation is buggy: that of AIX 4.3 would
1728 give strnlen (S, 1) == 3. */
1731 for (i = 0; i < S_LEN + 1; ++i)
1733 int expected = i <= S_LEN ? i : S_LEN;
1734 if (strnlen (S, i) != expected)
1739 [ac_cv_func_strnlen_working=yes],
1740 [ac_cv_func_strnlen_working=no],
1741 [# Guess no on AIX systems, yes otherwise.
1743 aix*) ac_cv_func_strnlen_working=no;;
1744 *) ac_cv_func_strnlen_working=yes;;
1746 test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1750 # AC_FUNC_SETVBUF_REVERSED
1751 # ------------------------
1752 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1753 [AC_DIAGNOSE([obsolete],
1754 [The macro `$0' is obsolete. Remove it and all references to SETVBUF_REVERSED.])dnl
1755 AC_CACHE_VAL([ac_cv_func_setvbuf_reversed], [ac_cv_func_setvbuf_reversed=no])
1756 ])# AC_FUNC_SETVBUF_REVERSED
1759 # AU::AC_SETVBUF_REVERSED
1760 # -----------------------
1761 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1766 AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
1767 AC_DEFUN([AC_FUNC_STRCOLL],
1768 [AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
1769 AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1770 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1771 [[return (strcoll ("abc", "def") >= 0 ||
1772 strcoll ("ABC", "DEF") >= 0 ||
1773 strcoll ("123", "456") >= 0)]])],
1774 ac_cv_func_strcoll_works=yes,
1775 ac_cv_func_strcoll_works=no,
1776 [case "$host_os" in # ((
1777 # Guess yes on glibc systems.
1778 *-gnu*) ac_cv_func_strcoll_works=yes ;;
1779 # If we don't know, assume the worst.
1780 *) ac_cv_func_strcoll_works=no ;;
1782 if test $ac_cv_func_strcoll_works = yes; then
1783 AC_DEFINE(HAVE_STRCOLL, 1,
1784 [Define to 1 if you have the `strcoll' function and it is properly
1792 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1795 # AC_FUNC_UTIME_NULL
1796 # ------------------
1797 AC_DEFUN([AC_FUNC_UTIME_NULL],
1798 [AC_CHECK_HEADERS_ONCE(utime.h)
1799 AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1800 [rm -f conftest.data; >conftest.data
1801 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1802 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1807 return ! (stat ("conftest.data", &s) == 0
1808 && utime ("conftest.data", 0) == 0
1809 && stat ("conftest.data", &t) == 0
1810 && t.st_mtime >= s.st_mtime
1811 && t.st_mtime - s.st_mtime < 120);]])],
1812 ac_cv_func_utime_null=yes,
1813 ac_cv_func_utime_null=no,
1814 ac_cv_func_utime_null='guessing yes')])
1815 if test "x$ac_cv_func_utime_null" != xno; then
1816 ac_cv_func_utime_null=yes
1817 AC_DEFINE(HAVE_UTIME_NULL, 1,
1818 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1822 ])# AC_FUNC_UTIME_NULL
1827 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1832 AN_FUNCTION([fork], [AC_FUNC_FORK])
1833 AN_FUNCTION([vfork], [AC_FUNC_FORK])
1834 AC_DEFUN([AC_FUNC_FORK],
1835 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1836 AC_CHECK_HEADERS(vfork.h)
1837 AC_CHECK_FUNCS(fork vfork)
1838 if test "x$ac_cv_func_fork" = xyes; then
1841 ac_cv_func_fork_works=$ac_cv_func_fork
1843 if test "x$ac_cv_func_fork_works" = xcross; then
1845 *-*-amigaos* | *-*-msdosdjgpp*)
1846 # Override, as these systems have only a dummy fork() stub
1847 ac_cv_func_fork_works=no
1850 ac_cv_func_fork_works=yes
1853 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1855 ac_cv_func_vfork_works=$ac_cv_func_vfork
1856 if test "x$ac_cv_func_vfork" = xyes; then
1859 if test "x$ac_cv_func_fork_works" = xcross; then
1860 ac_cv_func_vfork_works=$ac_cv_func_vfork
1861 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1864 if test "x$ac_cv_func_vfork_works" = xyes; then
1865 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1867 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1869 if test "x$ac_cv_func_fork_works" = xyes; then
1870 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1877 AC_DEFUN([_AC_FUNC_FORK],
1878 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1880 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1882 /* By Ruediger Kuhlmann. */
1885 [ac_cv_func_fork_works=yes],
1886 [ac_cv_func_fork_works=no],
1887 [ac_cv_func_fork_works=cross])])]
1893 AC_DEFUN([_AC_FUNC_VFORK],
1894 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1895 [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
1896 ]AC_INCLUDES_DEFAULT[
1898 #include <sys/wait.h>
1904 do_nothing (int sig)
1909 /* On some sparc systems, changes by the child to local and incoming
1910 argument registers are propagated back to the parent. The compiler
1911 is told about this with #include <vfork.h>, but some compilers
1912 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1913 static variable whose address is put into a register that is
1914 clobbered by the vfork. */
1916 sparc_address_test (int arg)
1936 pid_t parent = getpid ();
1939 sparc_address_test (0);
1941 /* On Solaris 2.4, changes by the child to the signal handler
1942 also munge signal handlers in the parent. To detect this,
1943 start by putting the parent's handler in a known state. */
1944 signal (SIGTERM, SIG_DFL);
1949 /* Here is another test for sparc vfork register problems. This
1950 test uses lots of local variables, at least as many local
1951 variables as main has allocated so far including compiler
1952 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1953 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1954 reuse the register of parent for one of the local variables,
1955 since it will think that parent can't possibly be used any more
1956 in this routine. Assigning to the local variable will thus
1957 munge parent in the parent process. */
1959 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1960 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1961 /* Convince the compiler that p..p7 are live; otherwise, it might
1962 use the same hardware register for all 8 local variables. */
1963 if (p != p1 || p != p2 || p != p3 || p != p4
1964 || p != p5 || p != p6 || p != p7)
1967 /* Alter the child's signal handler. */
1968 if (signal (SIGTERM, do_nothing) != SIG_DFL)
1971 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1972 from child file descriptors. If the child closes a descriptor
1973 before it execs or exits, this munges the parent's descriptor
1974 as well. Test for this by closing stdout in the child. */
1975 _exit(close(fileno(stdout)) != 0);
1980 while (wait(&status) != child)
1983 /* Was there some problem with vforking? */
1986 /* Did the child munge the parent's signal handler? */
1987 || signal (SIGTERM, SIG_DFL) != SIG_DFL
1989 /* Did the child fail? (This shouldn't happen.) */
1992 /* Did the vfork/compiler bug occur? */
1993 || parent != getpid()
1995 /* Did the file descriptor bug occur? */
1996 || fstat(fileno(stdout), &st) != 0
2000 [ac_cv_func_vfork_works=yes],
2001 [ac_cv_func_vfork_works=no],
2002 [ac_cv_func_vfork_works=cross])])
2008 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
2012 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
2017 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
2018 # That the logical name!
2019 AC_DEFUN([AC_FUNC_VPRINTF],
2020 [AC_CHECK_FUNCS(vprintf, []
2021 [AC_CHECK_FUNC(_doprnt,
2022 [AC_DEFINE(HAVE_DOPRNT, 1,
2023 [Define to 1 if you don't have `vprintf' but do have
2030 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
2035 # Don't bother too hard maintaining this macro, as it's obsoleted.
2036 # We don't AU define it, since we don't have any alternative to propose,
2037 # any invocation should be removed, and the code adjusted.
2038 AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
2039 AC_DEFUN([AC_FUNC_WAIT3],
2040 [AC_DIAGNOSE([obsolete],
2041 [$0: `wait3' has been removed from POSIX.
2042 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
2043 AC_CACHE_CHECK([for wait3 that fills in rusage],
2044 [ac_cv_func_wait3_rusage],
2045 [AC_RUN_IFELSE([AC_LANG_SOURCE(
2046 [AC_INCLUDES_DEFAULT[
2047 #include <sys/time.h>
2048 #include <sys/resource.h>
2049 #include <sys/wait.h>
2050 /* HP-UX has wait3 but does not fill in rusage at all. */
2056 /* Use a field that we can force nonzero --
2057 voluntary context switches.
2058 For systems like NeXT and OSF/1 that don't set it,
2059 also use the system CPU time. And page faults (I/O) for Linux. */
2061 r.ru_stime.tv_sec = 0;
2062 r.ru_stime.tv_usec = 0;
2063 r.ru_majflt = r.ru_minflt = 0;
2066 case 0: /* Child. */
2067 sleep(1); /* Give up the CPU. */
2070 case -1: /* What can we do? */
2073 default: /* Parent. */
2075 /* Avoid "text file busy" from rm on fast HP-UX machines. */
2077 return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
2078 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
2081 [ac_cv_func_wait3_rusage=yes],
2082 [ac_cv_func_wait3_rusage=no],
2083 [ac_cv_func_wait3_rusage=no])])
2084 if test $ac_cv_func_wait3_rusage = yes; then
2085 AC_DEFINE(HAVE_WAIT3, 1,
2086 [Define to 1 if you have the `wait3' system call.
2087 Deprecated, you should no longer depend upon `wait3'.])
2094 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])