📄 functions.m4
字号:
AC_CHECK_FUNCS(getmntent)])# AC_FUNC_GETPGRP# ---------------# Figure out whether getpgrp requires zero arguments.AN_FUNCTION([getpgrp], [AC_FUNC_GETPGRP])AC_DEFUN([AC_FUNC_GETPGRP],[AC_CACHE_CHECK(whether getpgrp requires zero arguments, ac_cv_func_getpgrp_void,[# Use it with a single arg.AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])], [ac_cv_func_getpgrp_void=no], [ac_cv_func_getpgrp_void=yes])])if test $ac_cv_func_getpgrp_void = yes; then AC_DEFINE(GETPGRP_VOID, 1, [Define to 1 if the `getpgrp' function requires zero arguments.])fi])# AC_FUNC_GETPGRP# AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK# -------------------------------------# When cross-compiling, be pessimistic so we will end up using the# replacement version of lstat that checks for trailing slashes and# calls lstat a second time when necessary.AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],[AC_CACHE_CHECK( [whether lstat dereferences a symlink specified with a trailing slash], [ac_cv_func_lstat_dereferences_slashed_symlink],[rm -f conftest.sym conftest.fileecho >conftest.fileif test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [struct stat sbuf; /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0;])], [ac_cv_func_lstat_dereferences_slashed_symlink=yes], [ac_cv_func_lstat_dereferences_slashed_symlink=no], [ac_cv_func_lstat_dereferences_slashed_symlink=no])else # If the `ln -s' command failed, then we probably don't even # have an lstat function. ac_cv_func_lstat_dereferences_slashed_symlink=nofirm -f conftest.sym conftest.file])test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1, [Define to 1 if `lstat' dereferences a symlink specified with a trailing slash.])if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then AC_LIBOBJ(lstat)fi])# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)# ------------------------------------# If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.AC_DEFUN([_AC_FUNC_MALLOC_IF],[AC_REQUIRE([AC_HEADER_STDC])dnlAC_CHECK_HEADERS(stdlib.h)AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,[AC_RUN_IFELSE([AC_LANG_PROGRAM([[#if STDC_HEADERS || HAVE_STDLIB_H# include <stdlib.h>#elsechar *malloc ();#endif]], [return ! malloc (0);])], [ac_cv_func_malloc_0_nonnull=yes], [ac_cv_func_malloc_0_nonnull=no], [ac_cv_func_malloc_0_nonnull=no])])AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])])# AC_FUNC_MALLOC# AC_FUNC_MALLOC# --------------# Report whether `malloc (0)' properly handled, and replace malloc if# needed.AN_FUNCTION([malloc], [AC_FUNC_MALLOC])AC_DEFUN([AC_FUNC_MALLOC],[_AC_FUNC_MALLOC_IF( [AC_DEFINE([HAVE_MALLOC], 1, [Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise.])], [AC_DEFINE([HAVE_MALLOC], 0) AC_LIBOBJ(malloc) AC_DEFINE([malloc], [rpl_malloc], [Define to rpl_malloc if the replacement function should be used.])])])# AC_FUNC_MALLOC# AC_FUNC_MBRTOWC# ---------------AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])AC_DEFUN([AC_FUNC_MBRTOWC],[ AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], ac_cv_func_mbrtowc, [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[@%:@include <wchar.h>]], [[wchar_t wc; char const s[] = ""; size_t n = 1; mbstate_t state; return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], ac_cv_func_mbrtowc=yes, ac_cv_func_mbrtowc=no)]) if test $ac_cv_func_mbrtowc = yes; then AC_DEFINE([HAVE_MBRTOWC], 1, [Define to 1 if mbrtowc and mbstate_t are properly declared.]) fi])# AC_FUNC_MEMCMP# --------------AN_FUNCTION([memcmp], [AC_FUNC_MEMCMP])AC_DEFUN([AC_FUNC_MEMCMP],[AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ /* Some versions of memcmp are not 8-bit clean. */ char c0 = '\100', c1 = '\200', c2 = '\201'; if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) return 1; /* The Next x86 OpenStep bug shows up only when comparing 16 bytes or more and with at least one buffer not starting on a 4-byte boundary. William Lewis provided this test program. */ { char foo[21]; char bar[21]; int i; for (i = 0; i < 4; i++) { char *a = foo + i; char *b = bar + i; strcpy (a, "--------01111111"); strcpy (b, "--------10000000"); if (memcmp (a, b, 16) >= 0) return 1; } return 0; }]])], [ac_cv_func_memcmp_working=yes], [ac_cv_func_memcmp_working=no], [ac_cv_func_memcmp_working=no])])test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])])# AC_FUNC_MEMCMP# AC_FUNC_MKTIME# --------------AN_FUNCTION([mktime], [AC_FUNC_MKTIME])AC_DEFUN([AC_FUNC_MKTIME],[AC_REQUIRE([AC_HEADER_TIME])dnlAC_CHECK_HEADERS(stdlib.h sys/time.h unistd.h)AC_CHECK_FUNCS(alarm)AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,[AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Test program from Paul Eggert and Tony Leneis. */#if TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h>#else# if HAVE_SYS_TIME_H# include <sys/time.h># else# include <time.h># endif#endif#if HAVE_STDLIB_H# include <stdlib.h>#endif#if HAVE_UNISTD_H# include <unistd.h>#endif#if !HAVE_ALARM# define alarm(X) /* empty */#endif/* Work around redefinition to rpl_putenv by other config tests. */#undef putenvstatic time_t time_t_max;static time_t time_t_min;/* Values we'll use to set the TZ environment variable. */static char *tz_strings[] = { (char *) 0, "TZ=GMT0", "TZ=JST-9", "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"};#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))/* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */static intspring_forward_gap (){ /* glibc (up to about 1998-10-07) failed this test. */ struct tm tm; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); tm.tm_year = 98; tm.tm_mon = 3; tm.tm_mday = 5; tm.tm_hour = 2; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm) != (time_t) -1;}static intmktime_test1 (now) time_t now;{ struct tm *lt; return ! (lt = localtime (&now)) || mktime (lt) == now;}static intmktime_test (now) time_t now;{ return (mktime_test1 (now) && mktime_test1 ((time_t) (time_t_max - now)) && mktime_test1 ((time_t) (time_t_min + now)));}static intirix_6_4_bug (){ /* Based on code from Ariel Faigon. */ struct tm tm; tm.tm_year = 96; tm.tm_mon = 3; tm.tm_mday = 0; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; mktime (&tm); return tm.tm_mon == 2 && tm.tm_mday == 31;}static intbigtime_test (j) int j;{ struct tm tm; time_t now; tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; now = mktime (&tm); if (now != (time_t) -1) { struct tm *lt = localtime (&now); if (! (lt && lt->tm_year == tm.tm_year && lt->tm_mon == tm.tm_mon && lt->tm_mday == tm.tm_mday && lt->tm_hour == tm.tm_hour && lt->tm_min == tm.tm_min && lt->tm_sec == tm.tm_sec && lt->tm_yday == tm.tm_yday && lt->tm_wday == tm.tm_wday && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) return 0; } return 1;}intmain (){ time_t t, delta; int i, j; /* This test makes some buggy mktime implementations loop. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ alarm (60); for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) continue; time_t_max--; if ((time_t) -1 < 0) for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2) continue; delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { if (tz_strings[i]) putenv (tz_strings[i]); for (t = 0; t <= time_t_max - delta; t += delta) if (! mktime_test (t)) return 1; if (! (mktime_test ((time_t) 1) && mktime_test ((time_t) (60 * 60)) && mktime_test ((time_t) (60 * 60 * 24)))) return 1; for (j = 1; 0 < j; j *= 2) if (! bigtime_test (j)) return 1; if (! bigtime_test (j - 1)) return 1; } return ! (irix_6_4_bug () && spring_forward_gap ());}]])], [ac_cv_func_working_mktime=yes], [ac_cv_func_working_mktime=no], [ac_cv_func_working_mktime=no])])if test $ac_cv_func_working_mktime = no; then AC_LIBOBJ([mktime])fi])# AC_FUNC_MKTIME# AU::AM_FUNC_MKTIME# ------------------AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])# AC_FUNC_MMAP# ------------AN_FUNCTION([mmap], [AC_FUNC_MMAP])AC_DEFUN([AC_FUNC_MMAP],[AC_CHECK_HEADERS(stdlib.h unistd.h)AC_CHECK_FUNCS(getpagesize)AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,[AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT][[/* malloc might have been renamed as rpl_malloc. */#undef malloc/* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: mmap private not fixed mmap private fixed at somewhere currently unmapped mmap private fixed at somewhere already mapped mmap shared not fixed mmap shared fixed at somewhere currently unmapped mmap shared fixed at somewhere already mapped For private mappings, we should verify that changes cannot be read() back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get propagated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */#include <fcntl.h>#include <sys/mman.h>#if !STDC_HEADERS && !HAVE_STDLIB_Hchar *malloc ();#endif/* This mess was copied from the GNU getpagesize.h. */#if !HAVE_GETPAGESIZE/* Assume that all systems that can run configure have sys/param.h. */# if !HAVE_SYS_PARAM_H# define HAVE_SYS_PARAM_H 1# endif# ifdef _SC_PAGESIZE# define getpagesize() sysconf(_SC_PAGESIZE)# else /* no _SC_PAGESIZE */# if HAVE_SYS_PARAM_H# include <sys/param.h># ifdef EXEC_PAGESIZE# define getpagesize() EXEC_PAGESIZE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -