1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
3 # Copyright (C) 2000-2011 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])AC_DEFINE(AS_TR_CPP([HAVE_$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 ()
330 static char *addr = 0;
335 return find_stack_direction ();
338 return (&dummy > addr) ? 1 : -1;
344 return find_stack_direction () < 0;
346 [ac_cv_c_stack_direction=1],
347 [ac_cv_c_stack_direction=-1],
348 [ac_cv_c_stack_direction=0])])
349 AH_VERBATIM([STACK_DIRECTION],
350 [/* If using the C implementation of alloca, define if you know the
351 direction of stack growth for your system; otherwise it will be
352 automatically deduced at runtime.
353 STACK_DIRECTION > 0 => grows toward higher addresses
354 STACK_DIRECTION < 0 => grows toward lower addresses
355 STACK_DIRECTION = 0 => direction of growth unknown */
356 @%:@undef STACK_DIRECTION])dnl
357 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
358 ])# _AC_LIBOBJ_ALLOCA
363 AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
364 AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
365 AC_DEFUN([AC_FUNC_ALLOCA],
366 [AC_REQUIRE([AC_TYPE_SIZE_T])]dnl
367 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
368 # for constant arguments. Useless!
369 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
371 [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
372 [[char *p = (char *) alloca (2 * sizeof (int));
373 if (p) return 0;]])],
374 [ac_cv_working_alloca_h=yes],
375 [ac_cv_working_alloca_h=no])])
376 if test $ac_cv_working_alloca_h = yes; then
377 AC_DEFINE(HAVE_ALLOCA_H, 1,
378 [Define to 1 if you have <alloca.h> and it should be used
382 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
383 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
385 # define alloca __builtin_alloca
389 # define alloca _alloca
391 # ifdef HAVE_ALLOCA_H
397 # ifndef alloca /* predefined by HP cc +Olibcalls */
398 void *alloca (size_t);
404 ]], [[char *p = (char *) alloca (1);
405 if (p) return 0;]])],
406 [ac_cv_func_alloca_works=yes],
407 [ac_cv_func_alloca_works=no])])
409 if test $ac_cv_func_alloca_works = yes; then
410 AC_DEFINE(HAVE_ALLOCA, 1,
411 [Define to 1 if you have `alloca', as a function or macro.])
420 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
425 # Determine whether chown accepts arguments of -1 for uid and gid.
426 AN_FUNCTION([chown], [AC_FUNC_CHOWN])
427 AC_DEFUN([AC_FUNC_CHOWN],
428 [AC_REQUIRE([AC_TYPE_UID_T])dnl
429 AC_CHECK_HEADERS(unistd.h)
430 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
431 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
434 [[ char *f = "conftest.chown";
435 struct stat before, after;
437 if (creat (f, 0600) < 0)
439 if (stat (f, &before) < 0)
441 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
443 if (stat (f, &after) < 0)
445 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
447 [ac_cv_func_chown_works=yes],
448 [ac_cv_func_chown_works=no],
449 [ac_cv_func_chown_works=no])
452 if test $ac_cv_func_chown_works = yes; then
453 AC_DEFINE(HAVE_CHOWN, 1,
454 [Define to 1 if your system has a working `chown' function.])
459 # AC_FUNC_CLOSEDIR_VOID
460 # ---------------------
461 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
463 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
464 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
465 AC_CACHE_CHECK([whether closedir returns void],
466 [ac_cv_func_closedir_void],
467 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
468 #include <$ac_header_dirent>
473 [[return closedir (opendir (".")) != 0;]])],
474 [ac_cv_func_closedir_void=no],
475 [ac_cv_func_closedir_void=yes],
476 [ac_cv_func_closedir_void=yes])])
477 if test $ac_cv_func_closedir_void = yes; then
478 AC_DEFINE(CLOSEDIR_VOID, 1,
479 [Define to 1 if the `closedir' function returns void instead
485 # AC_FUNC_ERROR_AT_LINE
486 # ---------------------
487 AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
488 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
489 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
490 [AC_LIBSOURCES([error.h, error.c])dnl
491 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
492 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
493 [error_at_line (0, 0, "", 0, "an error occurred");])],
494 [ac_cv_lib_error_at_line=yes],
495 [ac_cv_lib_error_at_line=no])])
496 if test $ac_cv_lib_error_at_line = no; then
502 # AU::AM_FUNC_ERROR_AT_LINE
503 # -------------------------
504 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
507 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
508 # -------------------------------------------------------------------------
509 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
510 # IF-FALSE. Use CACHE_VAR.
511 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
513 [for working $1 fnmatch],
515 [# Some versions of Solaris, SCO, and the GNU C Library
516 # have a broken or incompatible fnmatch.
517 # So we run a test program. If we are cross-compiling, take no chance.
518 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
521 [#include <fnmatch.h>
522 # define y(a, b, c) (fnmatch (a, b, c) == 0)
523 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
526 (!(y ("a*", "abc", 0)
527 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
528 && y ("a\\\\bc", "abc", 0)
529 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
531 && n ("*x", ".x", FNM_PERIOD)
532 && m4_if([$1], [GNU],
533 [y ("xxXX", "xXxX", FNM_CASEFOLD)
534 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
535 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
536 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
537 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
538 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
543 AS_IF([test $$2 = yes], [$3], [$4])
544 ])# _AC_FUNC_FNMATCH_IF
549 AC_DEFUN([AC_FUNC_FNMATCH],
550 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
551 [AC_DEFINE([HAVE_FNMATCH], 1,
552 [Define to 1 if your system has a working POSIX `fnmatch'
559 # Prepare the replacement of fnmatch.
560 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
561 [AC_REQUIRE([AC_C_CONST])dnl
562 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
563 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
564 AC_CHECK_DECLS([getenv])
565 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
566 AC_CHECK_HEADERS([wchar.h wctype.h])
568 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
569 AC_DEFINE(fnmatch, rpl_fnmatch,
570 [Define to rpl_fnmatch if the replacement function should be used.])
571 ])# _AC_LIBOBJ_FNMATCH
576 AC_DEFUN([AC_REPLACE_FNMATCH],
577 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
578 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
579 [_AC_LIBOBJ_FNMATCH])
580 ])# AC_REPLACE_FNMATCH
583 # AC_FUNC_FNMATCH_GNU
584 # -------------------
585 AC_DEFUN([AC_FUNC_FNMATCH_GNU],
586 [AC_REQUIRE([AC_GNU_SOURCE])
587 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
588 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
589 [_AC_LIBOBJ_FNMATCH])
590 ])# AC_FUNC_FNMATCH_GNU
593 # AU::AM_FUNC_FNMATCH
594 # AU::fp_FUNC_FNMATCH
595 # -------------------
596 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
597 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
602 AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
603 AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
604 AC_DEFUN([AC_FUNC_FSEEKO],
605 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
606 [ac_cv_sys_largefile_source],
607 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
608 [[#include <sys/types.h> /* for off_t */
609 #include <stdio.h>]],
610 [[int (*fp) (FILE *, off_t, int) = fseeko;
611 return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
613 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
614 # in glibc 2.1.3, but that breaks too many other things.
615 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
616 if test $ac_cv_sys_largefile_source != unknown; then
617 AC_DEFINE(HAVE_FSEEKO, 1,
618 [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
625 # Try to find `getgroups', and check that it works.
626 # When cross-compiling, assume getgroups is broken.
627 AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
628 AC_DEFUN([AC_FUNC_GETGROUPS],
629 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
630 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
631 AC_CHECK_FUNC(getgroups)
633 # If we don't yet have getgroups, see if it's in -lbsd.
634 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
636 if test $ac_cv_func_getgroups = no; then
637 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
640 # Run the program to test the functionality of the system-supplied
641 # getgroups function only if there is such a function.
642 if test $ac_cv_func_getgroups = yes; then
643 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
644 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
645 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
646 return getgroups (0, 0) == -1;]])],
647 [ac_cv_func_getgroups_works=yes],
648 [ac_cv_func_getgroups_works=no],
649 [ac_cv_func_getgroups_works=no])
652 ac_cv_func_getgroups_works=no
654 if test $ac_cv_func_getgroups_works = yes; then
655 AC_DEFINE(HAVE_GETGROUPS, 1,
656 [Define to 1 if your system has a working `getgroups' function.])
659 ])# AC_FUNC_GETGROUPS
662 # _AC_LIBOBJ_GETLOADAVG
663 # ---------------------
664 # Set up the AC_LIBOBJ replacement of `getloadavg'.
665 m4_define([_AC_LIBOBJ_GETLOADAVG],
666 [AC_LIBOBJ(getloadavg)
667 AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
668 # Figure out what our getloadavg.c needs.
670 AC_CHECK_HEADER(sys/dg_sys_info.h,
672 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
673 AC_CHECK_LIB(dgc, dg_sys_info)])
675 AC_CHECK_HEADER(locale.h)
676 AC_CHECK_FUNCS(setlocale)
678 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
679 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
680 # Irix 4.0.5F has the header but not the library.
681 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
682 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
684 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
687 if test $ac_have_func = no; then
688 AC_CHECK_HEADER(inq_stats/cpustats.h,
690 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
691 AC_DEFINE(UMAX4_3, 1,
692 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
693 instead of <sys/cpustats.h>.])])
696 if test $ac_have_func = no; then
697 AC_CHECK_HEADER(sys/cpustats.h,
698 [ac_have_func=yes; AC_DEFINE(UMAX)])
701 if test $ac_have_func = no; then
702 AC_CHECK_HEADERS(mach/mach.h)
705 AC_CHECK_HEADERS(nlist.h,
706 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
707 [AC_DEFINE(NLIST_NAME_UNION, 1,
708 [Define to 1 if your `struct nlist' has an
709 `n_un' member. Obsolete, depend on
710 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
711 [@%:@include <nlist.h>])
713 ])# _AC_LIBOBJ_GETLOADAVG
718 AC_DEFUN([AC_FUNC_GETLOADAVG],
719 [ac_have_func=no # yes means we've found a way to get the load average.
721 # Make sure getloadavg.c is where it belongs, at configure-time.
722 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
723 AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
727 # Check for getloadavg, but be sure not to touch the cache variable.
728 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
730 # On HPUX9, an unprivileged user can get load averages through this function.
731 AC_CHECK_FUNCS(pstat_getdynamic)
733 # Solaris has libkstat which does not require root.
734 AC_CHECK_LIB(kstat, kstat_open)
735 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
737 # Some systems with -lutil have (and need) -lkvm as well, some do not.
738 # On Solaris, -lkvm requires nlist from -lelf, so check that first
739 # to get the right answer into the cache.
740 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
741 if test $ac_have_func = no; then
742 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
744 if test $ac_have_func = no; then
745 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
746 # Check for the 4.4BSD definition of getloadavg.
747 AC_CHECK_LIB(util, getloadavg,
748 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
751 if test $ac_have_func = no; then
752 # There is a commonly available library for RS/6000 AIX.
753 # Since it is not a standard part of AIX, it might be installed locally.
754 ac_getloadavg_LIBS=$LIBS
755 LIBS="-L/usr/local/lib $LIBS"
756 AC_CHECK_LIB(getloadavg, getloadavg,
757 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
760 # Make sure it is really in the library, if we think we found it,
761 # otherwise set up the replacement function.
762 AC_CHECK_FUNCS(getloadavg, [],
763 [_AC_LIBOBJ_GETLOADAVG])
765 # Some definitions of getloadavg require that the program be installed setgid.
766 AC_CACHE_CHECK(whether getloadavg requires setgid,
767 ac_cv_func_getloadavg_setgid,
768 [AC_EGREP_CPP([Yowza Am I SETGID yet],
769 [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
770 #ifdef LDAV_PRIVILEGED
771 Yowza Am I SETGID yet
773 ac_cv_func_getloadavg_setgid=yes,
774 ac_cv_func_getloadavg_setgid=no)])
775 if test $ac_cv_func_getloadavg_setgid = yes; then
777 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
778 [Define to 1 if the `getloadavg' function needs to be run setuid
783 AC_SUBST(NEED_SETGID)dnl
785 if test $ac_cv_func_getloadavg_setgid = yes; then
786 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
787 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
788 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
789 # If we got an error (system does not support symlinks), try without -L.
790 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
791 ac_cv_group_kmem=`AS_ECHO(["$ac_ls_output"]) \
792 | sed -ne ['s/[ ][ ]*/ /g;
793 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
796 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
798 if test "x$ac_save_LIBS" = x; then
799 GETLOADAVG_LIBS=$LIBS
801 GETLOADAVG_LIBS=`AS_ECHO(["$LIBS"]) | sed "s|$ac_save_LIBS||"`
805 AC_SUBST(GETLOADAVG_LIBS)dnl
806 ])# AC_FUNC_GETLOADAVG
811 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
816 AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
817 AC_DEFUN([AC_FUNC_GETMNTENT],
818 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
819 # -lseq on Dynix/PTX, -lgen on Unixware.
820 AC_SEARCH_LIBS(getmntent, [sun seq gen],
821 [ac_cv_func_getmntent=yes
822 AC_DEFINE([HAVE_GETMNTENT], 1,
823 [Define to 1 if you have the `getmntent' function.])],
824 [ac_cv_func_getmntent=no])
830 # Figure out whether getpgrp requires zero arguments.
831 AC_DEFUN([AC_FUNC_GETPGRP],
832 [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
833 ac_cv_func_getpgrp_void,
834 [# Use it with a single arg.
835 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
836 [ac_cv_func_getpgrp_void=no],
837 [ac_cv_func_getpgrp_void=yes])
839 if test $ac_cv_func_getpgrp_void = yes; then
840 AC_DEFINE(GETPGRP_VOID, 1,
841 [Define to 1 if the `getpgrp' function requires zero arguments.])
846 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
847 # -------------------------------------
848 # When cross-compiling, be pessimistic so we will end up using the
849 # replacement version of lstat that checks for trailing slashes and
850 # calls lstat a second time when necessary.
851 AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
852 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
854 [whether lstat correctly handles trailing slash],
855 [ac_cv_func_lstat_dereferences_slashed_symlink],
856 [rm -f conftest.sym conftest.file
858 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
859 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
861 /* Linux will dereference the symlink and fail, as required by POSIX.
862 That is better in the sense that it means we will not
863 have to compile and use the lstat wrapper. */
864 return lstat ("conftest.sym/", &sbuf) == 0;])],
865 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
866 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
867 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
869 # If the `ln -s' command failed, then we probably don't even
870 # have an lstat function.
871 ac_cv_func_lstat_dereferences_slashed_symlink=no
873 rm -f conftest.sym conftest.file
876 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
877 AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
878 [Define to 1 if `lstat' dereferences a symlink specified
879 with a trailing slash.])
881 if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
887 # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
888 # ------------------------------------
889 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
890 AC_DEFUN([_AC_FUNC_MALLOC_IF],
891 [AC_REQUIRE([AC_HEADER_STDC])dnl
892 AC_CHECK_HEADERS(stdlib.h)
893 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
896 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
902 [return ! malloc (0);])],
903 [ac_cv_func_malloc_0_nonnull=yes],
904 [ac_cv_func_malloc_0_nonnull=no],
905 [ac_cv_func_malloc_0_nonnull=no])])
906 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
907 ])# _AC_FUNC_MALLOC_IF
912 # Report whether `malloc (0)' properly handled, and replace malloc if
914 AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
915 AC_DEFUN([AC_FUNC_MALLOC],
917 [AC_DEFINE([HAVE_MALLOC], 1,
918 [Define to 1 if your system has a GNU libc compatible `malloc'
919 function, and to 0 otherwise.])],
920 [AC_DEFINE([HAVE_MALLOC], 0)
922 AC_DEFINE([malloc], [rpl_malloc],
923 [Define to rpl_malloc if the replacement function should be used.])])
929 AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
930 AC_DEFUN([AC_FUNC_MBRTOWC],
932 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
936 [[@%:@include <wchar.h>]],
941 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
942 ac_cv_func_mbrtowc=yes,
943 ac_cv_func_mbrtowc=no)])
944 if test $ac_cv_func_mbrtowc = yes; then
945 AC_DEFINE([HAVE_MBRTOWC], 1,
946 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
953 AC_DEFUN([AC_FUNC_MEMCMP],
954 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
955 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
956 /* Some versions of memcmp are not 8-bit clean. */
957 char c0 = '\100', c1 = '\200', c2 = '\201';
958 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
961 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
962 or more and with at least one buffer not starting on a 4-byte boundary.
963 William Lewis provided this test program. */
968 for (i = 0; i < 4; i++)
972 strcpy (a, "--------01111111");
973 strcpy (b, "--------10000000");
974 if (memcmp (a, b, 16) >= 0)
980 [ac_cv_func_memcmp_working=yes],
981 [ac_cv_func_memcmp_working=no],
982 [ac_cv_func_memcmp_working=no])])
983 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
989 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
990 AC_DEFUN([AC_FUNC_MKTIME],
991 [AC_REQUIRE([AC_HEADER_TIME])dnl
992 AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
993 AC_CHECK_FUNCS_ONCE(alarm)
994 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
995 [AC_RUN_IFELSE([AC_LANG_SOURCE(
996 [[/* Test program from Paul Eggert and Tony Leneis. */
997 #ifdef TIME_WITH_SYS_TIME
998 # include <sys/time.h>
1001 # ifdef HAVE_SYS_TIME_H
1002 # include <sys/time.h>
1011 #ifdef HAVE_UNISTD_H
1012 # include <unistd.h>
1016 # define alarm(X) /* empty */
1019 /* Work around redefinition to rpl_putenv by other config tests. */
1022 static time_t time_t_max;
1023 static time_t time_t_min;
1025 /* Values we'll use to set the TZ environment variable. */
1026 static const char *tz_strings[] = {
1027 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
1028 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
1030 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
1032 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
1033 Based on a problem report from Andreas Jaeger. */
1035 spring_forward_gap ()
1037 /* glibc (up to about 1998-10-07) failed this test. */
1040 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1041 instead of "TZ=America/Vancouver" in order to detect the bug even
1042 on systems that don't support the Olson extension, or don't have the
1043 full zoneinfo tables installed. */
1044 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
1053 return mktime (&tm) != (time_t) -1;
1057 mktime_test1 (time_t now)
1060 return ! (lt = localtime (&now)) || mktime (lt) == now;
1064 mktime_test (time_t now)
1066 return (mktime_test1 (now)
1067 && mktime_test1 ((time_t) (time_t_max - now))
1068 && mktime_test1 ((time_t) (time_t_min + now)));
1074 /* Based on code from Ariel Faigon. */
1084 return tm.tm_mon == 2 && tm.tm_mday == 31;
1088 bigtime_test (int j)
1092 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
1094 if (now != (time_t) -1)
1096 struct tm *lt = localtime (&now);
1098 && lt->tm_year == tm.tm_year
1099 && lt->tm_mon == tm.tm_mon
1100 && lt->tm_mday == tm.tm_mday
1101 && lt->tm_hour == tm.tm_hour
1102 && lt->tm_min == tm.tm_min
1103 && lt->tm_sec == tm.tm_sec
1104 && lt->tm_yday == tm.tm_yday
1105 && lt->tm_wday == tm.tm_wday
1106 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
1107 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
1116 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
1117 ignoring leap seconds. */
1118 unsigned long int answer = 2527315200UL;
1122 tm.tm_year = 2050 - 1900;
1125 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
1128 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1129 instead of "TZ=America/Vancouver" in order to detect the bug even
1130 on systems that don't support the Olson extension, or don't have the
1131 full zoneinfo tables installed. */
1132 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
1136 /* Check that the result is either a failure, or close enough
1137 to the correct answer that we can assume the discrepancy is
1138 due to leap seconds. */
1139 return (t == (time_t) -1
1140 || (0 < t && answer - 120 <= t && t <= answer + 120));
1149 /* This test makes some buggy mktime implementations loop.
1150 Give up after 60 seconds; a mktime slower than that
1151 isn't worth using anyway. */
1156 t = (time_t_max << 1) + 1;
1157 if (t <= time_t_max)
1161 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
1163 delta = time_t_max / 997; /* a suitable prime number */
1164 for (i = 0; i < N_STRINGS; i++)
1167 putenv ((char*) tz_strings[i]);
1169 for (t = 0; t <= time_t_max - delta; t += delta)
1170 if (! mktime_test (t))
1172 if (! (mktime_test ((time_t) 1)
1173 && mktime_test ((time_t) (60 * 60))
1174 && mktime_test ((time_t) (60 * 60 * 24))))
1177 for (j = 1; ; j <<= 1)
1178 if (! bigtime_test (j))
1180 else if (INT_MAX / 2 < j)
1182 if (! bigtime_test (INT_MAX))
1185 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
1187 [ac_cv_func_working_mktime=yes],
1188 [ac_cv_func_working_mktime=no],
1189 [ac_cv_func_working_mktime=no])])
1190 if test $ac_cv_func_working_mktime = no; then
1196 # AU::AM_FUNC_MKTIME
1197 # ------------------
1198 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
1203 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
1204 AC_DEFUN([AC_FUNC_MMAP],
1205 [AC_CHECK_HEADERS_ONCE([stdlib.h unistd.h sys/param.h])
1206 AC_CHECK_FUNCS([getpagesize])
1207 AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
1208 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
1209 [[/* malloc might have been renamed as rpl_malloc. */
1212 /* Thanks to Mike Haertel and Jim Avera for this test.
1213 Here is a matrix of mmap possibilities:
1214 mmap private not fixed
1215 mmap private fixed at somewhere currently unmapped
1216 mmap private fixed at somewhere already mapped
1217 mmap shared not fixed
1218 mmap shared fixed at somewhere currently unmapped
1219 mmap shared fixed at somewhere already mapped
1220 For private mappings, we should verify that changes cannot be read()
1221 back from the file, nor mmap's back from the file at a different
1222 address. (There have been systems where private was not correctly
1223 implemented like the infamous i386 svr4.0, and systems where the
1224 VM page cache was not coherent with the file system buffer cache
1225 like early versions of FreeBSD and possibly contemporary NetBSD.)
1226 For shared mappings, we should conversely verify that changes get
1227 propagated back to all the places they're supposed to be.
1229 Grep wants private fixed already mapped.
1230 The main things grep needs to know about mmap are:
1231 * does it exist and is it safe to write into the mmap'd area
1232 * how to use it (BSD variants) */
1235 #include <sys/mman.h>
1237 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
1241 /* This mess was copied from the GNU getpagesize.h. */
1242 #ifndef HAVE_GETPAGESIZE
1243 # ifdef _SC_PAGESIZE
1244 # define getpagesize() sysconf(_SC_PAGESIZE)
1245 # else /* no _SC_PAGESIZE */
1246 # ifdef HAVE_SYS_PARAM_H
1247 # include <sys/param.h>
1248 # ifdef EXEC_PAGESIZE
1249 # define getpagesize() EXEC_PAGESIZE
1250 # else /* no EXEC_PAGESIZE */
1252 # define getpagesize() NBPG * CLSIZE
1255 # endif /* no CLSIZE */
1256 # else /* no NBPG */
1258 # define getpagesize() NBPC
1259 # else /* no NBPC */
1261 # define getpagesize() PAGESIZE
1262 # endif /* PAGESIZE */
1263 # endif /* no NBPC */
1264 # endif /* no NBPG */
1265 # endif /* no EXEC_PAGESIZE */
1266 # else /* no HAVE_SYS_PARAM_H */
1267 # define getpagesize() 8192 /* punt totally */
1268 # endif /* no HAVE_SYS_PARAM_H */
1269 # endif /* no _SC_PAGESIZE */
1271 #endif /* no HAVE_GETPAGESIZE */
1276 char *data, *data2, *data3;
1281 pagesize = getpagesize ();
1283 /* First, make a file with some known garbage in it. */
1284 data = (char *) malloc (pagesize);
1287 for (i = 0; i < pagesize; ++i)
1288 *(data + i) = rand ();
1290 fd = creat ("conftest.mmap", 0600);
1293 if (write (fd, data, pagesize) != pagesize)
1297 /* Next, check that the tail of a page is zero-filled. File must have
1298 non-zero length, otherwise we risk SIGBUS for entire page. */
1299 fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
1303 if (write (fd2, cdata2, 1) != 1)
1305 data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
1306 if (data2 == MAP_FAILED)
1308 for (i = 0; i < pagesize; ++i)
1312 if (munmap (data2, pagesize))
1315 /* Next, try to mmap the file at a fixed address which already has
1316 something else allocated at it. If we can, also make sure that
1317 we see the same garbage. */
1318 fd = open ("conftest.mmap", O_RDWR);
1321 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1322 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1324 for (i = 0; i < pagesize; ++i)
1325 if (*(data + i) != *(data2 + i))
1328 /* Finally, make sure that changes to the mapped area do not
1329 percolate back to the file as seen by read(). (This is a bug on
1330 some variants of i386 svr4.0.) */
1331 for (i = 0; i < pagesize; ++i)
1332 *(data2 + i) = *(data2 + i) + 1;
1333 data3 = (char *) malloc (pagesize);
1336 if (read (fd, data3, pagesize) != pagesize)
1338 for (i = 0; i < pagesize; ++i)
1339 if (*(data + i) != *(data3 + i))
1344 [ac_cv_func_mmap_fixed_mapped=yes],
1345 [ac_cv_func_mmap_fixed_mapped=no],
1346 [ac_cv_func_mmap_fixed_mapped=no])])
1347 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1348 AC_DEFINE([HAVE_MMAP], [1],
1349 [Define to 1 if you have a working `mmap' system call.])
1351 rm -f conftest.mmap conftest.txt
1357 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1362 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1363 AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
1364 AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
1365 AC_DEFUN([AC_FUNC_OBSTACK],
1366 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1367 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1369 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1370 [@%:@include "obstack.h"]],
1371 [[struct obstack mem;
1372 @%:@define obstack_chunk_alloc malloc
1373 @%:@define obstack_chunk_free free
1374 obstack_init (&mem);
1375 obstack_free (&mem, 0);]])],
1376 [ac_cv_func_obstack=yes],
1377 [ac_cv_func_obstack=no])])
1378 if test $ac_cv_func_obstack = yes; then
1379 AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1386 # AU::AM_FUNC_OBSTACK
1387 # -------------------
1388 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1392 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
1393 # -------------------------------------
1394 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
1395 AC_DEFUN([_AC_FUNC_REALLOC_IF],
1396 [AC_REQUIRE([AC_HEADER_STDC])dnl
1397 AC_CHECK_HEADERS(stdlib.h)
1398 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
1401 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1402 # include <stdlib.h>
1407 [return ! realloc (0, 0);])],
1408 [ac_cv_func_realloc_0_nonnull=yes],
1409 [ac_cv_func_realloc_0_nonnull=no],
1410 [ac_cv_func_realloc_0_nonnull=no])])
1411 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
1417 # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
1419 AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
1420 AC_DEFUN([AC_FUNC_REALLOC],
1421 [_AC_FUNC_REALLOC_IF(
1422 [AC_DEFINE([HAVE_REALLOC], 1,
1423 [Define to 1 if your system has a GNU libc compatible `realloc'
1424 function, and to 0 otherwise.])],
1425 [AC_DEFINE([HAVE_REALLOC], 0)
1426 AC_LIBOBJ([realloc])
1427 AC_DEFINE([realloc], [rpl_realloc],
1428 [Define to rpl_realloc if the replacement function should be used.])])
1432 # AC_FUNC_SELECT_ARGTYPES
1433 # -----------------------
1434 # Determine the correct type to be passed to each of the `select'
1435 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1436 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1437 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1438 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1439 AC_CACHE_CHECK([types of arguments for select],
1440 [ac_cv_func_select_args],
1441 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1442 for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
1443 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1446 [AC_INCLUDES_DEFAULT
1447 #ifdef HAVE_SYS_SELECT_H
1448 # include <sys/select.h>
1450 #ifdef HAVE_SYS_SOCKET_H
1451 # include <sys/socket.h>
1454 [extern int select ($ac_arg1,
1455 $ac_arg234, $ac_arg234, $ac_arg234,
1457 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1461 # Provide a safe default value.
1462 : "${ac_cv_func_select_args=int,int *,struct timeval *}"
1464 ac_save_IFS=$IFS; IFS=','
1465 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1468 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1469 [Define to the type of arg 1 for `select'.])
1470 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1471 [Define to the type of args 2, 3 and 4 for `select'.])
1472 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1473 [Define to the type of arg 5 for `select'.])
1475 ])# AC_FUNC_SELECT_ARGTYPES
1480 AC_DEFUN([AC_FUNC_SETPGRP],
1481 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1483 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1484 [/* If this system has a BSD-style setpgrp which takes arguments,
1485 setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1486 exit successfully. */
1487 return setpgrp (1,1) != -1;])],
1488 [ac_cv_func_setpgrp_void=no],
1489 [ac_cv_func_setpgrp_void=yes],
1490 [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1491 if test $ac_cv_func_setpgrp_void = yes; then
1492 AC_DEFINE(SETPGRP_VOID, 1,
1493 [Define to 1 if the `setpgrp' function takes no argument.])
1498 # _AC_FUNC_STAT(STAT | LSTAT)
1499 # ---------------------------
1500 # Determine whether stat or lstat have the bug that it succeeds when
1501 # given the zero-length file name argument. The stat and lstat from
1502 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1504 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1505 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1507 m4_define([_AC_FUNC_STAT],
1508 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1509 AC_CACHE_CHECK([whether $1 accepts an empty string],
1510 [ac_cv_func_$1_empty_string_bug],
1511 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1513 return $1 ("", &sbuf) == 0;]])],
1514 [ac_cv_func_$1_empty_string_bug=no],
1515 [ac_cv_func_$1_empty_string_bug=yes],
1516 [ac_cv_func_$1_empty_string_bug=yes])])
1517 if test $ac_cv_func_$1_empty_string_bug = yes; then
1519 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1520 [Define to 1 if `$1' has the bug that it succeeds when
1521 given the zero-length file name argument.])
1526 # AC_FUNC_STAT & AC_FUNC_LSTAT
1527 # ----------------------------
1528 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1529 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1534 m4_define([_AC_LIBOBJ_STRTOD],
1537 if test $ac_cv_func_pow = no; then
1538 AC_CHECK_LIB(m, pow,
1540 [AC_MSG_WARN([cannot find library containing definition of pow])])
1542 ])# _AC_LIBOBJ_STRTOD
1547 AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
1548 AC_DEFUN([AC_FUNC_STRTOD],
1549 [AC_SUBST(POW_LIB)dnl
1550 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1551 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1552 ]AC_INCLUDES_DEFAULT[
1560 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1561 char *string = " +69";
1564 value = strtod (string, &term);
1565 if (value != 69 || term != (string + 4))
1570 /* Under Solaris 2.4, strtod returns the wrong value for the
1571 terminating character under some conditions. */
1572 char *string = "NaN";
1574 strtod (string, &term);
1575 if (term != string && *(term - 1) == 0)
1581 ac_cv_func_strtod=yes,
1582 ac_cv_func_strtod=no,
1583 ac_cv_func_strtod=no)])
1584 if test $ac_cv_func_strtod = no; then
1592 AC_DEFUN([AC_FUNC_STRTOLD],
1594 AC_CACHE_CHECK([whether strtold conforms to C99],
1595 [ac_cv_func_strtold],
1598 [[/* On HP-UX before 11.23, strtold returns a struct instead of
1599 long double. Reject implementations like that, by requiring
1600 compatibility with the C99 prototype. */
1601 # include <stdlib.h>
1602 static long double (*p) (char const *, char **) = strtold;
1604 test (char const *nptr, char **endptr)
1607 r = strtold (nptr, endptr);
1610 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
1611 [ac_cv_func_strtold=yes],
1612 [ac_cv_func_strtold=no])])
1613 if test $ac_cv_func_strtold = yes; then
1614 AC_DEFINE([HAVE_STRTOLD], 1,
1615 [Define to 1 if strtold exists and conforms to C99.])
1620 # AU::AM_FUNC_STRTOD
1621 # ------------------
1622 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1625 # AC_FUNC_STRERROR_R
1626 # ------------------
1627 AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
1628 AC_DEFUN([AC_FUNC_STRERROR_R],
1629 [AC_CHECK_DECLS([strerror_r])
1630 AC_CHECK_FUNCS([strerror_r])
1631 AC_CACHE_CHECK([whether strerror_r returns char *],
1632 ac_cv_func_strerror_r_char_p,
1634 ac_cv_func_strerror_r_char_p=no
1635 if test $ac_cv_have_decl_strerror_r = yes; then
1636 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1639 char x = *strerror_r (0, buf, sizeof buf);
1640 char *p = strerror_r (0, buf, sizeof buf);
1643 ac_cv_func_strerror_r_char_p=yes)
1645 # strerror_r is not declared. Choose between
1646 # systems that have relatively inaccessible declarations for the
1647 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1648 # former has a strerror_r that returns char*, while the latter
1649 # has a strerror_r that returns `int'.
1650 # This test should segfault on the DEC system.
1651 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1652 extern char *strerror_r ();],
1654 char x = *strerror_r (0, buf, sizeof buf);
1655 return ! isalpha (x);]])],
1656 ac_cv_func_strerror_r_char_p=yes, , :)
1659 if test $ac_cv_func_strerror_r_char_p = yes; then
1660 AC_DEFINE([STRERROR_R_CHAR_P], 1,
1661 [Define to 1 if strerror_r returns char *.])
1663 ])# AC_FUNC_STRERROR_R
1668 AC_DEFUN([AC_FUNC_STRFTIME],
1669 [AC_CHECK_FUNCS(strftime, [],
1670 [# strftime is in -lintl on SCO UNIX.
1671 AC_CHECK_LIB(intl, strftime,
1672 [AC_DEFINE(HAVE_STRFTIME)
1673 LIBS="-lintl $LIBS"])])dnl
1674 ])# AC_FUNC_STRFTIME
1679 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
1680 AC_DEFUN([AC_FUNC_STRNLEN],
1681 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
1682 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1683 AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1684 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1686 #define S_LEN (sizeof S - 1)
1688 /* At least one implementation is buggy: that of AIX 4.3 would
1689 give strnlen (S, 1) == 3. */
1692 for (i = 0; i < S_LEN + 1; ++i)
1694 int expected = i <= S_LEN ? i : S_LEN;
1695 if (strnlen (S, i) != expected)
1700 [ac_cv_func_strnlen_working=yes],
1701 [ac_cv_func_strnlen_working=no],
1702 [# Guess no on AIX systems, yes otherwise.
1704 aix*) ac_cv_func_strnlen_working=no;;
1705 *) ac_cv_func_strnlen_working=yes;;
1707 test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1711 # AC_FUNC_SETVBUF_REVERSED
1712 # ------------------------
1713 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1714 [AC_DIAGNOSE([obsolete],
1715 [The macro `$0' is obsolete. Remove it and all references to SETVBUF_REVERSED.])dnl
1716 AC_CACHE_VAL([ac_cv_func_setvbuf_reversed], [ac_cv_func_setvbuf_reversed=no])
1717 ])# AC_FUNC_SETVBUF_REVERSED
1720 # AU::AC_SETVBUF_REVERSED
1721 # -----------------------
1722 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1727 AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
1728 AC_DEFUN([AC_FUNC_STRCOLL],
1729 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1730 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1731 [[return (strcoll ("abc", "def") >= 0 ||
1732 strcoll ("ABC", "DEF") >= 0 ||
1733 strcoll ("123", "456") >= 0)]])],
1734 ac_cv_func_strcoll_works=yes,
1735 ac_cv_func_strcoll_works=no,
1736 ac_cv_func_strcoll_works=no)])
1737 if test $ac_cv_func_strcoll_works = yes; then
1738 AC_DEFINE(HAVE_STRCOLL, 1,
1739 [Define to 1 if you have the `strcoll' function and it is properly
1747 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1750 # AC_FUNC_UTIME_NULL
1751 # ------------------
1752 AC_DEFUN([AC_FUNC_UTIME_NULL],
1753 [AC_CHECK_HEADERS_ONCE(utime.h)
1754 AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1755 [rm -f conftest.data; >conftest.data
1756 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1757 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1762 return ! (stat ("conftest.data", &s) == 0
1763 && utime ("conftest.data", 0) == 0
1764 && stat ("conftest.data", &t) == 0
1765 && t.st_mtime >= s.st_mtime
1766 && t.st_mtime - s.st_mtime < 120);]])],
1767 ac_cv_func_utime_null=yes,
1768 ac_cv_func_utime_null=no,
1769 ac_cv_func_utime_null='guessing yes')])
1770 if test "x$ac_cv_func_utime_null" != xno; then
1771 ac_cv_func_utime_null=yes
1772 AC_DEFINE(HAVE_UTIME_NULL, 1,
1773 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1777 ])# AC_FUNC_UTIME_NULL
1782 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1787 AN_FUNCTION([fork], [AC_FUNC_FORK])
1788 AN_FUNCTION([vfork], [AC_FUNC_FORK])
1789 AC_DEFUN([AC_FUNC_FORK],
1790 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1791 AC_CHECK_HEADERS(vfork.h)
1792 AC_CHECK_FUNCS(fork vfork)
1793 if test "x$ac_cv_func_fork" = xyes; then
1796 ac_cv_func_fork_works=$ac_cv_func_fork
1798 if test "x$ac_cv_func_fork_works" = xcross; then
1800 *-*-amigaos* | *-*-msdosdjgpp*)
1801 # Override, as these systems have only a dummy fork() stub
1802 ac_cv_func_fork_works=no
1805 ac_cv_func_fork_works=yes
1808 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1810 ac_cv_func_vfork_works=$ac_cv_func_vfork
1811 if test "x$ac_cv_func_vfork" = xyes; then
1814 if test "x$ac_cv_func_fork_works" = xcross; then
1815 ac_cv_func_vfork_works=$ac_cv_func_vfork
1816 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1819 if test "x$ac_cv_func_vfork_works" = xyes; then
1820 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1822 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1824 if test "x$ac_cv_func_fork_works" = xyes; then
1825 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1832 AC_DEFUN([_AC_FUNC_FORK],
1833 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1835 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1837 /* By Ruediger Kuhlmann. */
1840 [ac_cv_func_fork_works=yes],
1841 [ac_cv_func_fork_works=no],
1842 [ac_cv_func_fork_works=cross])])]
1848 AC_DEFUN([_AC_FUNC_VFORK],
1849 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1850 [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
1851 ]AC_INCLUDES_DEFAULT[
1852 #include <sys/wait.h>
1856 /* On some sparc systems, changes by the child to local and incoming
1857 argument registers are propagated back to the parent. The compiler
1858 is told about this with #include <vfork.h>, but some compilers
1859 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1860 static variable whose address is put into a register that is
1861 clobbered by the vfork. */
1864 sparc_address_test (int arg)
1866 sparc_address_test (arg) int arg;
1887 pid_t parent = getpid ();
1890 sparc_address_test (0);
1895 /* Here is another test for sparc vfork register problems. This
1896 test uses lots of local variables, at least as many local
1897 variables as main has allocated so far including compiler
1898 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1899 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1900 reuse the register of parent for one of the local variables,
1901 since it will think that parent can't possibly be used any more
1902 in this routine. Assigning to the local variable will thus
1903 munge parent in the parent process. */
1905 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1906 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1907 /* Convince the compiler that p..p7 are live; otherwise, it might
1908 use the same hardware register for all 8 local variables. */
1909 if (p != p1 || p != p2 || p != p3 || p != p4
1910 || p != p5 || p != p6 || p != p7)
1913 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1914 from child file descriptors. If the child closes a descriptor
1915 before it execs or exits, this munges the parent's descriptor
1916 as well. Test for this by closing stdout in the child. */
1917 _exit(close(fileno(stdout)) != 0);
1922 while (wait(&status) != child)
1925 /* Was there some problem with vforking? */
1928 /* Did the child fail? (This shouldn't happen.) */
1931 /* Did the vfork/compiler bug occur? */
1932 || parent != getpid()
1934 /* Did the file descriptor bug occur? */
1935 || fstat(fileno(stdout), &st) != 0
1939 [ac_cv_func_vfork_works=yes],
1940 [ac_cv_func_vfork_works=no],
1941 [ac_cv_func_vfork_works=cross])])
1947 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1951 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1956 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1957 # That the logical name!
1958 AC_DEFUN([AC_FUNC_VPRINTF],
1959 [AC_CHECK_FUNCS(vprintf, []
1960 [AC_CHECK_FUNC(_doprnt,
1961 [AC_DEFINE(HAVE_DOPRNT, 1,
1962 [Define to 1 if you don't have `vprintf' but do have
1969 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1974 # Don't bother too hard maintaining this macro, as it's obsoleted.
1975 # We don't AU define it, since we don't have any alternative to propose,
1976 # any invocation should be removed, and the code adjusted.
1977 AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
1978 AC_DEFUN([AC_FUNC_WAIT3],
1979 [AC_DIAGNOSE([obsolete],
1980 [$0: `wait3' has been removed from POSIX.
1981 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1982 AC_CACHE_CHECK([for wait3 that fills in rusage],
1983 [ac_cv_func_wait3_rusage],
1984 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1985 [AC_INCLUDES_DEFAULT[
1986 #include <sys/time.h>
1987 #include <sys/resource.h>
1988 #include <sys/wait.h>
1989 /* HP-UX has wait3 but does not fill in rusage at all. */
1995 /* Use a field that we can force nonzero --
1996 voluntary context switches.
1997 For systems like NeXT and OSF/1 that don't set it,
1998 also use the system CPU time. And page faults (I/O) for Linux. */
2000 r.ru_stime.tv_sec = 0;
2001 r.ru_stime.tv_usec = 0;
2002 r.ru_majflt = r.ru_minflt = 0;
2005 case 0: /* Child. */
2006 sleep(1); /* Give up the CPU. */
2009 case -1: /* What can we do? */
2012 default: /* Parent. */
2014 /* Avoid "text file busy" from rm on fast HP-UX machines. */
2016 return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
2017 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
2020 [ac_cv_func_wait3_rusage=yes],
2021 [ac_cv_func_wait3_rusage=no],
2022 [ac_cv_func_wait3_rusage=no])])
2023 if test $ac_cv_func_wait3_rusage = yes; then
2024 AC_DEFINE(HAVE_WAIT3, 1,
2025 [Define to 1 if you have the `wait3' system call.
2026 Deprecated, you should no longer depend upon `wait3'.])
2033 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])