1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
4 # Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
55 # 1. Generic tests for functions.
56 # 2. Tests for specific functions.
59 ## -------------------------------- ##
60 ## 1. Generic tests for functions. ##
61 ## -------------------------------- ##
64 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
65 # -----------------------------------------------------------------
66 AC_DEFUN([AC_CHECK_FUNC],
67 [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
68 AC_CACHE_CHECK([for $1], ac_var,
69 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
70 [AS_VAR_SET(ac_var, yes)],
71 [AS_VAR_SET(ac_var, no)])])
72 AS_IF([test AS_VAR_GET(ac_var) = yes], [$2], [$3])dnl
73 AS_VAR_POPDEF([ac_var])dnl
77 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
78 # ---------------------------------------------------------------------
79 AC_DEFUN([AC_CHECK_FUNCS],
80 [AC_FOREACH([AC_Func], [$1],
81 [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
82 [Define if you have the `]AC_Func[' function.])])dnl
85 AC_CHECK_FUNC($ac_func,
86 [AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$ac_func])]) $2],
92 # AC_REPLACE_FUNCS(FUNCTION...)
93 # -----------------------------
94 AC_DEFUN([AC_REPLACE_FUNCS],
95 [AC_FOREACH([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
96 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
102 AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
107 AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
112 ## --------------------------------- ##
113 ## 2. Tests for specific functions. ##
114 ## --------------------------------- ##
117 # The macros are sorted:
119 # 1. AC_FUNC_* macros are sorted by alphabetical order.
121 # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
124 # 3. Obsolete macros are right after the modern macro.
130 # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
131 # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
132 # Nevertheless, for Automake, AC_LIBSOURCES it.
133 m4_define([_AC_LIBOBJ_ALLOCA],
134 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
135 # that cause trouble. Some versions do not even contain alloca or
136 # contain a buggy version. If you still want to use their alloca,
137 # use ar to extract alloca.o from them instead of compiling alloca.c.
138 AC_LIBSOURCES(alloca.c)
139 AC_SUBST(ALLOCA, alloca.$ac_objext)dnl
140 AC_DEFINE(C_ALLOCA, 1, [Define if using `alloca.c'.])
142 AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
143 [AC_EGREP_CPP(webecray,
144 [#if defined(CRAY) && ! defined(CRAY2)
149 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
150 if test $ac_cv_os_cray = yes; then
151 for ac_func in _getb67 GETB67 getb67; do
152 AC_CHECK_FUNC($ac_func,
153 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
154 [Define to one of `_getb67', `GETB67',
155 `getb67' for Cray-2 and Cray-YMP
156 systems. This function is required for
157 `alloca.c' support on those systems.])
162 AC_CACHE_CHECK([stack direction for C alloca],
163 [ac_cv_c_stack_direction],
164 [AC_RUN_IFELSE([AC_LANG_SOURCE(
166 find_stack_direction ()
168 static char *addr = 0;
173 return find_stack_direction ();
176 return (&dummy > addr) ? 1 : -1;
182 exit (find_stack_direction () < 0);
184 [ac_cv_c_stack_direction=1],
185 [ac_cv_c_stack_direction=-1],
186 [ac_cv_c_stack_direction=0])])
187 AH_VERBATIM([STACK_DIRECTION],
188 [/* If using the C implementation of alloca, define if you know the
189 direction of stack growth for your system; otherwise it will be
190 automatically deduced at run-time.
191 STACK_DIRECTION > 0 => grows toward higher addresses
192 STACK_DIRECTION < 0 => grows toward lower addresses
193 STACK_DIRECTION = 0 => direction of growth unknown */
194 @%:@undef STACK_DIRECTION])dnl
195 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
196 ])# _AC_LIBOBJ_ALLOCA
201 AC_DEFUN([AC_FUNC_ALLOCA],
202 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
203 # for constant arguments. Useless!
204 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
205 [AC_TRY_LINK([@%:@include <alloca.h>],
206 [char *p = (char *) alloca (2 * sizeof (int));],
207 ac_cv_working_alloca_h=yes, ac_cv_working_alloca_h=no)])
208 if test $ac_cv_working_alloca_h = yes; then
209 AC_DEFINE(HAVE_ALLOCA_H, 1,
210 [Define if you have <alloca.h> and it should be used
214 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
217 # define alloca __builtin_alloca
221 # define alloca _alloca
229 # ifndef alloca /* predefined by HP cc +Olibcalls */
236 ], [char *p = (char *) alloca (1);],
237 ac_cv_func_alloca_works=yes, ac_cv_func_alloca_works=no)])
239 if test $ac_cv_func_alloca_works = yes; then
240 AC_DEFINE(HAVE_ALLOCA, 1,
241 [Define if you have `alloca', as a function or macro.])
250 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
255 # Determine whether chown accepts arguments of -1 for uid and gid.
256 AC_DEFUN([AC_FUNC_CHOWN],
257 [AC_REQUIRE([AC_TYPE_UID_T])dnl
258 AC_CHECK_HEADERS(unistd.h)
259 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
260 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
263 [[ char *f = "conftest.chown";
264 struct stat before, after;
266 if (creat (f, 0600) < 0)
268 if (stat (f, &before) < 0)
270 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
272 if (stat (f, &after) < 0)
274 exit ((before.st_uid == after.st_uid
275 && before.st_gid == after.st_gid) ? 0 : 1);
277 [ac_cv_func_chown_works=yes],
278 [ac_cv_func_chown_works=no],
279 [ac_cv_func_chown_works=no])
282 if test $ac_cv_func_chown_works = yes; then
283 AC_DEFINE(HAVE_CHOWN, 1,
284 [Define if your system has a working `chown' function.])
289 # AC_FUNC_CLOSEDIR_VOID
290 # ---------------------
291 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
293 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
294 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
295 AC_CACHE_CHECK([whether closedir returns void],
296 [ac_cv_func_closedir_void],
297 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
298 #include <$ac_header_dirent>
303 [[exit (closedir (opendir (".")) != 0);]])],
304 [ac_cv_func_closedir_void=no],
305 [ac_cv_func_closedir_void=yes],
306 [ac_cv_func_closedir_void=yes])])
307 if test $ac_cv_func_closedir_void = yes; then
308 AC_DEFINE(CLOSEDIR_VOID, 1,
309 [Define if the `closedir' function returns void instead of `int'.])
314 # AC_FUNC_ERROR_AT_LINE
315 # ---------------------
316 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
317 [AC_LIBSOURCES([error.h, error.c])dnl
318 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
319 [AC_TRY_LINK([],[error_at_line (0, 0, "", 0, "");],
320 [ac_cv_lib_error_at_line=yes],
321 [ac_cv_lib_error_at_line=no])])
322 if test $ac_cv_lib_error_at_line = no; then
328 # AU::AM_FUNC_ERROR_AT_LINE
329 # -------------------------
330 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
335 # We look for fnmatch.h to avoid that the test fails in C++.
336 AC_DEFUN([AC_FUNC_FNMATCH],
337 [AC_CACHE_CHECK([for working GNU-style fnmatch],
338 [ac_cv_func_fnmatch_works],
339 # Some versions of Solaris, SCO, and the GNU C Library
340 # have a broken or incompatible fnmatch.
341 # So we run a test program. If we are cross-compiling, take no chance.
342 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
343 [AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include <fnmatch.h>],
344 [exit (fnmatch ("a*", "abc", 0) != 0
345 || fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) != FNM_NOMATCH
346 || fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
347 || fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
348 || fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0);])],
349 [ac_cv_func_fnmatch_works=yes],
350 [ac_cv_func_fnmatch_works=no],
351 [ac_cv_func_fnmatch_works=no])])
352 if test $ac_cv_func_fnmatch_works = yes; then
353 AC_DEFINE(HAVE_FNMATCH, 1,
354 [Define if your system has a working `fnmatch' function.])
359 # AU::AM_FUNC_FNMATCH
360 # AU::fp_FUNC_FNMATCH
361 # -------------------
362 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
363 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
368 AC_DEFUN([AC_FUNC_FSEEKO],
369 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
370 [ac_cv_sys_largefile_source],
371 [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
372 [@%:@include <stdio.h>], [return !fseeko;])
374 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
375 # in glibc 2.1.3, but that breaks too many other things.
376 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
377 AC_CACHE_CHECK([for fseeko], [ac_cv_func_fseeko],
378 [AC_TRY_LINK([@%:@include <stdio.h>],
379 [return fseeko && fseeko (stdin, 0, 0);],
380 [ac_cv_func_fseeko=yes],
381 [ac_cv_func_fseeko=no])])
382 if test $ac_cv_func_fseeko = yes; then
383 AC_DEFINE(HAVE_FSEEKO, 1,
384 [Define if fseeko (and presumably ftello) exists and is declared.])
391 # Try to find `getgroups', and check that it works.
392 # When crosscompiling, assume getgroups is broken.
393 AC_DEFUN([AC_FUNC_GETGROUPS],
394 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
395 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
396 AC_CHECK_FUNC(getgroups)
398 # If we don't yet have getgroups, see if it's in -lbsd.
399 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
401 if test $ac_cv_func_getgroups = no; then
402 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
405 # Run the program to test the functionality of the system-supplied
406 # getgroups function only if there is such a function.
407 if test $ac_cv_func_getgroups = yes; then
408 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
409 [AC_RUN_IFELSE([AC_LANG_PROGRAM([],
410 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
411 exit (getgroups (0, 0) == -1 ? 1 : 0);]])],
412 [ac_cv_func_getgroups_works=yes],
413 [ac_cv_func_getgroups_works=no],
414 [ac_cv_func_getgroups_works=no])
416 if test $ac_cv_func_getgroups_works = yes; then
417 AC_DEFINE(HAVE_GETGROUPS, 1,
418 [Define if your system has a working `getgroups' function.])
422 ])# AC_FUNC_GETGROUPS
425 # _AC_LIBOBJ_GETLOADAVG
426 # ---------------------
427 # Set up the AC_LIBOBJ replacement of `getloadavg'.
428 m4_define([_AC_LIBOBJ_GETLOADAVG],
429 [AC_LIBOBJ(getloadavg)
430 AC_DEFINE(C_GETLOADAVG, 1, [Define if using `getloadavg.c'.])
431 # Figure out what our getloadavg.c needs.
433 AC_CHECK_HEADER(sys/dg_sys_info.h,
435 AC_DEFINE(DGUX, 1, [Define for DGUX with <sys/dg_sys_info.h>.])
436 AC_CHECK_LIB(dgc, dg_sys_info)])
438 AC_CHECK_HEADER(locale.h)
439 AC_CHECK_FUNCS(setlocale)
441 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
442 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
443 # Irix 4.0.5F has the header but not the library.
444 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
446 AC_DEFINE(SVR4, 1, [Define on System V Release 4.])
449 if test $ac_have_func = no; then
450 AC_CHECK_HEADER(inq_stats/cpustats.h,
452 AC_DEFINE(UMAX, 1, [Define for Encore UMAX.])
453 AC_DEFINE(UMAX4_3, 1,
454 [Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
455 instead of <sys/cpustats.h>.])])
458 if test $ac_have_func = no; then
459 AC_CHECK_HEADER(sys/cpustats.h,
460 [ac_have_func=yes; AC_DEFINE(UMAX)])
463 if test $ac_have_func = no; then
464 AC_CHECK_HEADERS(mach/mach.h)
467 AC_CHECK_HEADERS(nlist.h,
468 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
469 [AC_DEFINE(NLIST_NAME_UNION, 1,
470 [Define if your `struct nlist' has an
471 `n_un' member. Obsolete, depend on
472 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
473 [@%:@include <nlist.h>])
475 ])# _AC_LIBOBJ_GETLOADAVG
480 AC_DEFUN([AC_FUNC_GETLOADAVG],
481 [ac_have_func=no # yes means we've found a way to get the load average.
485 # Check for getloadavg, but be sure not to touch the cache variable.
486 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
488 # On HPUX9, an unprivileged user can get load averages through this function.
489 AC_CHECK_FUNCS(pstat_getdynamic)
491 # Solaris has libkstat which does not require root.
492 AC_CHECK_LIB(kstat, kstat_open)
493 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
495 # Some systems with -lutil have (and need) -lkvm as well, some do not.
496 # On Solaris, -lkvm requires nlist from -lelf, so check that first
497 # to get the right answer into the cache.
498 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
499 if test $ac_have_func = no; then
500 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
502 if test $ac_have_func = no; then
503 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
504 # Check for the 4.4BSD definition of getloadavg.
505 AC_CHECK_LIB(util, getloadavg,
506 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
509 if test $ac_have_func = no; then
510 # There is a commonly available library for RS/6000 AIX.
511 # Since it is not a standard part of AIX, it might be installed locally.
512 ac_getloadavg_LIBS=$LIBS
513 LIBS="-L/usr/local/lib $LIBS"
514 AC_CHECK_LIB(getloadavg, getloadavg,
515 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
518 # Make sure it is really in the library, if we think we found it,
519 # otherwise set up the replacement function.
520 AC_CHECK_FUNCS(getloadavg, [],
521 [_AC_LIBOBJ_GETLOADAVG])
523 # Some definitions of getloadavg require that the program be installed setgid.
524 dnl FIXME: Don't hardwire the path of getloadavg.c in the top-level directory.
525 AC_CACHE_CHECK(whether getloadavg requires setgid,
526 ac_cv_func_getloadavg_setgid,
527 [AC_EGREP_CPP([Yowza Am I SETGID yet],
528 [#include "$srcdir/getloadavg.c"
529 #ifdef LDAV_PRIVILEGED
530 Yowza Am I SETGID yet
532 ac_cv_func_getloadavg_setgid=yes,
533 ac_cv_func_getloadavg_setgid=no)])
534 if test $ac_cv_func_getloadavg_setgid = yes; then
536 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
537 [Define if the `getloadavg' function needs to be run setuid
542 AC_SUBST(NEED_SETGID)dnl
544 if test $ac_cv_func_getloadavg_setgid = yes; then
545 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
546 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
547 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
548 # If we got an error (system does not support symlinks), try without -L.
549 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
550 ac_cv_group_kmem=`echo $ac_ls_output \
551 | sed -ne ['s/[ ][ ]*/ /g;
552 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
555 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
557 if test "x$ac_save_LIBS" = x; then
558 GETLOADAVG_LIBS=$LIBS
560 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
564 AC_SUBST(GETLOADAVG_LIBS)dnl
565 ])# AC_FUNC_GETLOADAVG
570 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
575 AC_DEFUN([AC_FUNC_GETMNTENT],
576 [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
577 AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
578 [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
579 [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
580 AC_CHECK_FUNC(getmntent,
581 [AC_DEFINE(HAVE_GETMNTENT, 1,
582 [Define if you have the `getmntent' function.])])])
585 # _AC_FUNC_GETPGRP_TEST
586 # ---------------------
587 # A program that exits with success iff `getpgrp' seems to ignore its
589 m4_define([_AC_FUNC_GETPGRP_TEST],
590 [AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
593 * If this system has a BSD-style getpgrp(),
594 * which takes a pid argument, exit unsuccessfully.
596 * Snarfed from Chet Ramey's bash pgrp.c test program
600 int pg1, pg2, pg3, pg4;
601 int ng, np, s, child;
612 /* If all of these values are the same, it's pretty sure that we're
613 on a system that ignores getpgrp's first argument. */
614 if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
623 /* If this is Sys V, this will not work; pgrp will be set to np
624 because setpgrp just changes a pgrp to be the same as the
627 ng = getpgrp (0); /* Same result for Sys V and BSD */
639 ])# _AC_FUNC_GETPGRP_TEST
644 # Figure out whether getpgrp takes an argument or not. Try first using
645 # prototypes (AC_COMPILE), and if the compiler is of no help, try a runtime
647 AC_DEFUN([AC_FUNC_GETPGRP],
648 [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
649 [# Use it with a single arg.
650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
651 [ac_func_getpgrp_1=yes],
652 [ac_func_getpgrp_1=no])
653 # Use it with no arg.
654 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp ();])],
655 [ac_func_getpgrp_0=yes],
656 [ac_func_getpgrp_0=no])
657 # If both static checks agree, we are done.
658 case $ac_func_getpgrp_0:$ac_func_getpgrp_1 in
659 yes:no) ac_cv_func_getpgrp_void=yes;;
660 no:yes) ac_cv_func_getpgrp_void=false;;
661 *) AC_RUN_IFELSE([_AC_FUNC_GETPGRP_TEST],
662 [ac_cv_func_getpgrp_void=yes],
663 [ac_cv_func_getpgrp_void=no],
664 [AC_MSG_ERROR([cannot check getpgrp if cross compiling])]);;
665 esac # $ac_func_getpgrp_0:$ac_func_getpgrp_1
667 if test $ac_cv_func_getpgrp_void = yes; then
668 AC_DEFINE(GETPGRP_VOID, 1,
669 [Define if the `getpgrp' function takes no argument.])
674 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
675 # -------------------------------------
676 # When crosscompiling, be pessimistic so we will end up using the
677 # replacement version of lstat that checkes for trailing slashes and
678 # calls lstat a second time when necessary.
679 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
681 [whether lstat dereferences a symlink specified with a trailing slash],
682 [ac_cv_func_lstat_dereferences_slashed_symlink],
683 [rm -f conftest.sym conftest.file
685 if ln -s conftest.file conftest.sym; then
686 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
688 /* Linux will dereference the symlink and fail.
689 That is better in the sense that it means we will not
690 have to compile and use the lstat wrapper. */
691 exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);])],
692 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
693 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
694 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
696 # If the `ln -s' command failed, then we probably don't even
697 # have an lstat function.
698 ac_cv_func_lstat_dereferences_slashed_symlink=no
700 rm -f conftest.sym conftest.file
703 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
704 AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
705 [Define if `lstat' dereferences a symlink specified
706 with a trailing slash.])
708 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
716 # Is `malloc (0)' properly handled?
717 AC_DEFUN([AC_FUNC_MALLOC],
718 [AC_REQUIRE([AC_HEADER_STDC])dnl
719 AC_CHECK_HEADERS(stdlib.h)
720 AC_CACHE_CHECK([for working malloc], ac_cv_func_malloc_works,
723 [[#if STDC_HEADERS || HAVE_STDLIB_H
729 [exit (malloc (0) ? 0 : 1);])],
730 [ac_cv_func_malloc_works=yes],
731 [ac_cv_func_malloc_works=no],
732 [ac_cv_func_malloc_works=no])])
733 if test $ac_cv_func_malloc_works = yes; then
734 AC_DEFINE(HAVE_MALLOC, 1,
735 [Define if your system has a working `malloc' function.])
742 AC_DEFUN([AC_FUNC_MEMCMP],
743 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
744 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
745 /* Some versions of memcmp are not 8-bit clean. */
746 char c0 = 0x40, c1 = 0x80, c2 = 0x81;
747 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
750 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
751 or more and with at least one buffer not starting on a 4-byte boundary.
752 William Lewis provided this test program. */
757 for (i = 0; i < 4; i++)
761 strcpy (a, "--------01111111");
762 strcpy (b, "--------10000000");
763 if (memcmp (a, b, 16) >= 0)
769 [ac_cv_func_memcmp_working=yes],
770 [ac_cv_func_memcmp_working=no],
771 [ac_cv_func_memcmp_working=no])])
772 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
778 AC_DEFUN([AC_FUNC_MKTIME],
779 [AC_REQUIRE([AC_HEADER_TIME])dnl
780 AC_CHECK_HEADERS(sys/time.h unistd.h)
781 AC_CHECK_FUNCS(alarm)
782 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
783 [AC_RUN_IFELSE([AC_LANG_SOURCE(
784 [[/* Test program from Paul Eggert and Tony Leneis. */
785 #if TIME_WITH_SYS_TIME
786 # include <sys/time.h>
790 # include <sys/time.h>
801 # define alarm(X) /* empty */
804 /* Work around redefinition to rpl_putenv by other config tests. */
807 static time_t time_t_max;
809 /* Values we'll use to set the TZ environment variable. */
810 static const char *const tz_strings[] = {
811 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
812 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
814 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
816 /* Fail if mktime fails to convert a date in the spring-forward gap.
817 Based on a problem report from Andreas Jaeger. */
819 spring_forward_gap ()
821 /* glibc (up to about 1998-10-07) failed this test. */
824 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
825 instead of "TZ=America/Vancouver" in order to detect the bug even
826 on systems that don't support the Olson extension, or don't have the
827 full zoneinfo tables installed. */
828 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
837 if (mktime (&tm) == (time_t)-1)
846 if ((lt = localtime (&now)) && mktime (lt) != now)
848 now = time_t_max - now;
849 if ((lt = localtime (&now)) && mktime (lt) != now)
856 /* Based on code from Ariel Faigon. */
866 if (tm.tm_mon != 2 || tm.tm_mday != 31)
876 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
878 if (now != (time_t) -1)
880 struct tm *lt = localtime (&now);
882 && lt->tm_year == tm.tm_year
883 && lt->tm_mon == tm.tm_mon
884 && lt->tm_mday == tm.tm_mday
885 && lt->tm_hour == tm.tm_hour
886 && lt->tm_min == tm.tm_min
887 && lt->tm_sec == tm.tm_sec
888 && lt->tm_yday == tm.tm_yday
889 && lt->tm_wday == tm.tm_wday
890 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
891 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
902 /* This test makes some buggy mktime implementations loop.
903 Give up after 60 seconds; a mktime slower than that
904 isn't worth using anyway. */
907 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
910 delta = time_t_max / 997; /* a suitable prime number */
911 for (i = 0; i < N_STRINGS; i++)
914 putenv (tz_strings[i]);
916 for (t = 0; t <= time_t_max - delta; t += delta)
918 mktime_test ((time_t) 60 * 60);
919 mktime_test ((time_t) 60 * 60 * 24);
921 for (j = 1; 0 < j; j *= 2)
923 bigtime_test (j - 1);
926 spring_forward_gap ();
929 [ac_cv_func_working_mktime=yes],
930 [ac_cv_func_working_mktime=no],
931 [ac_cv_func_working_mktime=no])])
932 if test $ac_cv_func_working_mktime = no; then
940 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
945 AC_DEFUN([AC_FUNC_MMAP],
946 [AC_CHECK_HEADERS(stdlib.h unistd.h)
947 AC_CHECK_FUNCS(getpagesize)
948 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
949 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
950 [[/* Thanks to Mike Haertel and Jim Avera for this test.
951 Here is a matrix of mmap possibilities:
952 mmap private not fixed
953 mmap private fixed at somewhere currently unmapped
954 mmap private fixed at somewhere already mapped
955 mmap shared not fixed
956 mmap shared fixed at somewhere currently unmapped
957 mmap shared fixed at somewhere already mapped
958 For private mappings, we should verify that changes cannot be read()
959 back from the file, nor mmap's back from the file at a different
960 address. (There have been systems where private was not correctly
961 implemented like the infamous i386 svr4.0, and systems where the
962 VM page cache was not coherent with the file system buffer cache
963 like early versions of FreeBSD and possibly contemporary NetBSD.)
964 For shared mappings, we should conversely verify that changes get
965 propogated back to all the places they're supposed to be.
967 Grep wants private fixed already mapped.
968 The main things grep needs to know about mmap are:
969 * does it exist and is it safe to write into the mmap'd area
970 * how to use it (BSD variants) */
973 #include <sys/mman.h>
975 #if !STDC_HEADERS && !HAVE_STDLIB_H
979 /* This mess was copied from the GNU getpagesize.h. */
980 #if !HAVE_GETPAGESIZE
981 /* Assume that all systems that can run configure have sys/param.h. */
982 # if !HAVE_SYS_PARAM_H
983 # define HAVE_SYS_PARAM_H 1
987 # define getpagesize() sysconf(_SC_PAGESIZE)
988 # else /* no _SC_PAGESIZE */
989 # if HAVE_SYS_PARAM_H
990 # include <sys/param.h>
991 # ifdef EXEC_PAGESIZE
992 # define getpagesize() EXEC_PAGESIZE
993 # else /* no EXEC_PAGESIZE */
995 # define getpagesize() NBPG * CLSIZE
998 # endif /* no CLSIZE */
1001 # define getpagesize() NBPC
1002 # else /* no NBPC */
1004 # define getpagesize() PAGESIZE
1005 # endif /* PAGESIZE */
1006 # endif /* no NBPC */
1007 # endif /* no NBPG */
1008 # endif /* no EXEC_PAGESIZE */
1009 # else /* no HAVE_SYS_PARAM_H */
1010 # define getpagesize() 8192 /* punt totally */
1011 # endif /* no HAVE_SYS_PARAM_H */
1012 # endif /* no _SC_PAGESIZE */
1014 #endif /* no HAVE_GETPAGESIZE */
1019 char *data, *data2, *data3;
1023 pagesize = getpagesize ();
1025 /* First, make a file with some known garbage in it. */
1026 data = (char *) malloc (pagesize);
1029 for (i = 0; i < pagesize; ++i)
1030 *(data + i) = rand ();
1032 fd = creat ("conftest.mmap", 0600);
1035 if (write (fd, data, pagesize) != pagesize)
1039 /* Next, try to mmap the file at a fixed address which already has
1040 something else allocated at it. If we can, also make sure that
1041 we see the same garbage. */
1042 fd = open ("conftest.mmap", O_RDWR);
1045 data2 = (char *) malloc (2 * pagesize);
1048 data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
1049 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1050 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1052 for (i = 0; i < pagesize; ++i)
1053 if (*(data + i) != *(data2 + i))
1056 /* Finally, make sure that changes to the mapped area do not
1057 percolate back to the file as seen by read(). (This is a bug on
1058 some variants of i386 svr4.0.) */
1059 for (i = 0; i < pagesize; ++i)
1060 *(data2 + i) = *(data2 + i) + 1;
1061 data3 = (char *) malloc (pagesize);
1064 if (read (fd, data3, pagesize) != pagesize)
1066 for (i = 0; i < pagesize; ++i)
1067 if (*(data + i) != *(data3 + i))
1072 [ac_cv_func_mmap_fixed_mapped=yes],
1073 [ac_cv_func_mmap_fixed_mapped=no],
1074 [ac_cv_func_mmap_fixed_mapped=no])])
1075 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1076 AC_DEFINE(HAVE_MMAP, 1,
1077 [Define if you have a working `mmap' system call.])
1085 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1090 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1091 AC_DEFUN([AC_FUNC_OBSTACK],
1092 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1093 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1094 [AC_TRY_LINK([@%:@include "obstack.h"],
1095 [struct obstack *mem; obstack_free(mem,(char *) 0)],
1096 [ac_cv_func_obstack=yes],
1097 [ac_cv_func_obstack=no])])
1098 if test $ac_cv_func_obstack = yes; then
1099 AC_DEFINE(HAVE_OBSTACK, 1, [Define if libc includes obstacks.])
1106 # AU::AM_FUNC_OBSTACK
1107 # -------------------
1108 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1111 # AC_FUNC_SELECT_ARGTYPES
1112 # -----------------------
1113 # Determine the correct type to be passed to each of the `select'
1114 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1115 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1116 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1117 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1118 AC_CACHE_CHECK([types of arguments for select],
1119 [ac_cv_func_select_args],
1120 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1121 for ac_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
1122 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1125 [AC_INCLUDES_DEFAULT
1126 #if HAVE_SYS_SELECT_H
1127 # include <sys/select.h>
1129 #if HAVE_SYS_SOCKET_H
1130 # include <sys/socket.h>
1133 [extern int select ($ac_arg1,
1134 $ac_arg234, $ac_arg234, $ac_arg234,
1136 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1140 # Provide a safe default value.
1141 : ${ac_cv_func_select_args='int,int *,struct timeval *'}
1143 ac_save_IFS=$IFS; IFS=','
1144 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1147 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1148 [Define to the type of arg 1 for `select'.])
1149 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1150 [Define to the type of args 2, 3 and 4 for `select'.])
1151 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1152 [Define to the type of arg 5 for `select'.])
1154 ])# AC_FUNC_SELECT_ARGTYPES
1159 AC_DEFUN([AC_FUNC_SETPGRP],
1160 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1164 # include <unistd.h>
1167 [/* If this system has a BSD-style setpgrp, which takes arguments, exit
1169 exit (setpgrp (1,1) == -1);])],
1170 [ac_cv_func_setpgrp_void=no],
1171 [ac_cv_func_setpgrp_void=yes],
1172 [AC_MSG_ERROR([cannot check setpgrp if cross compiling])])])
1173 if test $ac_cv_func_setpgrp_void = yes; then
1174 AC_DEFINE(SETPGRP_VOID, 1,
1175 [Define if the `setpgrp' function takes no argument.])
1180 # _AC_FUNC_STAT(STAT | LSTAT)
1181 # ---------------------------
1182 # Determine whether stat or lstat have the bug that it succeeds when
1183 # given the zero-length file name argument. The stat and lstat from
1184 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1186 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1187 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1189 m4_define([_AC_FUNC_STAT],
1190 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1191 AC_CACHE_CHECK([whether $1 accepts an empty string],
1192 [ac_cv_func_$1_empty_string_bug],
1193 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1195 exit ($1 ("", &sbuf) ? 1 : 0);]])],
1196 [ac_cv_func_$1_empty_string_bug=yes],
1197 [ac_cv_func_$1_empty_string_bug=no],
1198 [ac_cv_func_$1_empty_string_bug=yes])])
1199 if test $ac_cv_func_$1_empty_string_bug = yes; then
1201 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1202 [Define if `$1' has the bug that it succeeds when
1203 given the zero-length file name argument.])
1208 # AC_FUNC_STAT & AC_FUNC_LSTAT
1209 # ----------------------------
1210 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1211 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1216 m4_define([_AC_LIBOBJ_STRTOD],
1219 if test $ac_cv_func_pow = no; then
1220 AC_CHECK_LIB(m, pow,
1222 [AC_MSG_WARN([can't find library containing definition of pow])])
1224 ])# _AC_LIBOBJ_STRTOD
1229 AC_DEFUN([AC_FUNC_STRTOD],
1230 [AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1231 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1237 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1238 char *string = " +69";
1241 value = strtod (string, &term);
1242 if (value != 69 || term != (string + 4))
1247 /* Under Solaris 2.4, strtod returns the wrong value for the
1248 terminating character under some conditions. */
1249 char *string = "NaN";
1251 strtod (string, &term);
1252 if (term != string && *(term - 1) == 0)
1258 ac_cv_func_strtod=yes,
1259 ac_cv_func_strtod=no,
1260 ac_cv_func_strtod=no)])
1261 if test $ac_cv_func_strtod = no; then
1267 # AU::AM_FUNC_STRTOD
1268 # ------------------
1269 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1272 # AC_FUNC_STRERROR_R
1273 # ------------------
1274 AC_DEFUN([AC_FUNC_STRERROR_R],
1275 [AC_CHECK_DECLS([strerror_r])
1276 AC_CHECK_FUNCS([strerror_r])
1277 if test $ac_cv_func_strerror_r = yes; then
1278 AC_CACHE_CHECK([for working strerror_r],
1279 ac_cv_func_strerror_r_works,
1281 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1284 char x = *strerror_r (0, buf, sizeof buf);
1286 ac_cv_func_strerror_r_works=yes,
1287 ac_cv_func_strerror_r_works=no)
1288 if test $ac_cv_func_strerror_r_works = no; then
1289 # strerror_r seems not to work, but now we have to choose between
1290 # systems that have relatively inaccessible declarations for the
1291 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1292 # former has a strerror_r that returns char*, while the latter
1293 # has a strerror_r that returns `int'.
1294 # This test should segfault on the DEC system.
1295 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1296 extern char *strerror_r ();],
1298 char x = *strerror_r (0, buf, sizeof buf);
1299 exit (!isalpha (x));]])],
1300 ac_cv_func_strerror_r_works=yes,
1301 ac_cv_func_strerror_r_works=no,
1302 ac_cv_func_strerror_r_works=no)
1305 if test $ac_cv_func_strerror_r_works = yes; then
1306 AC_DEFINE_UNQUOTED([HAVE_WORKING_STRERROR_R], 1,
1307 [Define to 1 if `strerror_r' returns a string.])
1310 ])# AC_FUNC_STRERROR_R
1315 AC_DEFUN([AC_FUNC_STRFTIME],
1316 [AC_CHECK_FUNCS(strftime, [],
1317 [# strftime is in -lintl on SCO UNIX.
1318 AC_CHECK_LIB(intl, strftime,
1319 [AC_DEFINE(HAVE_STRFTIME)
1320 LIBS="-lintl $LIBS"])])dnl
1321 ])# AC_FUNC_STRFTIME
1324 # AC_FUNC_SETVBUF_REVERSED
1325 # ------------------------
1326 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1327 [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
1328 ac_cv_func_setvbuf_reversed,
1329 [AC_TRY_RUN([#include <stdio.h>
1330 /* If setvbuf has the reversed format, exit 0. */
1334 /* This call has the arguments reversed.
1335 A reversed system may check and see that the address of main
1336 is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
1337 if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
1340 exit(0); /* Non-reversed systems segv here. */
1341 }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
1342 rm -f core core.* *.core])
1343 if test $ac_cv_func_setvbuf_reversed = yes; then
1344 AC_DEFINE(SETVBUF_REVERSED, 1,
1345 [Define if the `setvbuf' function takes the buffering type as
1346 its second argument and the buffer pointer as the third, as on
1347 System V before release 3.])
1349 ])# AC_FUNC_SETVBUF_REVERSED
1352 # AU::AC_SETVBUF_REVERSED
1353 # -----------------------
1354 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1359 AC_DEFUN([AC_FUNC_STRCOLL],
1360 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1361 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1362 [[exit (strcoll ("abc", "def") >= 0 ||
1363 strcoll ("ABC", "DEF") >= 0 ||
1364 strcoll ("123", "456") >= 0)]])],
1365 ac_cv_func_strcoll_works=yes,
1366 ac_cv_func_strcoll_works=no,
1367 ac_cv_func_strcoll_works=no)])
1368 if test $ac_cv_func_strcoll_works = yes; then
1369 AC_DEFINE(HAVE_STRCOLL, 1,
1370 [Define if you have the `strcoll' function and it is properly
1378 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1381 # AC_FUNC_UTIME_NULL
1382 # ------------------
1383 AC_DEFUN([AC_FUNC_UTIME_NULL],
1384 [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1385 [rm -f conftest.data; >conftest.data
1386 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1387 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1389 exit (!(stat ("conftest.data", &s) == 0
1390 && utime ("conftest.data", (long *)0) == 0
1391 && stat ("conftest.data", &t) == 0
1392 && t.st_mtime >= s.st_mtime
1393 && t.st_mtime - s.st_mtime < 120));]])],
1394 ac_cv_func_utime_null=yes,
1395 ac_cv_func_utime_null=no,
1396 ac_cv_func_utime_null=no)
1397 rm -f core core.* *.core])
1398 if test $ac_cv_func_utime_null = yes; then
1399 AC_DEFINE(HAVE_UTIME_NULL, 1,
1400 [Define if `utime(file, NULL)' sets file's timestamp to the
1404 ])# AC_FUNC_UTIME_NULL
1409 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1414 AC_DEFUN([AC_FUNC_FORK],
1415 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1416 AC_CHECK_HEADERS(unistd.h vfork.h)
1417 AC_CHECK_FUNCS(fork vfork)
1418 ac_cv_func_fork_works=$ac_cv_func_fork
1419 if test "x$ac_cv_func_fork" = xyes; then
1422 if test "x$ac_cv_func_fork_works" = xcross; then
1424 *-*-amigaos* | *-*-msdosdjgpp*)
1425 # Override, as these systems have only a dummy fork() stub
1426 ac_cv_func_fork_works=no
1429 ac_cv_func_fork_works=yes
1432 AC_MSG_WARN(CROSS: Result $ac_cv_func_fork_works guessed due to cross-compiling.)
1434 ac_cv_func_vfork_works=$ac_cv_func_vfork
1435 if test "x$ac_cv_func_vfork" = xyes; then
1438 if test "x$ac_cv_func_fork_works" = xcross; then
1439 ac_cv_func_vfork_works=ac_cv_func_vfork
1440 AC_MSG_WARN(CROSS: Result $ac_cv_func_vfork_works guessed due to cross-compiling.)
1443 if test "x$ac_cv_func_vfork_works" = xyes; then
1444 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define if `vfork' works.])
1446 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1448 if test "x$ac_cv_func_fork_works" = xyes; then
1449 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define if `fork' works.])
1456 AC_DEFUN([_AC_FUNC_FORK],
1457 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1458 [AC_RUN_IFELSE([/* By RĂ¼diger Kuhlmann. */
1459 #include <sys/types.h>
1461 # include <unistd.h>
1463 /* Some systems only have a dummy stub for fork() */
1470 [ac_cv_func_fork_works=yes],
1471 [ac_cv_func_fork_works=no],
1472 [ac_cv_func_fork_works=cross])])]
1478 AC_DEFUN([_AC_FUNC_VFORK],
1479 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1480 [AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */
1482 #include <sys/types.h>
1483 #include <sys/stat.h>
1485 # include <unistd.h>
1490 /* On some sparc systems, changes by the child to local and incoming
1491 argument registers are propagated back to the parent. The compiler
1492 is told about this with #include <vfork.h>, but some compilers
1493 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1494 static variable whose address is put into a register that is
1495 clobbered by the vfork. */
1498 sparc_address_test (int arg)
1500 sparc_address_test (arg) int arg;
1521 pid_t parent = getpid ();
1524 sparc_address_test ();
1529 /* Here is another test for sparc vfork register problems. This
1530 test uses lots of local variables, at least as many local
1531 variables as main has allocated so far including compiler
1532 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1533 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1534 reuse the register of parent for one of the local variables,
1535 since it will think that parent can't possibly be used any more
1536 in this routine. Assigning to the local variable will thus
1537 munge parent in the parent process. */
1539 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1540 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1541 /* Convince the compiler that p..p7 are live; otherwise, it might
1542 use the same hardware register for all 8 local variables. */
1543 if (p != p1 || p != p2 || p != p3 || p != p4
1544 || p != p5 || p != p6 || p != p7)
1547 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1548 from child file descriptors. If the child closes a descriptor
1549 before it execs or exits, this munges the parent's descriptor
1550 as well. Test for this by closing stdout in the child. */
1551 _exit(close(fileno(stdout)) != 0);
1556 while (wait(&status) != child)
1559 /* Was there some problem with vforking? */
1562 /* Did the child fail? (This shouldn't happen.) */
1565 /* Did the vfork/compiler bug occur? */
1566 || parent != getpid()
1568 /* Did the file descriptor bug occur? */
1569 || fstat(fileno(stdout), &st) != 0
1573 [ac_cv_func_vfork_works=yes],
1574 [ac_cv_func_vfork_works=no],
1575 [ac_cv_func_vfork_works=cross])])
1581 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1585 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1590 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1591 # That the logical name!
1592 AC_DEFUN([AC_FUNC_VPRINTF],
1593 [AC_CHECK_FUNCS(vprintf, []
1594 [AC_CHECK_FUNC(_doprnt,
1595 [AC_DEFINE(HAVE_DOPRNT, 1,
1596 [Define if you don't have `vprintf' but do have
1603 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1608 # Don't bother too hard maintaining this macro, as it's obsoleted.
1609 # We don't AU define it, since we don't have any alternative to propose,
1610 # any invocation should be removed, and the code adjusted.
1611 AC_DEFUN([AC_FUNC_WAIT3],
1612 [AC_DIAGNOSE([obsolete],
1613 [$0: `wait3' is being removed from the Open Group standards.
1614 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1615 AC_CACHE_CHECK([for wait3 that fills in rusage],
1616 [ac_cv_func_wait3_rusage],
1617 [AC_RUN_IFELSE([AC_LANG_SOURCE(
1618 [[#include <sys/types.h>
1619 #include <sys/time.h>
1620 #include <sys/resource.h>
1622 /* HP-UX has wait3 but does not fill in rusage at all. */
1628 /* Use a field that we can force nonzero --
1629 voluntary context switches.
1630 For systems like NeXT and OSF/1 that don't set it,
1631 also use the system CPU time. And page faults (I/O) for Linux. */
1633 r.ru_stime.tv_sec = 0;
1634 r.ru_stime.tv_usec = 0;
1635 r.ru_majflt = r.ru_minflt = 0;
1638 case 0: /* Child. */
1639 sleep(1); /* Give up the CPU. */
1642 case -1: /* What can we do? */
1645 default: /* Parent. */
1647 /* Avoid "text file busy" from rm on fast HP-UX machines. */
1649 exit (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1650 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1653 [ac_cv_func_wait3_rusage=yes],
1654 [ac_cv_func_wait3_rusage=no],
1655 [ac_cv_func_wait3_rusage=no])])
1656 if test $ac_cv_func_wait3_rusage = yes; then
1657 AC_DEFINE(HAVE_WAIT3, 1,
1658 [Define if you have the `wait3' system call.
1659 Deprecated, you should no longer depend upon `wait3'.])
1666 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])