📄 functions.m4
字号:
# else /* no EXEC_PAGESIZE */# ifdef NBPG# define getpagesize() NBPG * CLSIZE# ifndef CLSIZE# define CLSIZE 1# endif /* no CLSIZE */# else /* no NBPG */# ifdef NBPC# define getpagesize() NBPC# else /* no NBPC */# ifdef PAGESIZE# define getpagesize() PAGESIZE# endif /* PAGESIZE */# endif /* no NBPC */# endif /* no NBPG */# endif /* no EXEC_PAGESIZE */# else /* no HAVE_SYS_PARAM_H */# define getpagesize() 8192 /* punt totally */# endif /* no HAVE_SYS_PARAM_H */# endif /* no _SC_PAGESIZE */#endif /* no HAVE_GETPAGESIZE */intmain (){ char *data, *data2, *data3; int i, pagesize; int fd; pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ data = (char *) malloc (pagesize); if (!data) return 1; for (i = 0; i < pagesize; ++i) *(data + i) = rand (); umask (0); fd = creat ("conftest.mmap", 0600); if (fd < 0) return 1; if (write (fd, data, pagesize) != pagesize) return 1; close (fd); /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that we see the same garbage. */ fd = open ("conftest.mmap", O_RDWR); if (fd < 0) return 1; data2 = (char *) malloc (2 * pagesize); if (!data2) return 1; data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data2 + i)) return 1; /* Finally, make sure that changes to the mapped area do not percolate back to the file as seen by read(). (This is a bug on some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; data3 = (char *) malloc (pagesize); if (!data3) return 1; if (read (fd, data3, pagesize) != pagesize) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data3 + i)) return 1; close (fd); return 0;}]])], [ac_cv_func_mmap_fixed_mapped=yes], [ac_cv_func_mmap_fixed_mapped=no], [ac_cv_func_mmap_fixed_mapped=no])])if test $ac_cv_func_mmap_fixed_mapped = yes; then AC_DEFINE(HAVE_MMAP, 1, [Define to 1 if you have a working `mmap' system call.])firm -f conftest.mmap])# AC_FUNC_MMAP# AU::AC_MMAP# -----------AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])# AC_FUNC_OBSTACK# ---------------# Ensure obstack support. Yeah, this is not exactly a `FUNC' check.AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])AC_DEFUN([AC_FUNC_OBSTACK],[AC_LIBSOURCES([obstack.h, obstack.c])dnlAC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,[AC_LINK_IFELSE( [AC_LANG_PROGRAM([[@%:@include "obstack.h"]], [[struct obstack *mem; obstack_free(mem,(char *) 0)]])], [ac_cv_func_obstack=yes], [ac_cv_func_obstack=no])])if test $ac_cv_func_obstack = yes; then AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])else AC_LIBOBJ(obstack)fi])# AC_FUNC_OBSTACK# AU::AM_FUNC_OBSTACK# -------------------AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)# -------------------------------------# If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.AC_DEFUN([_AC_FUNC_REALLOC_IF],[AC_REQUIRE([AC_HEADER_STDC])dnlAC_CHECK_HEADERS(stdlib.h)AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,[AC_RUN_IFELSE([AC_LANG_PROGRAM([[#if STDC_HEADERS || HAVE_STDLIB_H# include <stdlib.h>#elsechar *realloc ();#endif]], [return ! realloc (0, 0);])], [ac_cv_func_realloc_0_nonnull=yes], [ac_cv_func_realloc_0_nonnull=no], [ac_cv_func_realloc_0_nonnull=no])])AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])])# AC_FUNC_REALLOC# AC_FUNC_REALLOC# ---------------# Report whether `realloc (0, 0)' is properly handled, and replace realloc if# needed.AN_FUNCTION([realloc], [AC_FUNC_REALLOC])AC_DEFUN([AC_FUNC_REALLOC],[_AC_FUNC_REALLOC_IF( [AC_DEFINE([HAVE_REALLOC], 1, [Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise.])], [AC_DEFINE([HAVE_REALLOC], 0) AC_LIBOBJ([realloc]) AC_DEFINE([realloc], [rpl_realloc], [Define to rpl_realloc if the replacement function should be used.])])])# AC_FUNC_REALLOC# AC_FUNC_SELECT_ARGTYPES# -----------------------# Determine the correct type to be passed to each of the `select'# function's arguments, and define those types in `SELECT_TYPE_ARG1',# `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.AN_FUNCTION([select], [AC_FUNC_SELECT_ARGTYPES])AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],[AC_CHECK_HEADERS(sys/select.h sys/socket.h)AC_CACHE_CHECK([types of arguments for select],[ac_cv_func_select_args],[for ac_arg234 in 'fd_set *' 'int *' 'void *'; do for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT#if HAVE_SYS_SELECT_H# include <sys/select.h>#endif#if HAVE_SYS_SOCKET_H# include <sys/socket.h>#endif], [extern int select ($ac_arg1, $ac_arg234, $ac_arg234, $ac_arg234, $ac_arg5);])], [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3]) done donedone# Provide a safe default value.: ${ac_cv_func_select_args='int,int *,struct timeval *'}])ac_save_IFS=$IFS; IFS=','set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`IFS=$ac_save_IFSshiftAC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1], [Define to the type of arg 1 for `select'.])AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]), [Define to the type of args 2, 3 and 4 for `select'.])AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]), [Define to the type of arg 5 for `select'.])rm -f conftest*])# AC_FUNC_SELECT_ARGTYPES# AC_FUNC_SETPGRP# ---------------AN_FUNCTION([setpgrp], [AC_FUNC_SETPGRP])AC_DEFUN([AC_FUNC_SETPGRP],[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[/* If this system has a BSD-style setpgrp which takes arguments, setpgrp(1, 1) will fail with ESRCH and return -1, in that case exit successfully. */ return setpgrp (1,1) != -1;])], [ac_cv_func_setpgrp_void=no], [ac_cv_func_setpgrp_void=yes], [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])if test $ac_cv_func_setpgrp_void = yes; then AC_DEFINE(SETPGRP_VOID, 1, [Define to 1 if the `setpgrp' function takes no argument.])fi])# AC_FUNC_SETPGRP# _AC_FUNC_STAT(STAT | LSTAT)# ---------------------------# Determine whether stat or lstat have the bug that it succeeds when# given the zero-length file name argument. The stat and lstat from# SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.## If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or# HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper# function.m4_define([_AC_FUNC_STAT],[AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnlAC_CACHE_CHECK([whether $1 accepts an empty string], [ac_cv_func_$1_empty_string_bug],[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[struct stat sbuf; return $1 ("", &sbuf) == 0;]])], [ac_cv_func_$1_empty_string_bug=no], [ac_cv_func_$1_empty_string_bug=yes], [ac_cv_func_$1_empty_string_bug=yes])])if test $ac_cv_func_$1_empty_string_bug = yes; then AC_LIBOBJ([$1]) AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1, [Define to 1 if `$1' has the bug that it succeeds when given the zero-length file name argument.])fi])# _AC_FUNC_STAT# AC_FUNC_STAT & AC_FUNC_LSTAT# ----------------------------AN_FUNCTION([stat], [AC_FUNC_STAT])AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])AN_FUNCTION([lstat], [AC_FUNC_LSTAT])AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])# _AC_LIBOBJ_STRTOD# -----------------m4_define([_AC_LIBOBJ_STRTOD],[AC_LIBOBJ(strtod)AC_CHECK_FUNC(pow)if test $ac_cv_func_pow = no; then AC_CHECK_LIB(m, pow, [POW_LIB=-lm], [AC_MSG_WARN([cannot find library containing definition of pow])])fi])# _AC_LIBOBJ_STRTOD# AC_FUNC_STRTOD# --------------AN_FUNCTION([strtod], [AC_FUNC_STRTOD])AC_DEFUN([AC_FUNC_STRTOD],[AC_SUBST(POW_LIB)dnlAC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,[AC_RUN_IFELSE([AC_LANG_SOURCE([[]AC_INCLUDES_DEFAULT[#ifndef strtoddouble strtod ();#endifintmain(){ { /* Some versions of Linux strtod mis-parse strings with leading '+'. */ char *string = " +69"; char *term; double value; value = strtod (string, &term); if (value != 69 || term != (string + 4)) return 1; } { /* Under Solaris 2.4, strtod returns the wrong value for the terminating character under some conditions. */ char *string = "NaN"; char *term; strtod (string, &term); if (term != string && *(term - 1) == 0) return 1; } return 0;}]])], ac_cv_func_strtod=yes, ac_cv_func_strtod=no, ac_cv_func_strtod=no)])if test $ac_cv_func_strtod = no; then _AC_LIBOBJ_STRTODfi])# AC_FUNC_STRTOLD# ---------------AC_DEFUN([AC_FUNC_STRTOLD],[ AC_CACHE_CHECK([whether strtold conforms to C99], [ac_cv_func_strtold], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[/* On HP-UX before 11.23, strtold returns a struct instead of long double. Reject implementations like that, by requiring compatibility with the C99 prototype. */# include <stdlib.h> static long double (*p) (char const *, char **) = strtold; static long double test (char const *nptr, char **endptr) { long double r; r = strtold (nptr, endptr); return r; }]], [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])], [ac_cv_func_strtold=yes], [ac_cv_func_strtold=no])]) if test $ac_cv_func_strtold = yes; then AC_DEFINE([HAVE_STRTOLD], 1, [Define to 1 if strtold exists and conforms to C99.]) fi])# AC_FUNC_STRTOLD# AU::AM_FUNC_STRTOD# ------------------AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])# AC_FUNC_STRERROR_R# ------------------AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])AC_DEFUN([AC_FUNC_STRERROR_R],[AC_CHECK_DECLS([strerror_r])AC_CHECK_FUNCS([strerror_r])AC_CACHE_CHECK([whether strerror_r returns char *], ac_cv_func_strerror_r_char_p, [ ac_cv_func_strerror_r_char_p=no if test $ac_cv_have_decl_strerror_r = yes; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ char buf[100]; char x = *strerror_r (0, buf, sizeof buf); char *p = strerror_r (0, buf, sizeof buf); return !p || x; ]])], ac_cv_func_strerror_r_char_p=yes) else # strerror_r is not declared. Choose between # systems that have relatively inaccessible declarations for the # function. BeOS and DEC UNIX 4.0 fall in this category, but the # former has a strerror_r that returns char*, while the latter # has a strerror_r that returns `int'. # This test should segfault on the DEC system. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT extern char *strerror_r ();], [[char buf[100]; char x = *strerror_r (0, buf, sizeof buf); return ! isalpha (x);]])], ac_cv_func_strerror_r_char_p=yes, , :) fi ])if test $ac_cv_func_strerror_r_char_p = yes; then AC_DEFINE([STRERROR_R_CHAR_P], 1, [Define to 1 if strerror_r returns char *.])fi])# AC_FUNC_STRERROR_R# AC_FUNC_STRFTIME# ----------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -