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 [AC_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 [AC_VAR_SET(ac_var, yes)],
71 [AC_VAR_SET(ac_var, no)])])
72 AS_IF([test AC_VAR_GET(ac_var) = yes], [$2], [$3])dnl
73 AC_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(AC_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([AC_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_SOURCE([[#include <sys/types.h>
261 #include <sys/stat.h>
270 char *f = "conftest.chown";
271 struct stat before, after;
273 if (creat (f, 0600) < 0)
275 if (stat (f, &before) < 0)
277 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
279 if (stat (f, &after) < 0)
281 exit ((before.st_uid == after.st_uid
282 && before.st_gid == after.st_gid) ? 0 : 1);
284 [ac_cv_func_chown_works=yes],
285 [ac_cv_func_chown_works=no],
286 [ac_cv_func_chown_works=no])
289 if test $ac_cv_func_chown_works = yes; then
290 AC_DEFINE(HAVE_CHOWN, 1,
291 [Define if your system has a working `chown' function.])
296 # AC_FUNC_CLOSEDIR_VOID
297 # ---------------------
298 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
300 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
301 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
302 AC_CACHE_CHECK([whether closedir returns void],
303 [ac_cv_func_closedir_void],
304 [AC_RUN_IFELSE([AC_LANG_SOURCE(
305 [#include <sys/types.h>
306 #include <$ac_header_dirent>
312 exit (closedir (opendir (".")) != 0);
314 [ac_cv_func_closedir_void=no],
315 [ac_cv_func_closedir_void=yes],
316 [ac_cv_func_closedir_void=yes])])
317 if test $ac_cv_func_closedir_void = yes; then
318 AC_DEFINE(CLOSEDIR_VOID, 1,
319 [Define if the `closedir' function returns void instead of `int'.])
324 # AC_FUNC_ERROR_AT_LINE
325 # ---------------------
326 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
327 [AC_LIBSOURCES([error.h, error.c])dnl
328 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
329 [AC_TRY_LINK([],[error_at_line (0, 0, "", 0, "");],
330 [ac_cv_lib_error_at_line=yes],
331 [ac_cv_lib_error_at_line=no])])
332 if test $ac_cv_lib_error_at_line = no; then
338 # AU::AM_FUNC_ERROR_AT_LINE
339 # -------------------------
340 # FIXME: Because Automake macros are defined with their name unquoted,
341 # we can't yet provide the Autoupdate glue.
342 # AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
347 # We look for fnmatch.h to avoid that the test fails in C++.
348 AC_DEFUN([AC_FUNC_FNMATCH],
349 [AC_CACHE_CHECK([for working GNU-style fnmatch],
350 [ac_cv_func_fnmatch_works],
351 # Some versions of Solaris, SCO, and the GNU C Library
352 # have a broken or incompatible fnmatch.
353 # So we run a test program. If we are cross-compiling, take no chance.
354 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
355 [AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include <fnmatch.h>],
356 [exit (fnmatch ("a*", "abc", 0) != 0
357 || fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) != FNM_NOMATCH
358 || fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
359 || fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
360 || fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0);])],
361 [ac_cv_func_fnmatch_works=yes],
362 [ac_cv_func_fnmatch_works=no],
363 [ac_cv_func_fnmatch_works=no])])
364 if test $ac_cv_func_fnmatch_works = yes; then
365 AC_DEFINE(HAVE_FNMATCH, 1,
366 [Define if your system has a working `fnmatch' function.])
371 # AU::AM_FUNC_FNMATCH
372 # AU::fp_FUNC_FNMATCH
373 # -------------------
374 # FIXME: Because Automake macros are defined with their name unquoted,
375 # we can't yet provide the Autoupdate glue.
376 # AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
377 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
382 AC_DEFUN([AC_FUNC_FSEEKO],
383 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
384 [ac_cv_sys_largefile_source],
385 [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
386 [@%:@include <stdio.h>], [return !fseeko;])
388 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
389 # in glibc 2.1.3, but that breaks too many other things.
390 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
391 AC_CACHE_CHECK([for fseeko], [ac_cv_func_fseeko],
392 [AC_TRY_LINK([@%:@include <stdio.h>],
393 [return fseeko && fseeko (stdin, 0, 0);],
394 [ac_cv_func_fseeko=yes],
395 [ac_cv_func_fseeko=no])])
396 if test $ac_cv_func_fseeko = yes; then
397 AC_DEFINE(HAVE_FSEEKO, 1,
398 [Define if fseeko (and presumably ftello) exists and is declared.])
405 # Try to find `getgroups', and check that it works.
406 # When crosscompiling, assume getgroups is broken.
407 AC_DEFUN([AC_FUNC_GETGROUPS],
408 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
409 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
410 AC_CHECK_FUNC(getgroups)
412 # If we don't yet have getgroups, see if it's in -lbsd.
413 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
415 if test $ac_cv_func_getgroups = no; then
416 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
419 # Run the program to test the functionality of the system-supplied
420 # getgroups function only if there is such a function.
421 if test $ac_cv_func_getgroups = yes; then
422 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
423 [AC_RUN_IFELSE([AC_LANG_PROGRAM([],
424 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
425 exit (getgroups (0, 0) == -1 ? 1 : 0);]])],
426 [ac_cv_func_getgroups_works=yes],
427 [ac_cv_func_getgroups_works=no],
428 [ac_cv_func_getgroups_works=no])
430 if test $ac_cv_func_getgroups_works = yes; then
431 AC_DEFINE(HAVE_GETGROUPS, 1,
432 [Define if your system has a working `getgroups' function.])
436 ])# AC_FUNC_GETGROUPS
439 # _AC_LIBOBJ_GETLOADAVG
440 # ---------------------
441 # Set up the AC_LIBOBJ replacement of `getloadavg'.
442 m4_define([_AC_LIBOBJ_GETLOADAVG],
443 [AC_LIBOBJ(getloadavg)
444 AC_DEFINE(C_GETLOADAVG, 1, [Define if using `getloadavg.c'.])
445 # Figure out what our getloadavg.c needs.
447 AC_CHECK_HEADER(sys/dg_sys_info.h,
449 AC_DEFINE(DGUX, 1, [Define for DGUX with <sys/dg_sys_info.h>.])
450 AC_CHECK_LIB(dgc, dg_sys_info)])
452 AC_CHECK_HEADER(locale.h)
453 AC_CHECK_FUNCS(setlocale)
455 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
456 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
457 # Irix 4.0.5F has the header but not the library.
458 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
460 AC_DEFINE(SVR4, 1, [Define on System V Release 4.])
463 if test $ac_have_func = no; then
464 AC_CHECK_HEADER(inq_stats/cpustats.h,
466 AC_DEFINE(UMAX, 1, [Define for Encore UMAX.])
467 AC_DEFINE(UMAX4_3, 1,
468 [Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
469 instead of <sys/cpustats.h>.])])
472 if test $ac_have_func = no; then
473 AC_CHECK_HEADER(sys/cpustats.h,
474 [ac_have_func=yes; AC_DEFINE(UMAX)])
477 if test $ac_have_func = no; then
478 AC_CHECK_HEADERS(mach/mach.h)
481 AC_CHECK_HEADERS(nlist.h,
482 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
483 [AC_DEFINE(NLIST_NAME_UNION, 1,
484 [Define if your `struct nlist' has an
485 `n_un' member. Obsolete, depend on
486 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
487 [@%:@include <nlist.h>])
489 ])# _AC_LIBOBJ_GETLOADAVG
494 AC_DEFUN([AC_FUNC_GETLOADAVG],
495 [ac_have_func=no # yes means we've found a way to get the load average.
499 # Check for getloadavg, but be sure not to touch the cache variable.
500 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
502 # On HPUX9, an unprivileged user can get load averages through this function.
503 AC_CHECK_FUNCS(pstat_getdynamic)
505 # Solaris has libkstat which does not require root.
506 AC_CHECK_LIB(kstat, kstat_open)
507 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
509 # Some systems with -lutil have (and need) -lkvm as well, some do not.
510 # On Solaris, -lkvm requires nlist from -lelf, so check that first
511 # to get the right answer into the cache.
512 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
513 if test $ac_have_func = no; then
514 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
516 if test $ac_have_func = no; then
517 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
518 # Check for the 4.4BSD definition of getloadavg.
519 AC_CHECK_LIB(util, getloadavg,
520 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
523 if test $ac_have_func = no; then
524 # There is a commonly available library for RS/6000 AIX.
525 # Since it is not a standard part of AIX, it might be installed locally.
526 ac_getloadavg_LIBS=$LIBS
527 LIBS="-L/usr/local/lib $LIBS"
528 AC_CHECK_LIB(getloadavg, getloadavg,
529 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
532 # Make sure it is really in the library, if we think we found it,
533 # otherwise set up the replacement function.
534 AC_CHECK_FUNCS(getloadavg, [],
535 [_AC_LIBOBJ_GETLOADAVG])
537 # Some definitions of getloadavg require that the program be installed setgid.
538 dnl FIXME: Don't hardwire the path of getloadavg.c in the top-level directory.
539 AC_CACHE_CHECK(whether getloadavg requires setgid,
540 ac_cv_func_getloadavg_setgid,
541 [AC_EGREP_CPP([Yowza Am I SETGID yet],
542 [#include "$srcdir/getloadavg.c"
543 #ifdef LDAV_PRIVILEGED
544 Yowza Am I SETGID yet
546 ac_cv_func_getloadavg_setgid=yes,
547 ac_cv_func_getloadavg_setgid=no)])
548 if test $ac_cv_func_getloadavg_setgid = yes; then
550 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
551 [Define if the `getloadavg' function needs to be run setuid
556 AC_SUBST(NEED_SETGID)dnl
558 if test $ac_cv_func_getloadavg_setgid = yes; then
559 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
560 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
561 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
562 # If we got an error (system does not support symlinks), try without -L.
563 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
564 ac_cv_group_kmem=`echo $ac_ls_output \
565 | sed -ne ['s/[ ][ ]*/ /g;
566 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
569 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
571 if test "x$ac_save_LIBS" = x; then
572 GETLOADAVG_LIBS=$LIBS
574 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
578 AC_SUBST(GETLOADAVG_LIBS)dnl
579 ])# AC_FUNC_GETLOADAVG
584 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
589 AC_DEFUN([AC_FUNC_GETMNTENT],
590 [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
591 AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
592 [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
593 [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
594 AC_CHECK_FUNC(getmntent,
595 [AC_DEFINE(HAVE_GETMNTENT, 1,
596 [Define if you have the `getmntent' function.])])])
601 AC_DEFUN([AC_FUNC_GETPGRP],
602 [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
603 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
605 * If this system has a BSD-style getpgrp(),
606 * which takes a pid argument, exit unsuccessfully.
608 * Snarfed from Chet Ramey's bash pgrp.c test program
611 #include <sys/types.h>
614 int pg1, pg2, pg3, pg4;
615 int ng, np, s, child;
626 /* If all of these values are the same, it's pretty sure that we're
627 on a system that ignores getpgrp's first argument. */
628 if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
637 /* If this is Sys V, this will not work; pgrp will be set to np
638 because setpgrp just changes a pgrp to be the same as the
641 ng = getpgrp (0); /* Same result for Sys V and BSD */
653 [ac_cv_func_getpgrp_void=yes],
654 [ac_cv_func_getpgrp_void=no],
655 [AC_MSG_ERROR([cannot check getpgrp if cross compiling])])
657 if test $ac_cv_func_getpgrp_void = yes; then
658 AC_DEFINE(GETPGRP_VOID, 1,
659 [Define if the `getpgrp' function takes no argument.])
664 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
665 # -------------------------------------
666 # When crosscompiling, be pessimistic so we will end up using the
667 # replacement version of lstat that checkes for trailing slashes and
668 # calls lstat a second time when necessary.
669 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
671 [whether lstat dereferences a symlink specified with a trailing slash],
672 [ac_cv_func_lstat_dereferences_slashed_symlink],
673 [rm -f conftest.sym conftest.file
675 if ln -s conftest.file conftest.sym; then
676 AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/types.h>
677 @%:@include <sys/stat.h>],
679 /* Linux will dereference the symlink and fail.
680 That is better in the sense that it means we will not
681 have to compile and use the lstat wrapper. */
682 exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);])],
683 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
684 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
685 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
687 # If the `ln -s' command failed, then we probably don't even
688 # have an lstat function.
689 ac_cv_func_lstat_dereferences_slashed_symlink=no
691 rm -f conftest.sym conftest.file
694 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
695 AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
696 [Define if `lstat' dereferences a symlink specified
697 with a trailing slash.])
699 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
707 # Is `malloc (0)' properly handled?
708 AC_DEFUN([AC_FUNC_MALLOC],
709 [AC_REQUIRE([AC_HEADER_STDC])dnl
710 AC_CHECK_HEADERS(stdlib.h)
711 AC_CACHE_CHECK([for working malloc], ac_cv_func_malloc_works,
714 [[#if STDC_HEADERS || HAVE_STDLIB_H
720 [exit (malloc (0) ? 0 : 1);])],
721 [ac_cv_func_malloc_works=yes],
722 [ac_cv_func_malloc_works=no],
723 [ac_cv_func_malloc_works=no])])
724 if test $ac_cv_func_malloc_works = yes; then
725 AC_DEFINE(HAVE_MALLOC, 1,
726 [Define if your system has a working `malloc' function.])
733 AC_DEFUN([AC_FUNC_MEMCMP],
734 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
735 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
739 /* Some versions of memcmp are not 8-bit clean. */
740 char c0 = 0x40, c1 = 0x80, c2 = 0x81;
741 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
744 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
745 or more and with at least one buffer not starting on a 4-byte boundary.
746 William Lewis provided this test program. */
751 for (i = 0; i < 4; i++)
755 strcpy (a, "--------01111111");
756 strcpy (b, "--------10000000");
757 if (memcmp (a, b, 16) >= 0)
763 [ac_cv_func_memcmp_working=yes],
764 [ac_cv_func_memcmp_working=no],
765 [ac_cv_func_memcmp_working=no])])
766 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
772 AC_DEFUN([AC_FUNC_MKTIME],
773 [AC_REQUIRE([AC_HEADER_TIME])dnl
774 AC_CHECK_HEADERS(sys/time.h unistd.h)
775 AC_CHECK_FUNCS(alarm)
776 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
777 [AC_RUN_IFELSE([AC_LANG_SOURCE(
778 [[/* Test program from Paul Eggert and Tony Leneis. */
779 #if TIME_WITH_SYS_TIME
780 # include <sys/time.h>
784 # include <sys/time.h>
795 # define alarm(X) /* empty */
798 /* Work around redefinition to rpl_putenv by other config tests. */
801 static time_t time_t_max;
803 /* Values we'll use to set the TZ environment variable. */
804 static const char *const tz_strings[] = {
805 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
806 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
808 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
810 /* Fail if mktime fails to convert a date in the spring-forward gap.
811 Based on a problem report from Andreas Jaeger. */
813 spring_forward_gap ()
815 /* glibc (up to about 1998-10-07) failed this test. */
818 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
819 instead of "TZ=America/Vancouver" in order to detect the bug even
820 on systems that don't support the Olson extension, or don't have the
821 full zoneinfo tables installed. */
822 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
831 if (mktime (&tm) == (time_t)-1)
840 if ((lt = localtime (&now)) && mktime (lt) != now)
842 now = time_t_max - now;
843 if ((lt = localtime (&now)) && mktime (lt) != now)
850 /* Based on code from Ariel Faigon. */
860 if (tm.tm_mon != 2 || tm.tm_mday != 31)
870 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
872 if (now != (time_t) -1)
874 struct tm *lt = localtime (&now);
876 && lt->tm_year == tm.tm_year
877 && lt->tm_mon == tm.tm_mon
878 && lt->tm_mday == tm.tm_mday
879 && lt->tm_hour == tm.tm_hour
880 && lt->tm_min == tm.tm_min
881 && lt->tm_sec == tm.tm_sec
882 && lt->tm_yday == tm.tm_yday
883 && lt->tm_wday == tm.tm_wday
884 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
885 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
896 /* This test makes some buggy mktime implementations loop.
897 Give up after 60 seconds; a mktime slower than that
898 isn't worth using anyway. */
901 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
904 delta = time_t_max / 997; /* a suitable prime number */
905 for (i = 0; i < N_STRINGS; i++)
908 putenv (tz_strings[i]);
910 for (t = 0; t <= time_t_max - delta; t += delta)
912 mktime_test ((time_t) 60 * 60);
913 mktime_test ((time_t) 60 * 60 * 24);
915 for (j = 1; 0 < j; j *= 2)
917 bigtime_test (j - 1);
920 spring_forward_gap ();
923 [ac_cv_func_working_mktime=yes],
924 [ac_cv_func_working_mktime=no],
925 [ac_cv_func_working_mktime=no])])
926 if test $ac_cv_func_working_mktime = no; then
934 # FIXME: Because Automake macros are defined with their name unquoted,
935 # we can't yet provide the Autoupdate glue.
936 # AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
941 AC_DEFUN([AC_FUNC_MMAP],
942 [AC_CHECK_HEADERS(stdlib.h unistd.h)
943 AC_CHECK_FUNCS(getpagesize)
944 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
945 [AC_RUN_IFELSE([AC_LANG_SOURCE(
946 [[/* Thanks to Mike Haertel and Jim Avera for this test.
947 Here is a matrix of mmap possibilities:
948 mmap private not fixed
949 mmap private fixed at somewhere currently unmapped
950 mmap private fixed at somewhere already mapped
951 mmap shared not fixed
952 mmap shared fixed at somewhere currently unmapped
953 mmap shared fixed at somewhere already mapped
954 For private mappings, we should verify that changes cannot be read()
955 back from the file, nor mmap's back from the file at a different
956 address. (There have been systems where private was not correctly
957 implemented like the infamous i386 svr4.0, and systems where the
958 VM page cache was not coherent with the file system buffer cache
959 like early versions of FreeBSD and possibly contemporary NetBSD.)
960 For shared mappings, we should conversely verify that changes get
961 propogated back to all the places they're supposed to be.
963 Grep wants private fixed already mapped.
964 The main things grep needs to know about mmap are:
965 * does it exist and is it safe to write into the mmap'd area
966 * how to use it (BSD variants) */
967 #include <sys/types.h>
969 #include <sys/mman.h>
971 #if STDC_HEADERS || HAVE_STDLIB_H
979 #include <sys/stat.h>
981 /* This mess was copied from the GNU getpagesize.h. */
982 #if !HAVE_GETPAGESIZE
983 /* Assume that all systems that can run configure have sys/param.h. */
984 # if !HAVE_SYS_PARAM_H
985 # define HAVE_SYS_PARAM_H 1
989 # define getpagesize() sysconf(_SC_PAGESIZE)
990 # else /* no _SC_PAGESIZE */
991 # if HAVE_SYS_PARAM_H
992 # include <sys/param.h>
993 # ifdef EXEC_PAGESIZE
994 # define getpagesize() EXEC_PAGESIZE
995 # else /* no EXEC_PAGESIZE */
997 # define getpagesize() NBPG * CLSIZE
1000 # endif /* no CLSIZE */
1001 # else /* no NBPG */
1003 # define getpagesize() NBPC
1004 # else /* no NBPC */
1006 # define getpagesize() PAGESIZE
1007 # endif /* PAGESIZE */
1008 # endif /* no NBPC */
1009 # endif /* no NBPG */
1010 # endif /* no EXEC_PAGESIZE */
1011 # else /* no HAVE_SYS_PARAM_H */
1012 # define getpagesize() 8192 /* punt totally */
1013 # endif /* no HAVE_SYS_PARAM_H */
1014 # endif /* no _SC_PAGESIZE */
1016 #endif /* no HAVE_GETPAGESIZE */
1021 char *data, *data2, *data3;
1025 pagesize = getpagesize ();
1027 /* First, make a file with some known garbage in it. */
1028 data = (char *) malloc (pagesize);
1031 for (i = 0; i < pagesize; ++i)
1032 *(data + i) = rand ();
1034 fd = creat ("conftest.mmap", 0600);
1037 if (write (fd, data, pagesize) != pagesize)
1041 /* Next, try to mmap the file at a fixed address which already has
1042 something else allocated at it. If we can, also make sure that
1043 we see the same garbage. */
1044 fd = open ("conftest.mmap", O_RDWR);
1047 data2 = (char *) malloc (2 * pagesize);
1050 data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
1051 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1052 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1054 for (i = 0; i < pagesize; ++i)
1055 if (*(data + i) != *(data2 + i))
1058 /* Finally, make sure that changes to the mapped area do not
1059 percolate back to the file as seen by read(). (This is a bug on
1060 some variants of i386 svr4.0.) */
1061 for (i = 0; i < pagesize; ++i)
1062 *(data2 + i) = *(data2 + i) + 1;
1063 data3 = (char *) malloc (pagesize);
1066 if (read (fd, data3, pagesize) != pagesize)
1068 for (i = 0; i < pagesize; ++i)
1069 if (*(data + i) != *(data3 + i))
1074 [ac_cv_func_mmap_fixed_mapped=yes],
1075 [ac_cv_func_mmap_fixed_mapped=no],
1076 [ac_cv_func_mmap_fixed_mapped=no])])
1077 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1078 AC_DEFINE(HAVE_MMAP, 1,
1079 [Define if you have a working `mmap' system call.])
1087 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1092 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1093 AC_DEFUN([AC_FUNC_OBSTACK],
1094 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1095 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1096 [AC_TRY_LINK([@%:@include "obstack.h"],
1097 [struct obstack *mem; obstack_free(mem,(char *) 0)],
1098 [ac_cv_func_obstack=yes],
1099 [ac_cv_func_obstack=no])])
1100 if test $ac_cv_func_obstack = yes; then
1101 AC_DEFINE(HAVE_OBSTACK, 1, [Define if libc includes obstacks.])
1108 # AU::AM_FUNC_OBSTACK
1109 # -------------------
1110 # FIXME: Because Automake macros are defined with their name unquoted,
1111 # we can't yet provide the Autoupdate glue.
1112 # AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1115 # AC_FUNC_SELECT_ARGTYPES
1116 # -----------------------
1117 # Determine the correct type to be passed to each of the `select'
1118 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1119 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1120 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1121 [AC_CACHE_CHECK([types of arguments for select],
1122 [ac_cv_func_select_args],
1123 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1124 for ac_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
1125 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1126 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1127 [#include <sys/types.h>
1129 # include <sys/time.h>
1131 #if HAVE_SYS_SELECT_H
1132 # include <sys/select.h>
1134 #if HAVE_SYS_SOCKET_H
1135 # include <sys/socket.h>
1137 extern int select ($ac_arg1,$ac_arg234,$ac_arg234,$ac_arg234,$ac_arg5);])],
1138 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1142 # Provide a safe default value.
1143 : ${ac_cv_func_select_args='int,int *,struct timeval *'}
1145 ac_save_IFS=$IFS; IFS=','
1146 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1149 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1150 [Define to the type of arg 1 for `select'.])
1151 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1152 [Define to the type of args 2, 3 and 4 for `select'.])
1153 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1154 [Define to the type of arg 5 for `select'.])
1156 ])# AC_FUNC_SELECT_ARGTYPES
1161 AC_DEFUN([AC_FUNC_SETPGRP],
1162 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1166 # include <unistd.h>
1169 [/* If this system has a BSD-style setpgrp, which takes arguments, exit
1171 exit (setpgrp (1,1) == -1);])],
1172 [ac_cv_func_setpgrp_void=no],
1173 [ac_cv_func_setpgrp_void=yes],
1174 [AC_MSG_ERROR([cannot check setpgrp if cross compiling])])])
1175 if test $ac_cv_func_setpgrp_void = yes; then
1176 AC_DEFINE(SETPGRP_VOID, 1,
1177 [Define if the `setpgrp' function takes no argument.])
1182 # _AC_FUNC_STAT(STAT | LSTAT)
1183 # ---------------------------
1184 # Determine whether stat or lstat have the bug that it succeeds when
1185 # given the zero-length file name argument. The stat and lstat from
1186 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1188 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1189 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1191 m4_define([_AC_FUNC_STAT],
1192 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1193 AC_CACHE_CHECK([whether $1 accepts an empty string],
1194 [ac_cv_func_$1_empty_string_bug],
1196 [#include <sys/types.h>
1197 #include <sys/stat.h>
1203 exit ($1 ("", &sbuf) ? 1 : 0);
1205 [ac_cv_func_$1_empty_string_bug=yes],
1206 [ac_cv_func_$1_empty_string_bug=no],
1207 [ac_cv_func_$1_empty_string_bug=yes])])
1208 if test $ac_cv_func_$1_empty_string_bug = yes; then
1210 AC_DEFINE_UNQUOTED(AC_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1211 [Define if `$1' has the bug that it succeeds when
1212 given the zero-length file name argument.])
1217 # AC_FUNC_STAT & AC_FUNC_LSTAT
1218 # ----------------------------
1219 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1220 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1225 m4_define([_AC_LIBOBJ_STRTOD],
1228 if test $ac_cv_func_pow = no; then
1229 AC_CHECK_LIB(m, pow,
1231 [AC_MSG_WARN([can't find library containing definition of pow])])
1233 ])# _AC_LIBOBJ_STRTOD
1238 AC_DEFUN([AC_FUNC_STRTOD],
1239 [AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1246 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1247 char *string = " +69";
1250 value = strtod (string, &term);
1251 if (value != 69 || term != (string + 4))
1256 /* Under Solaris 2.4, strtod returns the wrong value for the
1257 terminating character under some conditions. */
1258 char *string = "NaN";
1260 strtod (string, &term);
1261 if (term != string && *(term - 1) == 0)
1267 ac_cv_func_strtod=yes,
1268 ac_cv_func_strtod=no,
1269 ac_cv_func_strtod=no)])
1270 if test $ac_cv_func_strtod = no; then
1276 # AU::AM_FUNC_STRTOD
1277 # ------------------
1278 # FIXME: Because Automake macros are defined with their name unquoted,
1279 # we can't yet provide the Autoupdate glue.
1280 # AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1283 # AC_FUNC_STRERROR_R
1284 # ------------------
1285 AC_DEFUN([AC_FUNC_STRERROR_R],
1286 [AC_CHECK_FUNCS([strerror_r])
1287 if test $ac_cv_func_strerror_r = yes; then
1288 AC_CHECK_HEADERS(string.h)
1289 AC_CACHE_CHECK([for working strerror_r],
1290 ac_cv_func_strerror_r_works,
1296 # include <string.h>
1301 char x = *strerror_r (0, &buf, sizeof buf);
1303 ac_cv_func_strerror_r_works=yes,
1304 ac_cv_func_strerror_r_works=no
1306 if test $ac_cv_func_strerror_r_works = yes; then
1307 AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
1308 [Define to 1 if `strerror_r' returns a string.])
1311 ])# AC_FUNC_STRERROR_R
1316 AC_DEFUN([AC_FUNC_STRFTIME],
1317 [AC_CHECK_FUNCS(strftime, [],
1318 [# strftime is in -lintl on SCO UNIX.
1319 AC_CHECK_LIB(intl, strftime,
1320 [AC_DEFINE(HAVE_STRFTIME)
1321 LIBS="-lintl $LIBS"])])dnl
1322 ])# AC_FUNC_STRFTIME
1325 # AC_FUNC_SETVBUF_REVERSED
1326 # ------------------------
1327 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1328 [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
1329 ac_cv_func_setvbuf_reversed,
1330 [AC_TRY_RUN([#include <stdio.h>
1331 /* If setvbuf has the reversed format, exit 0. */
1335 /* This call has the arguments reversed.
1336 A reversed system may check and see that the address of main
1337 is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
1338 if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
1341 exit(0); /* Non-reversed systems segv here. */
1342 }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
1343 rm -f core core.* *.core])
1344 if test $ac_cv_func_setvbuf_reversed = yes; then
1345 AC_DEFINE(SETVBUF_REVERSED, 1,
1346 [Define if the `setvbuf' function takes the buffering type as
1347 its second argument and the buffer pointer as the third, as on
1348 System V before release 3.])
1350 ])# AC_FUNC_SETVBUF_REVERSED
1353 # AU::AC_SETVBUF_REVERSED
1354 # -----------------------
1355 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1360 AC_DEFUN([AC_FUNC_STRCOLL],
1361 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1362 [AC_TRY_RUN([#include <string.h>
1366 exit (strcoll ("abc", "def") >= 0 ||
1367 strcoll ("ABC", "DEF") >= 0 ||
1368 strcoll ("123", "456") >= 0);
1369 }], ac_cv_func_strcoll_works=yes, ac_cv_func_strcoll_works=no,
1370 ac_cv_func_strcoll_works=no)])
1371 if test $ac_cv_func_strcoll_works = yes; then
1372 AC_DEFINE(HAVE_STRCOLL, 1,
1373 [Define if you have the `strcoll' function and it is properly
1381 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1384 # AC_FUNC_UTIME_NULL
1385 # ------------------
1386 AC_DEFUN([AC_FUNC_UTIME_NULL],
1387 [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1388 [rm -f conftest.data; >conftest.data
1389 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1391 [#include <sys/types.h>
1392 #include <sys/stat.h>
1397 exit (!(stat ("conftest.data", &s) == 0
1398 && utime ("conftest.data", (long *)0) == 0
1399 && stat ("conftest.data", &t) == 0
1400 && t.st_mtime >= s.st_mtime
1401 && t.st_mtime - s.st_mtime < 120));
1402 }], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
1403 ac_cv_func_utime_null=no)
1404 rm -f core core.* *.core])
1405 if test $ac_cv_func_utime_null = yes; then
1406 AC_DEFINE(HAVE_UTIME_NULL, 1,
1407 [Define if `utime(file, NULL)' sets file's timestamp to the
1411 ])# AC_FUNC_UTIME_NULL
1416 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1421 AC_DEFUN([AC_FUNC_VFORK],
1422 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1423 AC_CHECK_HEADERS(unistd.h vfork.h)
1424 AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1425 [AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */
1427 #include <sys/types.h>
1428 #include <sys/stat.h>
1430 # include <unistd.h>
1435 /* On some sparc systems, changes by the child to local and incoming
1436 argument registers are propagated back to the parent. The compiler
1437 is told about this with #include <vfork.h>, but some compilers
1438 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1439 static variable whose address is put into a register that is
1440 clobbered by the vfork. */
1443 sparc_address_test (int arg)
1445 sparc_address_test (arg) int arg;
1466 pid_t parent = getpid ();
1469 sparc_address_test ();
1474 /* Here is another test for sparc vfork register problems. This
1475 test uses lots of local variables, at least as many local
1476 variables as main has allocated so far including compiler
1477 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1478 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1479 reuse the register of parent for one of the local variables,
1480 since it will think that parent can't possibly be used any more
1481 in this routine. Assigning to the local variable will thus
1482 munge parent in the parent process. */
1484 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1485 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1486 /* Convince the compiler that p..p7 are live; otherwise, it might
1487 use the same hardware register for all 8 local variables. */
1488 if (p != p1 || p != p2 || p != p3 || p != p4
1489 || p != p5 || p != p6 || p != p7)
1492 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1493 from child file descriptors. If the child closes a descriptor
1494 before it execs or exits, this munges the parent's descriptor
1495 as well. Test for this by closing stdout in the child. */
1496 _exit(close(fileno(stdout)) != 0);
1501 while (wait(&status) != child)
1504 /* Was there some problem with vforking? */
1507 /* Did the child fail? (This shouldn't happen.) */
1510 /* Did the vfork/compiler bug occur? */
1511 || parent != getpid()
1513 /* Did the file descriptor bug occur? */
1514 || fstat(fileno(stdout), &st) != 0
1518 [ac_cv_func_vfork_works=yes],
1519 [ac_cv_func_vfork_works=no],
1520 [AC_CHECK_FUNC(vfork)
1521 ac_cv_func_vfork_works=$ac_cv_func_vfork])])
1522 if test "x$ac_cv_func_vfork_works" = xno; then
1523 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1530 AU_ALIAS([AC_VFORK], [AC_FUNC_VFORK])
1535 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1536 # That the logical name!
1537 AC_DEFUN([AC_FUNC_VPRINTF],
1538 [AC_CHECK_FUNCS(vprintf, []
1539 [AC_CHECK_FUNC(_doprnt,
1540 [AC_DEFINE(HAVE_DOPRNT, 1,
1541 [Define if you don't have `vprintf' but do have
1548 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1553 AC_DEFUN([AC_FUNC_WAIT3],
1554 [AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
1556 [#include <sys/types.h>
1557 #include <sys/time.h>
1558 #include <sys/resource.h>
1560 /* HP-UX has wait3 but does not fill in rusage at all. */
1566 /* Use a field that we can force nonzero --
1567 voluntary context switches.
1568 For systems like NeXT and OSF/1 that don't set it,
1569 also use the system CPU time. And page faults (I/O) for Linux. */
1571 r.ru_stime.tv_sec = 0;
1572 r.ru_stime.tv_usec = 0;
1573 r.ru_majflt = r.ru_minflt = 0;
1576 case 0: /* Child. */
1577 sleep(1); /* Give up the CPU. */
1579 case -1: /* What can we do? */
1581 default: /* Parent. */
1583 /* Avoid "text file busy" from rm on fast HP-UX machines. */
1585 exit (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1586 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1588 }], ac_cv_func_wait3_rusage=yes, ac_cv_func_wait3_rusage=no,
1589 ac_cv_func_wait3_rusage=no)])
1590 if test $ac_cv_func_wait3_rusage = yes; then
1591 AC_DEFINE(HAVE_WAIT3, 1,
1592 [Define if you have the `wait3' system call.])
1599 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])