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 to 1 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)])
100
# AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
101
# ------------------------------------------------------------
102
# Try to link a program that calls FUNC, handling GCC builtins. If
103
# the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
104
# ACTION-IF-NOT-FOUND.
105
AC_DEFUN([AC_TRY_LINK_FUNC],
106
[AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
111
AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
116
AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
121
## --------------------------------- ##
122
## 2. Tests for specific functions. ##
123
## --------------------------------- ##
126
# The macros are sorted:
128
# 1. AC_FUNC_* macros are sorted by alphabetical order.
130
# 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
133
# 3. Obsolete macros are right after the modern macro.
139
# Set up the LIBOBJ replacement of `alloca'. Well, not exactly
140
# AC_LIBOBJ since we actually set the output variable `ALLOCA'.
141
# Nevertheless, for Automake, AC_LIBSOURCES it.
142
m4_define([_AC_LIBOBJ_ALLOCA],
143
[# The SVR3 libPW and SVR4 libucb both contain incompatible functions
144
# that cause trouble. Some versions do not even contain alloca or
145
# contain a buggy version. If you still want to use their alloca,
146
# use ar to extract alloca.o from them instead of compiling alloca.c.
147
AC_LIBSOURCES(alloca.c)
148
AC_SUBST(ALLOCA, alloca.$ac_objext)dnl
149
AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
151
AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
152
[AC_EGREP_CPP(webecray,
153
[#if defined(CRAY) && ! defined(CRAY2)
158
], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
159
if test $ac_cv_os_cray = yes; then
160
for ac_func in _getb67 GETB67 getb67; do
161
AC_CHECK_FUNC($ac_func,
162
[AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
163
[Define to one of `_getb67', `GETB67',
164
`getb67' for Cray-2 and Cray-YMP
165
systems. This function is required for
166
`alloca.c' support on those systems.])
171
AC_CACHE_CHECK([stack direction for C alloca],
172
[ac_cv_c_stack_direction],
173
[AC_RUN_IFELSE([AC_LANG_SOURCE(
175
find_stack_direction ()
177
static char *addr = 0;
182
return find_stack_direction ();
185
return (&dummy > addr) ? 1 : -1;
191
exit (find_stack_direction () < 0);
193
[ac_cv_c_stack_direction=1],
194
[ac_cv_c_stack_direction=-1],
195
[ac_cv_c_stack_direction=0])])
196
AH_VERBATIM([STACK_DIRECTION],
197
[/* If using the C implementation of alloca, define if you know the
198
direction of stack growth for your system; otherwise it will be
199
automatically deduced at run-time.
200
STACK_DIRECTION > 0 => grows toward higher addresses
201
STACK_DIRECTION < 0 => grows toward lower addresses
202
STACK_DIRECTION = 0 => direction of growth unknown */
203
@%:@undef STACK_DIRECTION])dnl
204
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
205
])# _AC_LIBOBJ_ALLOCA
210
AC_DEFUN([AC_FUNC_ALLOCA],
211
[# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
212
# for constant arguments. Useless!
213
AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
215
[AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
216
[[char *p = (char *) alloca (2 * sizeof (int));]])],
217
[ac_cv_working_alloca_h=yes],
218
[ac_cv_working_alloca_h=no])])
219
if test $ac_cv_working_alloca_h = yes; then
220
AC_DEFINE(HAVE_ALLOCA_H, 1,
221
[Define to 1 if you have <alloca.h> and it should be used
225
AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
226
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
228
# define alloca __builtin_alloca
232
# define alloca _alloca
240
# ifndef alloca /* predefined by HP cc +Olibcalls */
247
]], [[char *p = (char *) alloca (1);]])],
248
[ac_cv_func_alloca_works=yes],
249
[ac_cv_func_alloca_works=no])])
251
if test $ac_cv_func_alloca_works = yes; then
252
AC_DEFINE(HAVE_ALLOCA, 1,
253
[Define to 1 if you have `alloca', as a function or macro.])
262
AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
267
# Determine whether chown accepts arguments of -1 for uid and gid.
268
AC_DEFUN([AC_FUNC_CHOWN],
269
[AC_REQUIRE([AC_TYPE_UID_T])dnl
270
AC_CHECK_HEADERS(unistd.h)
271
AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
272
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
275
[[ char *f = "conftest.chown";
276
struct stat before, after;
278
if (creat (f, 0600) < 0)
280
if (stat (f, &before) < 0)
282
if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
284
if (stat (f, &after) < 0)
286
exit ((before.st_uid == after.st_uid
287
&& before.st_gid == after.st_gid) ? 0 : 1);
289
[ac_cv_func_chown_works=yes],
290
[ac_cv_func_chown_works=no],
291
[ac_cv_func_chown_works=no])
294
if test $ac_cv_func_chown_works = yes; then
295
AC_DEFINE(HAVE_CHOWN, 1,
296
[Define to 1 if your system has a working `chown' function.])
301
# AC_FUNC_CLOSEDIR_VOID
302
# ---------------------
303
# Check whether closedir returns void, and #define CLOSEDIR_VOID in
305
AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
306
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
307
AC_CACHE_CHECK([whether closedir returns void],
308
[ac_cv_func_closedir_void],
309
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
310
#include <$ac_header_dirent>
315
[[exit (closedir (opendir (".")) != 0);]])],
316
[ac_cv_func_closedir_void=no],
317
[ac_cv_func_closedir_void=yes],
318
[ac_cv_func_closedir_void=yes])])
319
if test $ac_cv_func_closedir_void = yes; then
320
AC_DEFINE(CLOSEDIR_VOID, 1,
321
[Define to 1 if the `closedir' function returns void instead
327
# AC_FUNC_ERROR_AT_LINE
328
# ---------------------
329
AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
330
[AC_LIBSOURCES([error.h, error.c])dnl
331
AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
332
[AC_LINK_IFELSE([AC_LANG_PROGRAM([],[error_at_line (0, 0, "", 0, "");])],
333
[ac_cv_lib_error_at_line=yes],
334
[ac_cv_lib_error_at_line=no])])
335
if test $ac_cv_lib_error_at_line = no; then
341
# AU::AM_FUNC_ERROR_AT_LINE
342
# -------------------------
343
AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
348
# We look for fnmatch.h to avoid that the test fails in C++.
349
AC_DEFUN([AC_FUNC_FNMATCH],
350
[AC_CACHE_CHECK([for working GNU-style fnmatch],
351
[ac_cv_func_fnmatch_works],
352
# Some versions of Solaris, SCO, and the GNU C Library
353
# have a broken or incompatible fnmatch.
354
# So we run a test program. If we are cross-compiling, take no chance.
355
# Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
356
[AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include <fnmatch.h>],
357
[exit (fnmatch ("a*", "abc", 0) != 0
358
|| fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) != FNM_NOMATCH
359
|| fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
360
|| fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) != 0
361
|| fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0);])],
362
[ac_cv_func_fnmatch_works=yes],
363
[ac_cv_func_fnmatch_works=no],
364
[ac_cv_func_fnmatch_works=no])])
365
if test $ac_cv_func_fnmatch_works = yes; then
366
AC_DEFINE(HAVE_FNMATCH, 1,
367
[Define to 1 if your system has a working `fnmatch' function.])
372
# AU::AM_FUNC_FNMATCH
373
# AU::fp_FUNC_FNMATCH
374
# -------------------
375
AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
376
AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
381
AC_DEFUN([AC_FUNC_FSEEKO],
382
[_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
383
[ac_cv_sys_largefile_source],
384
[Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
385
[@%:@include <stdio.h>], [return !fseeko;])
387
# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
388
# in glibc 2.1.3, but that breaks too many other things.
389
# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
390
AC_CACHE_CHECK([for fseeko], [ac_cv_func_fseeko],
391
[AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <stdio.h>],
392
[[return fseeko && fseeko (stdin, 0, 0);]])],
393
[ac_cv_func_fseeko=yes],
394
[ac_cv_func_fseeko=no])])
395
if test $ac_cv_func_fseeko = yes; then
396
AC_DEFINE(HAVE_FSEEKO, 1,
397
[Define to 1 if fseeko (and presumably ftello) exists and is declared.])
404
# Try to find `getgroups', and check that it works.
405
# When crosscompiling, assume getgroups is broken.
406
AC_DEFUN([AC_FUNC_GETGROUPS],
407
[AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
408
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
409
AC_CHECK_FUNC(getgroups)
411
# If we don't yet have getgroups, see if it's in -lbsd.
412
# This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
414
if test $ac_cv_func_getgroups = no; then
415
AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
418
# Run the program to test the functionality of the system-supplied
419
# getgroups function only if there is such a function.
420
if test $ac_cv_func_getgroups = yes; then
421
AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
422
[AC_RUN_IFELSE([AC_LANG_PROGRAM([],
423
[[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
424
exit (getgroups (0, 0) == -1 ? 1 : 0);]])],
425
[ac_cv_func_getgroups_works=yes],
426
[ac_cv_func_getgroups_works=no],
427
[ac_cv_func_getgroups_works=no])
429
if test $ac_cv_func_getgroups_works = yes; then
430
AC_DEFINE(HAVE_GETGROUPS, 1,
431
[Define to 1 if your system has a working `getgroups' function.])
435
])# AC_FUNC_GETGROUPS
438
# _AC_LIBOBJ_GETLOADAVG
439
# ---------------------
440
# Set up the AC_LIBOBJ replacement of `getloadavg'.
441
m4_define([_AC_LIBOBJ_GETLOADAVG],
442
[AC_LIBOBJ(getloadavg)
443
AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
444
# Figure out what our getloadavg.c needs.
446
AC_CHECK_HEADER(sys/dg_sys_info.h,
448
AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
449
AC_CHECK_LIB(dgc, dg_sys_info)])
451
AC_CHECK_HEADER(locale.h)
452
AC_CHECK_FUNCS(setlocale)
454
# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
455
# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
456
# Irix 4.0.5F has the header but not the library.
457
if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
459
AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
462
if test $ac_have_func = no; then
463
AC_CHECK_HEADER(inq_stats/cpustats.h,
465
AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
466
AC_DEFINE(UMAX4_3, 1,
467
[Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
468
instead of <sys/cpustats.h>.])])
471
if test $ac_have_func = no; then
472
AC_CHECK_HEADER(sys/cpustats.h,
473
[ac_have_func=yes; AC_DEFINE(UMAX)])
476
if test $ac_have_func = no; then
477
AC_CHECK_HEADERS(mach/mach.h)
480
AC_CHECK_HEADERS(nlist.h,
481
[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
482
[AC_DEFINE(NLIST_NAME_UNION, 1,
483
[Define to 1 if your `struct nlist' has an
484
`n_un' member. Obsolete, depend on
485
`HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
486
[@%:@include <nlist.h>])
488
])# _AC_LIBOBJ_GETLOADAVG
493
AC_DEFUN([AC_FUNC_GETLOADAVG],
494
[ac_have_func=no # yes means we've found a way to get the load average.
498
# Check for getloadavg, but be sure not to touch the cache variable.
499
(AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
501
# On HPUX9, an unprivileged user can get load averages through this function.
502
AC_CHECK_FUNCS(pstat_getdynamic)
504
# Solaris has libkstat which does not require root.
505
AC_CHECK_LIB(kstat, kstat_open)
506
test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
508
# Some systems with -lutil have (and need) -lkvm as well, some do not.
509
# On Solaris, -lkvm requires nlist from -lelf, so check that first
510
# to get the right answer into the cache.
511
# For kstat on solaris, we need libelf to force the definition of SVR4 below.
512
if test $ac_have_func = no; then
513
AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
515
if test $ac_have_func = no; then
516
AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
517
# Check for the 4.4BSD definition of getloadavg.
518
AC_CHECK_LIB(util, getloadavg,
519
[LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
522
if test $ac_have_func = no; then
523
# There is a commonly available library for RS/6000 AIX.
524
# Since it is not a standard part of AIX, it might be installed locally.
525
ac_getloadavg_LIBS=$LIBS
526
LIBS="-L/usr/local/lib $LIBS"
527
AC_CHECK_LIB(getloadavg, getloadavg,
528
[LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
531
# Make sure it is really in the library, if we think we found it,
532
# otherwise set up the replacement function.
533
AC_CHECK_FUNCS(getloadavg, [],
534
[_AC_LIBOBJ_GETLOADAVG])
536
# Some definitions of getloadavg require that the program be installed setgid.
537
dnl FIXME: Don't hardwire the path of getloadavg.c in the top-level directory.
538
AC_CACHE_CHECK(whether getloadavg requires setgid,
539
ac_cv_func_getloadavg_setgid,
540
[AC_EGREP_CPP([Yowza Am I SETGID yet],
541
[#include "$srcdir/getloadavg.c"
542
#ifdef LDAV_PRIVILEGED
543
Yowza Am I SETGID yet
545
ac_cv_func_getloadavg_setgid=yes,
546
ac_cv_func_getloadavg_setgid=no)])
547
if test $ac_cv_func_getloadavg_setgid = yes; then
549
AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
550
[Define to 1 if the `getloadavg' function needs to be run setuid
555
AC_SUBST(NEED_SETGID)dnl
557
if test $ac_cv_func_getloadavg_setgid = yes; then
558
AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
559
[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
560
ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
561
# If we got an error (system does not support symlinks), try without -L.
562
test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
563
ac_cv_group_kmem=`echo $ac_ls_output \
564
| sed -ne ['s/[ ][ ]*/ /g;
565
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
568
AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
570
if test "x$ac_save_LIBS" = x; then
571
GETLOADAVG_LIBS=$LIBS
573
GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
577
AC_SUBST(GETLOADAVG_LIBS)dnl
578
])# AC_FUNC_GETLOADAVG
583
AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
588
AC_DEFUN([AC_FUNC_GETMNTENT],
589
[# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
590
AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
591
[AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
592
[AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
593
AC_CHECK_FUNCS(getmntent)
599
# Figure out whether getpgrp requires zero arguments.
600
AC_DEFUN([AC_FUNC_GETPGRP],
601
[AC_CACHE_CHECK(whether getpgrp requires zero arguments,
602
ac_cv_func_getpgrp_void,
603
[# Use it with a single arg.
604
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
605
[ac_cv_func_getpgrp_void=no],
606
[ac_cv_func_getpgrp_void=yes])
608
if test $ac_cv_func_getpgrp_void = yes; then
609
AC_DEFINE(GETPGRP_VOID, 1,
610
[Define to 1 if the `getpgrp' function requires zero arguments.])
615
# AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
616
# -------------------------------------
617
# When crosscompiling, be pessimistic so we will end up using the
618
# replacement version of lstat that checkes for trailing slashes and
619
# calls lstat a second time when necessary.
620
AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
622
[whether lstat dereferences a symlink specified with a trailing slash],
623
[ac_cv_func_lstat_dereferences_slashed_symlink],
624
[rm -f conftest.sym conftest.file
626
if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
627
AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
629
/* Linux will dereference the symlink and fail.
630
That is better in the sense that it means we will not
631
have to compile and use the lstat wrapper. */
632
exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);])],
633
[ac_cv_func_lstat_dereferences_slashed_symlink=yes],
634
[ac_cv_func_lstat_dereferences_slashed_symlink=no],
635
[ac_cv_func_lstat_dereferences_slashed_symlink=no])
637
# If the `ln -s' command failed, then we probably don't even
638
# have an lstat function.
639
ac_cv_func_lstat_dereferences_slashed_symlink=no
641
rm -f conftest.sym conftest.file
644
test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
645
AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
646
[Define to 1 if `lstat' dereferences a symlink specified
647
with a trailing slash.])
649
if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
657
# Is `malloc (0)' properly handled?
658
AC_DEFUN([AC_FUNC_MALLOC],
659
[AC_REQUIRE([AC_HEADER_STDC])dnl
660
AC_CHECK_HEADERS(stdlib.h)
661
AC_CACHE_CHECK([for working malloc], ac_cv_func_malloc_works,
664
[[#if STDC_HEADERS || HAVE_STDLIB_H
670
[exit (malloc (0) ? 0 : 1);])],
671
[ac_cv_func_malloc_works=yes],
672
[ac_cv_func_malloc_works=no],
673
[ac_cv_func_malloc_works=no])])
674
if test $ac_cv_func_malloc_works = yes; then
675
AC_DEFINE(HAVE_MALLOC, 1,
676
[Define to 1 if your system has a working `malloc' function.])
683
AC_DEFUN([AC_FUNC_MEMCMP],
684
[AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
685
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
686
/* Some versions of memcmp are not 8-bit clean. */
687
char c0 = 0x40, c1 = 0x80, c2 = 0x81;
688
if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
691
/* The Next x86 OpenStep bug shows up only when comparing 16 bytes
692
or more and with at least one buffer not starting on a 4-byte boundary.
693
William Lewis provided this test program. */
698
for (i = 0; i < 4; i++)
702
strcpy (a, "--------01111111");
703
strcpy (b, "--------10000000");
704
if (memcmp (a, b, 16) >= 0)
710
[ac_cv_func_memcmp_working=yes],
711
[ac_cv_func_memcmp_working=no],
712
[ac_cv_func_memcmp_working=no])])
713
test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
719
AC_DEFUN([AC_FUNC_MKTIME],
720
[AC_REQUIRE([AC_HEADER_TIME])dnl
721
AC_CHECK_HEADERS(sys/time.h unistd.h)
722
AC_CHECK_FUNCS(alarm)
723
AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
724
[AC_RUN_IFELSE([AC_LANG_SOURCE(
725
[[/* Test program from Paul Eggert and Tony Leneis. */
726
#if TIME_WITH_SYS_TIME
727
# include <sys/time.h>
731
# include <sys/time.h>
742
# define alarm(X) /* empty */
745
/* Work around redefinition to rpl_putenv by other config tests. */
748
static time_t time_t_max;
750
/* Values we'll use to set the TZ environment variable. */
751
static const char *const tz_strings[] = {
752
(const char *) 0, "TZ=GMT0", "TZ=JST-9",
753
"TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
755
#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
757
/* Fail if mktime fails to convert a date in the spring-forward gap.
758
Based on a problem report from Andreas Jaeger. */
760
spring_forward_gap ()
762
/* glibc (up to about 1998-10-07) failed this test. */
765
/* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
766
instead of "TZ=America/Vancouver" in order to detect the bug even
767
on systems that don't support the Olson extension, or don't have the
768
full zoneinfo tables installed. */
769
putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
778
if (mktime (&tm) == (time_t)-1)
787
if ((lt = localtime (&now)) && mktime (lt) != now)
789
now = time_t_max - now;
790
if ((lt = localtime (&now)) && mktime (lt) != now)
797
/* Based on code from Ariel Faigon. */
807
if (tm.tm_mon != 2 || tm.tm_mday != 31)
817
tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
819
if (now != (time_t) -1)
821
struct tm *lt = localtime (&now);
823
&& lt->tm_year == tm.tm_year
824
&& lt->tm_mon == tm.tm_mon
825
&& lt->tm_mday == tm.tm_mday
826
&& lt->tm_hour == tm.tm_hour
827
&& lt->tm_min == tm.tm_min
828
&& lt->tm_sec == tm.tm_sec
829
&& lt->tm_yday == tm.tm_yday
830
&& lt->tm_wday == tm.tm_wday
831
&& ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
832
== (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
843
/* This test makes some buggy mktime implementations loop.
844
Give up after 60 seconds; a mktime slower than that
845
isn't worth using anyway. */
848
for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
851
delta = time_t_max / 997; /* a suitable prime number */
852
for (i = 0; i < N_STRINGS; i++)
855
putenv (tz_strings[i]);
857
for (t = 0; t <= time_t_max - delta; t += delta)
859
mktime_test ((time_t) 60 * 60);
860
mktime_test ((time_t) 60 * 60 * 24);
862
for (j = 1; 0 < j; j *= 2)
864
bigtime_test (j - 1);
867
spring_forward_gap ();
870
[ac_cv_func_working_mktime=yes],
871
[ac_cv_func_working_mktime=no],
872
[ac_cv_func_working_mktime=no])])
873
if test $ac_cv_func_working_mktime = no; then
881
AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
886
AC_DEFUN([AC_FUNC_MMAP],
887
[AC_CHECK_HEADERS(stdlib.h unistd.h)
888
AC_CHECK_FUNCS(getpagesize)
889
AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
890
[AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
891
[[/* malloc might have been renamed as rpl_malloc. */
894
/* Thanks to Mike Haertel and Jim Avera for this test.
895
Here is a matrix of mmap possibilities:
896
mmap private not fixed
897
mmap private fixed at somewhere currently unmapped
898
mmap private fixed at somewhere already mapped
899
mmap shared not fixed
900
mmap shared fixed at somewhere currently unmapped
901
mmap shared fixed at somewhere already mapped
902
For private mappings, we should verify that changes cannot be read()
903
back from the file, nor mmap's back from the file at a different
904
address. (There have been systems where private was not correctly
905
implemented like the infamous i386 svr4.0, and systems where the
906
VM page cache was not coherent with the file system buffer cache
907
like early versions of FreeBSD and possibly contemporary NetBSD.)
908
For shared mappings, we should conversely verify that changes get
909
propagated back to all the places they're supposed to be.
911
Grep wants private fixed already mapped.
912
The main things grep needs to know about mmap are:
913
* does it exist and is it safe to write into the mmap'd area
914
* how to use it (BSD variants) */
917
#include <sys/mman.h>
919
#if !STDC_HEADERS && !HAVE_STDLIB_H
923
/* This mess was copied from the GNU getpagesize.h. */
924
#if !HAVE_GETPAGESIZE
925
/* Assume that all systems that can run configure have sys/param.h. */
926
# if !HAVE_SYS_PARAM_H
927
# define HAVE_SYS_PARAM_H 1
931
# define getpagesize() sysconf(_SC_PAGESIZE)
932
# else /* no _SC_PAGESIZE */
933
# if HAVE_SYS_PARAM_H
934
# include <sys/param.h>
935
# ifdef EXEC_PAGESIZE
936
# define getpagesize() EXEC_PAGESIZE
937
# else /* no EXEC_PAGESIZE */
939
# define getpagesize() NBPG * CLSIZE
942
# endif /* no CLSIZE */
945
# define getpagesize() NBPC
948
# define getpagesize() PAGESIZE
949
# endif /* PAGESIZE */
950
# endif /* no NBPC */
951
# endif /* no NBPG */
952
# endif /* no EXEC_PAGESIZE */
953
# else /* no HAVE_SYS_PARAM_H */
954
# define getpagesize() 8192 /* punt totally */
955
# endif /* no HAVE_SYS_PARAM_H */
956
# endif /* no _SC_PAGESIZE */
958
#endif /* no HAVE_GETPAGESIZE */
963
char *data, *data2, *data3;
967
pagesize = getpagesize ();
969
/* First, make a file with some known garbage in it. */
970
data = (char *) malloc (pagesize);
973
for (i = 0; i < pagesize; ++i)
974
*(data + i) = rand ();
976
fd = creat ("conftest.mmap", 0600);
979
if (write (fd, data, pagesize) != pagesize)
983
/* Next, try to mmap the file at a fixed address which already has
984
something else allocated at it. If we can, also make sure that
985
we see the same garbage. */
986
fd = open ("conftest.mmap", O_RDWR);
989
data2 = (char *) malloc (2 * pagesize);
992
data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
993
if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
994
MAP_PRIVATE | MAP_FIXED, fd, 0L))
996
for (i = 0; i < pagesize; ++i)
997
if (*(data + i) != *(data2 + i))
1000
/* Finally, make sure that changes to the mapped area do not
1001
percolate back to the file as seen by read(). (This is a bug on
1002
some variants of i386 svr4.0.) */
1003
for (i = 0; i < pagesize; ++i)
1004
*(data2 + i) = *(data2 + i) + 1;
1005
data3 = (char *) malloc (pagesize);
1008
if (read (fd, data3, pagesize) != pagesize)
1010
for (i = 0; i < pagesize; ++i)
1011
if (*(data + i) != *(data3 + i))
1016
[ac_cv_func_mmap_fixed_mapped=yes],
1017
[ac_cv_func_mmap_fixed_mapped=no],
1018
[ac_cv_func_mmap_fixed_mapped=no])])
1019
if test $ac_cv_func_mmap_fixed_mapped = yes; then
1020
AC_DEFINE(HAVE_MMAP, 1,
1021
[Define to 1 if you have a working `mmap' system call.])
1029
AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1034
# Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1035
AC_DEFUN([AC_FUNC_OBSTACK],
1036
[AC_LIBSOURCES([obstack.h, obstack.c])dnl
1037
AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1039
[AC_LANG_PROGRAM([[@%:@include "obstack.h"]],
1040
[[struct obstack *mem; obstack_free(mem,(char *) 0)]])],
1041
[ac_cv_func_obstack=yes],
1042
[ac_cv_func_obstack=no])])
1043
if test $ac_cv_func_obstack = yes; then
1044
AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1051
# AU::AM_FUNC_OBSTACK
1052
# -------------------
1053
AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1056
# AC_FUNC_SELECT_ARGTYPES
1057
# -----------------------
1058
# Determine the correct type to be passed to each of the `select'
1059
# function's arguments, and define those types in `SELECT_TYPE_ARG1',
1060
# `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1061
AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1062
[AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1063
AC_CACHE_CHECK([types of arguments for select],
1064
[ac_cv_func_select_args],
1065
[for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1066
for ac_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
1067
for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1070
[AC_INCLUDES_DEFAULT
1071
#if HAVE_SYS_SELECT_H
1072
# include <sys/select.h>
1074
#if HAVE_SYS_SOCKET_H
1075
# include <sys/socket.h>
1078
[extern int select ($ac_arg1,
1079
$ac_arg234, $ac_arg234, $ac_arg234,
1081
[ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1085
# Provide a safe default value.
1086
: ${ac_cv_func_select_args='int,int *,struct timeval *'}
1088
ac_save_IFS=$IFS; IFS=','
1089
set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1092
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1093
[Define to the type of arg 1 for `select'.])
1094
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1095
[Define to the type of args 2, 3 and 4 for `select'.])
1096
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1097
[Define to the type of arg 5 for `select'.])
1099
])# AC_FUNC_SELECT_ARGTYPES
1104
AC_DEFUN([AC_FUNC_SETPGRP],
1105
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1109
# include <unistd.h>
1112
[/* If this system has a BSD-style setpgrp which takes arguments,
1113
setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1114
exit successfully. */
1115
exit (setpgrp (1,1) == -1 ? 0 : 1);])],
1116
[ac_cv_func_setpgrp_void=no],
1117
[ac_cv_func_setpgrp_void=yes],
1118
[AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1119
if test $ac_cv_func_setpgrp_void = yes; then
1120
AC_DEFINE(SETPGRP_VOID, 1,
1121
[Define to 1 if the `setpgrp' function takes no argument.])
1126
# _AC_FUNC_STAT(STAT | LSTAT)
1127
# ---------------------------
1128
# Determine whether stat or lstat have the bug that it succeeds when
1129
# given the zero-length file name argument. The stat and lstat from
1130
# SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1132
# If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1133
# HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1135
m4_define([_AC_FUNC_STAT],
1136
[AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1137
AC_CACHE_CHECK([whether $1 accepts an empty string],
1138
[ac_cv_func_$1_empty_string_bug],
1139
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1141
exit ($1 ("", &sbuf) ? 1 : 0);]])],
1142
[ac_cv_func_$1_empty_string_bug=yes],
1143
[ac_cv_func_$1_empty_string_bug=no],
1144
[ac_cv_func_$1_empty_string_bug=yes])])
1145
if test $ac_cv_func_$1_empty_string_bug = yes; then
1147
AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1148
[Define to 1 if `$1' has the bug that it succeeds when
1149
given the zero-length file name argument.])
1154
# AC_FUNC_STAT & AC_FUNC_LSTAT
1155
# ----------------------------
1156
AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1157
AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1162
m4_define([_AC_LIBOBJ_STRTOD],
1165
if test $ac_cv_func_pow = no; then
1166
AC_CHECK_LIB(m, pow,
1168
[AC_MSG_WARN([cannot find library containing definition of pow])])
1170
])# _AC_LIBOBJ_STRTOD
1175
AC_DEFUN([AC_FUNC_STRTOD],
1176
[AC_SUBST(POW_LIB)dnl
1177
AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1178
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
1184
/* Some versions of Linux strtod mis-parse strings with leading '+'. */
1185
char *string = " +69";
1188
value = strtod (string, &term);
1189
if (value != 69 || term != (string + 4))
1194
/* Under Solaris 2.4, strtod returns the wrong value for the
1195
terminating character under some conditions. */
1196
char *string = "NaN";
1198
strtod (string, &term);
1199
if (term != string && *(term - 1) == 0)
1205
ac_cv_func_strtod=yes,
1206
ac_cv_func_strtod=no,
1207
ac_cv_func_strtod=no)])
1208
if test $ac_cv_func_strtod = no; then
1214
# AU::AM_FUNC_STRTOD
1215
# ------------------
1216
AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1219
# AC_FUNC_STRERROR_R
1220
# ------------------
1221
AC_DEFUN([AC_FUNC_STRERROR_R],
1222
[AC_CHECK_DECLS([strerror_r])
1223
AC_CHECK_FUNCS([strerror_r])
1224
AC_CACHE_CHECK([whether strerror_r returns char *],
1225
ac_cv_func_strerror_r_char_p,
1227
ac_cv_func_strerror_r_char_p=no
1228
if test $ac_cv_have_decl_strerror_r = yes; then
1229
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1232
char x = *strerror_r (0, buf, sizeof buf);
1233
char *p = strerror_r (0, buf, sizeof buf);
1235
ac_cv_func_strerror_r_char_p=yes)
1237
# strerror_r is not declared. Choose between
1238
# systems that have relatively inaccessible declarations for the
1239
# function. BeOS and DEC UNIX 4.0 fall in this category, but the
1240
# former has a strerror_r that returns char*, while the latter
1241
# has a strerror_r that returns `int'.
1242
# This test should segfault on the DEC system.
1243
AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1244
extern char *strerror_r ();],
1246
char x = *strerror_r (0, buf, sizeof buf);
1247
exit (!isalpha (x));]])],
1248
ac_cv_func_strerror_r_char_p=yes, , :)
1251
if test $ac_cv_func_strerror_r_char_p = yes; then
1252
AC_DEFINE([STRERROR_R_CHAR_P], 1,
1253
[Define to 1 if strerror_r returns char *.])
1255
])# AC_FUNC_STRERROR_R
1260
AC_DEFUN([AC_FUNC_STRFTIME],
1261
[AC_CHECK_FUNCS(strftime, [],
1262
[# strftime is in -lintl on SCO UNIX.
1263
AC_CHECK_LIB(intl, strftime,
1264
[AC_DEFINE(HAVE_STRFTIME)
1265
LIBS="-lintl $LIBS"])])dnl
1266
])# AC_FUNC_STRFTIME
1271
AC_DEFUN([AC_FUNC_STRNLEN],
1272
[AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1273
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
1275
#define S_LEN (sizeof S - 1)
1277
/* At least one implementation is buggy: that of AIX 4.3 would
1278
give strnlen (S, 1) == 3. */
1281
for (i = 0; i < S_LEN + 1; ++i)
1283
int expected = i <= S_LEN ? i : S_LEN;
1284
if (strnlen (S, i) != expected)
1289
[ac_cv_func_strnlen_working=yes],
1290
[ac_cv_func_strnlen_working=no],
1291
[ac_cv_func_strnlen_working=no])])
1292
test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1296
# AC_FUNC_SETVBUF_REVERSED
1297
# ------------------------
1298
AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1299
[AC_CACHE_CHECK(whether setvbuf arguments are reversed,
1300
ac_cv_func_setvbuf_reversed,
1301
[AC_TRY_RUN([#include <stdio.h>
1302
/* If setvbuf has the reversed format, exit 0. */
1306
/* This call has the arguments reversed.
1307
A reversed system may check and see that the address of main
1308
is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
1309
if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
1312
exit(0); /* Non-reversed systems segv here. */
1313
}], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
1314
rm -f core core.* *.core])
1315
if test $ac_cv_func_setvbuf_reversed = yes; then
1316
AC_DEFINE(SETVBUF_REVERSED, 1,
1317
[Define to 1 if the `setvbuf' function takes the buffering type as
1318
its second argument and the buffer pointer as the third, as on
1319
System V before release 3.])
1321
])# AC_FUNC_SETVBUF_REVERSED
1324
# AU::AC_SETVBUF_REVERSED
1325
# -----------------------
1326
AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1331
AC_DEFUN([AC_FUNC_STRCOLL],
1332
[AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1333
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1334
[[exit (strcoll ("abc", "def") >= 0 ||
1335
strcoll ("ABC", "DEF") >= 0 ||
1336
strcoll ("123", "456") >= 0)]])],
1337
ac_cv_func_strcoll_works=yes,
1338
ac_cv_func_strcoll_works=no,
1339
ac_cv_func_strcoll_works=no)])
1340
if test $ac_cv_func_strcoll_works = yes; then
1341
AC_DEFINE(HAVE_STRCOLL, 1,
1342
[Define to 1 if you have the `strcoll' function and it is properly
1350
AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1353
# AC_FUNC_UTIME_NULL
1354
# ------------------
1355
AC_DEFUN([AC_FUNC_UTIME_NULL],
1356
[AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1357
[rm -f conftest.data; >conftest.data
1358
# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1359
AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1361
exit (!(stat ("conftest.data", &s) == 0
1362
&& utime ("conftest.data", (long *)0) == 0
1363
&& stat ("conftest.data", &t) == 0
1364
&& t.st_mtime >= s.st_mtime
1365
&& t.st_mtime - s.st_mtime < 120));]])],
1366
ac_cv_func_utime_null=yes,
1367
ac_cv_func_utime_null=no,
1368
ac_cv_func_utime_null=no)
1369
rm -f core core.* *.core])
1370
if test $ac_cv_func_utime_null = yes; then
1371
AC_DEFINE(HAVE_UTIME_NULL, 1,
1372
[Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1376
])# AC_FUNC_UTIME_NULL
1381
AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1386
AC_DEFUN([AC_FUNC_FORK],
1387
[AC_REQUIRE([AC_TYPE_PID_T])dnl
1388
AC_CHECK_HEADERS(unistd.h vfork.h)
1389
AC_CHECK_FUNCS(fork vfork)
1390
ac_cv_func_fork_works=$ac_cv_func_fork
1391
if test "x$ac_cv_func_fork" = xyes; then
1394
if test "x$ac_cv_func_fork_works" = xcross; then
1396
*-*-amigaos* | *-*-msdosdjgpp*)
1397
# Override, as these systems have only a dummy fork() stub
1398
ac_cv_func_fork_works=no
1401
ac_cv_func_fork_works=yes
1404
AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1406
ac_cv_func_vfork_works=$ac_cv_func_vfork
1407
if test "x$ac_cv_func_vfork" = xyes; then
1410
if test "x$ac_cv_func_fork_works" = xcross; then
1411
ac_cv_func_vfork_works=ac_cv_func_vfork
1412
AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1415
if test "x$ac_cv_func_vfork_works" = xyes; then
1416
AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1418
AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1420
if test "x$ac_cv_func_fork_works" = xyes; then
1421
AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1428
AC_DEFUN([_AC_FUNC_FORK],
1429
[AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1430
[AC_RUN_IFELSE([/* By Ruediger Kuhlmann. */
1431
#include <sys/types.h>
1433
# include <unistd.h>
1435
/* Some systems only have a dummy stub for fork() */
1442
[ac_cv_func_fork_works=yes],
1443
[ac_cv_func_fork_works=no],
1444
[ac_cv_func_fork_works=cross])])]
1450
AC_DEFUN([_AC_FUNC_VFORK],
1451
[AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1452
[AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */
1454
#include <sys/types.h>
1455
#include <sys/stat.h>
1457
# include <unistd.h>
1462
/* On some sparc systems, changes by the child to local and incoming
1463
argument registers are propagated back to the parent. The compiler
1464
is told about this with #include <vfork.h>, but some compilers
1465
(e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1466
static variable whose address is put into a register that is
1467
clobbered by the vfork. */
1470
sparc_address_test (int arg)
1472
sparc_address_test (arg) int arg;
1493
pid_t parent = getpid ();
1496
sparc_address_test ();
1501
/* Here is another test for sparc vfork register problems. This
1502
test uses lots of local variables, at least as many local
1503
variables as main has allocated so far including compiler
1504
temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1505
4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1506
reuse the register of parent for one of the local variables,
1507
since it will think that parent can't possibly be used any more
1508
in this routine. Assigning to the local variable will thus
1509
munge parent in the parent process. */
1511
p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1512
p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1513
/* Convince the compiler that p..p7 are live; otherwise, it might
1514
use the same hardware register for all 8 local variables. */
1515
if (p != p1 || p != p2 || p != p3 || p != p4
1516
|| p != p5 || p != p6 || p != p7)
1519
/* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1520
from child file descriptors. If the child closes a descriptor
1521
before it execs or exits, this munges the parent's descriptor
1522
as well. Test for this by closing stdout in the child. */
1523
_exit(close(fileno(stdout)) != 0);
1528
while (wait(&status) != child)
1531
/* Was there some problem with vforking? */
1534
/* Did the child fail? (This shouldn't happen.) */
1537
/* Did the vfork/compiler bug occur? */
1538
|| parent != getpid()
1540
/* Did the file descriptor bug occur? */
1541
|| fstat(fileno(stdout), &st) != 0
1545
[ac_cv_func_vfork_works=yes],
1546
[ac_cv_func_vfork_works=no],
1547
[ac_cv_func_vfork_works=cross])])
1553
AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1557
AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1562
# Why the heck is that _doprnt does not define HAVE__DOPRNT???
1563
# That the logical name!
1564
AC_DEFUN([AC_FUNC_VPRINTF],
1565
[AC_CHECK_FUNCS(vprintf, []
1566
[AC_CHECK_FUNC(_doprnt,
1567
[AC_DEFINE(HAVE_DOPRNT, 1,
1568
[Define to 1 if you don't have `vprintf' but do have
1575
AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1580
# Don't bother too hard maintaining this macro, as it's obsoleted.
1581
# We don't AU define it, since we don't have any alternative to propose,
1582
# any invocation should be removed, and the code adjusted.
1583
AC_DEFUN([AC_FUNC_WAIT3],
1584
[AC_DIAGNOSE([obsolete],
1585
[$0: `wait3' is being removed from the Open Group standards.
1586
Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1587
AC_CACHE_CHECK([for wait3 that fills in rusage],
1588
[ac_cv_func_wait3_rusage],
1589
[AC_RUN_IFELSE([AC_LANG_SOURCE(
1590
[[#include <sys/types.h>
1591
#include <sys/time.h>
1592
#include <sys/resource.h>
1594
/* HP-UX has wait3 but does not fill in rusage at all. */
1600
/* Use a field that we can force nonzero --
1601
voluntary context switches.
1602
For systems like NeXT and OSF/1 that don't set it,
1603
also use the system CPU time. And page faults (I/O) for Linux. */
1605
r.ru_stime.tv_sec = 0;
1606
r.ru_stime.tv_usec = 0;
1607
r.ru_majflt = r.ru_minflt = 0;
1610
case 0: /* Child. */
1611
sleep(1); /* Give up the CPU. */
1614
case -1: /* What can we do? */
1617
default: /* Parent. */
1619
/* Avoid "text file busy" from rm on fast HP-UX machines. */
1621
exit (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1622
&& r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1625
[ac_cv_func_wait3_rusage=yes],
1626
[ac_cv_func_wait3_rusage=no],
1627
[ac_cv_func_wait3_rusage=no])])
1628
if test $ac_cv_func_wait3_rusage = yes; then
1629
AC_DEFINE(HAVE_WAIT3, 1,
1630
[Define to 1 if you have the `wait3' system call.
1631
Deprecated, you should no longer depend upon `wait3'.])
1638
AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])