From 27e96877b716456a32e43cd20c5745080fc9143d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 27 Jul 2010 14:37:25 +0000 Subject: [PATCH] 2010-07-27 Tatsuhiro Tsujikawa Rewritten check for fallocate using AC_COMPILE_IFELSE. * configure.ac * m4/fallocate.m4 --- ChangeLog | 6 ++++++ Makefile.in | 10 +++++----- aclocal.m4 | 1 + configure | 37 +++++++++++++++++++++++++++++-------- configure.ac | 2 +- doc/Makefile.in | 10 +++++----- lib/Makefile.in | 10 +++++----- m4/fallocate.m4 | 17 +++++++++++++++++ src/Makefile.in | 10 +++++----- test/Makefile.in | 10 +++++----- 10 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 m4/fallocate.m4 diff --git a/ChangeLog b/ChangeLog index 4e561b3239..5fc856febf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-07-27 Tatsuhiro Tsujikawa + + Rewritten check for fallocate using AC_COMPILE_IFELSE. + * configure.ac + * m4/fallocate.m4 + 2010-07-26 Tatsuhiro Tsujikawa Fixed the bug that HAVE_SOME_FALLOCATE gets undefined if fallocate diff --git a/Makefile.in b/Makefile.in index b061b75a83..9598dbd5ec 100644 --- a/Makefile.in +++ b/Makefile.in @@ -46,11 +46,11 @@ DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aria2_arg.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/cppunit.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/fallocate.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcares.m4 \ diff --git a/aclocal.m4 b/aclocal.m4 index 54cd7316f3..a3bd0821a5 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -952,6 +952,7 @@ AC_SUBST([am__untar]) m4_include([m4/aria2_arg.m4]) m4_include([m4/codeset.m4]) m4_include([m4/cppunit.m4]) +m4_include([m4/fallocate.m4]) m4_include([m4/gettext.m4]) m4_include([m4/glibc2.m4]) m4_include([m4/glibc21.m4]) diff --git a/configure b/configure index 5a1d1905b8..847013d549 100755 --- a/configure +++ b/configure @@ -14793,16 +14793,37 @@ _ACEOF fi done -for ac_func in fallocate -do : - ac_fn_cxx_check_func "$LINENO" "fallocate" "ac_cv_func_fallocate" -if test "x$ac_cv_func_fallocate" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FALLOCATE 1 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fallocate" >&5 +$as_echo_n "checking for fallocate... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + +fallocate(2, 0, 0, 4096); + + ; + return 0; +} _ACEOF - have_fallocate=yes +if ac_fn_cxx_try_compile "$LINENO"; then : + have_fallocate=yes +else + have_fallocate=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_fallocate" >&5 +$as_echo "$have_fallocate" >&6; } +if test "x$have_fallocate" = "xyes"; then + +$as_echo "#define HAVE_FALLOCATE 1" >>confdefs.h + fi -done if test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes"; then diff --git a/configure.ac b/configure.ac index 0176547c53..0a4f8875a5 100644 --- a/configure.ac +++ b/configure.ac @@ -356,7 +356,7 @@ fi AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"]) AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes]) -AC_CHECK_FUNCS([fallocate], [have_fallocate=yes]) +ARIA2_CHECK_FALLOCATE if test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes"; then AC_DEFINE([HAVE_SOME_FALLOCATE], [1], diff --git a/doc/Makefile.in b/doc/Makefile.in index 7ff33b3b69..cca59fa082 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -41,11 +41,11 @@ DIST_COMMON = $(dist_doc_DATA) $(dist_doc_xmlrpc_DATA) \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aria2_arg.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/cppunit.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/fallocate.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcares.m4 \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 87d1403937..72d3b97488 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -39,11 +39,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aria2_arg.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/cppunit.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/fallocate.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcares.m4 \ diff --git a/m4/fallocate.m4 b/m4/fallocate.m4 new file mode 100644 index 0000000000..cf9fc83245 --- /dev/null +++ b/m4/fallocate.m4 @@ -0,0 +1,17 @@ +AC_DEFUN([ARIA2_CHECK_FALLOCATE], +[ +AC_MSG_CHECKING([for fallocate]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], +[[ +fallocate(2, 0, 0, 4096); +]])], +[have_fallocate=yes], +[have_fallocate=no]) +AC_MSG_RESULT([$have_fallocate]) +if test "x$have_fallocate" = "xyes"; then + AC_DEFINE([HAVE_FALLOCATE], [1], + [Define to 1 if you have the `fallocate' function.]) +fi +]) diff --git a/src/Makefile.in b/src/Makefile.in index 358315be90..d38f665967 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -289,11 +289,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aria2_arg.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/cppunit.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/fallocate.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcares.m4 \ diff --git a/test/Makefile.in b/test/Makefile.in index a3f4051090..c81a278eb6 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -157,11 +157,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aria2_arg.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/cppunit.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/fallocate.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcares.m4 \