summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac12
-rw-r--r--m4/ac_check_symbol.m448
-rw-r--r--src/fccache.c2
3 files changed, 51 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index 4478914..fed8b2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,18 +152,10 @@ AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getpr
dnl AC_CHECK_FUNCS doesn't check for header files.
dnl posix_fadvise() may be not available in older libc.
+AC_CHECK_SYMBOL([posix_fadvise], [fcntl.h], [fc_func_posix_fadvise=1], [fc_func_posix_fadvise=0])
+AC_DEFINE_UNQUOTED([HAVE_POSIX_FADVISE], [$fc_func_posix_fadvise], [Define to 1 if you have the 'posix_fadivse' function.])
fc_saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $WARN_CFLAGS -Werror"
-AC_MSG_CHECKING([for posix_fadvise])
-AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <fcntl.h>
- int main(void) {
- return posix_fadvise(0, 0, 0, 0);
- }
- ]])],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_POSIX_FADVISE], [1], [Define to 1 if you have the 'posix_fadvise' function.])
- ],[AC_MSG_RESULT([no])])
if test "$os_win32" = "no"; then
AC_MSG_CHECKING([for scandir])
AC_LINK_IFELSE([AC_LANG_SOURCE([[
diff --git a/m4/ac_check_symbol.m4 b/m4/ac_check_symbol.m4
new file mode 100644
index 0000000..41c1528
--- /dev/null
+++ b/m4/ac_check_symbol.m4
@@ -0,0 +1,48 @@
+dnl @synopsis AC_CHECK_SYMBOL(SYMBOL, HEADER... [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
+dnl
+dnl a wrapper around AC_EGREP_HEADER the shellvar $ac_found will hold
+dnl the HEADER-name that had been containing the symbol. This value is
+dnl shown to the user.
+dnl
+dnl @category C
+dnl @author Guido U. Draheim <guidod@gmx.de>
+dnl @version 2006-10-13
+dnl @license GPLWithACException
+
+AC_DEFUN([AC_CHECK_SYMBOL],
+[AC_MSG_CHECKING([for $1 in $2])
+AC_CACHE_VAL(ac_cv_func_$1,
+[AC_REQUIRE_CPP()dnl
+changequote(, )dnl
+symbol="[^a-zA-Z_0-9]$1[^a-zA-Z_0-9]"
+changequote([, ])dnl
+ac_found=no
+for ac_header in $2 ; do
+ ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%' `
+ if test $ac_found != "yes" ; then
+ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ AC_EGREP_HEADER( $symbol, $ac_header, [ac_found="$ac_header"] )
+ fi
+ fi
+done
+if test "$ac_found" != "no" ; then
+ AC_MSG_RESULT($ac_found)
+ ifelse([$3], , :, [$3])
+else
+ AC_MSG_RESULT(no)
+ ifelse([$4], , , [$4
+])dnl
+fi
+])])
+
+dnl AC_CHECK_SYMBOLS( symbol..., header... [, action-if-found [, action-if-not-found]])
+AC_DEFUN([AC_CHECK_SYMBOLS],
+[for ac_func in $1
+do
+P4_CHECK_SYMBOL($ac_func, $2,
+[changequote(, )dnl
+ ac_tr_func=HAVE_`echo $ac_func | sed -e 'y:abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:' -e 's:[[^A-Z0-9]]:_:'`
+changequote([, ])dnl
+ AC_DEFINE_UNQUOTED($ac_tr_func) $2], $3)dnl
+done
+])
diff --git a/src/fccache.c b/src/fccache.c
index c7f2437..10eacff 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -573,7 +573,7 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
{
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0);
-#if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
+#if (HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
posix_fadvise (fd, 0, fd_stat->st_size, POSIX_FADV_WILLNEED);
#endif
if (cache == MAP_FAILED)