configure.ac | 60 ++++++++++++++++++++------------------------------ m4/ac_check_symbol.m4 | 48 ++++++++++++++++++++++++++++++++++++++++ src/fccache.c | 2 - 3 files changed, 74 insertions(+), 36 deletions(-) New commits: commit d97fbbe9f59965167fbc0bdc49f983c2bc96d521 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Mon Dec 2 19:18:25 2013 +0900 Simplify to validate the availability of scandir diff --git a/configure.ac b/configure.ac index fed8b2a..1a1b534 100644 --- a/configure.ac +++ b/configure.ac @@ -154,38 +154,36 @@ 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" if test "$os_win32" = "no"; then AC_MSG_CHECKING([for scandir]) - AC_LINK_IFELSE([AC_LANG_SOURCE([[ + fc_saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $WARN_CFLAGS -Werror" + AC_TRY_COMPILE([ #include <dirent.h> - int comp(const struct dirent **, const struct dirent **); - int comp(const struct dirent **a, const struct dirent **b) { return 0; } - int main(void) { - struct dirent **d; - return scandir(".", &d, 0, &comp) >= 0; - } - ]])],[ + int main(void); + ], [ + int (* comp) (const struct dirent **, const struct dirent **) = 0; + struct dirent **d; + return scandir(".", &d, 0, comp) >= 0; + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.]) + ], [ + AC_TRY_COMPILE([ + #include <dirent.h> + int main(void); + ], [ + int (* comp) (const void *, const void *) = 0; + struct dirent **d; + return scandir(".", &d, 0, comp) >= 0; + ], [ AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.]) + AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)]) ],[ - AC_LINK_IFELSE([AC_LANG_SOURCE([[ - #include <dirent.h> - int comp(const void *, const void *); - int comp(const void *a, const void *b) { return 0; } - int main(void) { - struct dirent **d; - return scandir(".", &d, 0, &comp) >= 0; - } - ]])],[ - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)]) - ],[ - AC_MSG_ERROR([ + AC_MSG_ERROR([ *** No scandir function available.]) - ]) ]) + ]) fi CFLAGS="$fc_saved_CFLAGS" commit 51521153490ab0b01959c10c57e476de3ad27acb Author: Akira TAGOH <akira@xxxxxxxxx> Date: Mon Dec 2 18:43:10 2013 +0900 Simplify to validate the availability of posix_fadvise 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@xxxxxx> +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) _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig