null+****@clear*****
null+****@clear*****
2011年 12月 26日 (月) 15:50:06 JST
Kouhei Sutou 2011-12-26 15:50:06 +0900 (Mon, 26 Dec 2011) New Revision: a20b5ec2f474b468f498837771d3654705ef487d Log: add --enable-map-hugetlb option. Modified files: configure.ac lib/dat/Makefile.am lib/dat/file-impl.cpp Modified: configure.ac (+28 -0) =================================================================== --- configure.ac 2011-12-26 14:21:31 +0900 (a70e3c1) +++ configure.ac 2011-12-26 15:50:06 +0900 (1dca1a1) @@ -314,6 +314,34 @@ AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_CHECK_SIZEOF(off_t) +# MAP_HUGETLB +AC_ARG_ENABLE(map-hugetlb, + [AS_HELP_STRING([--enable-map-hugetlb], + [use MAP_HUGETLB. [default=no]])], + , + [enable_map_hugetlb="no"]) +if test "x$enable_map_hugetlb" != "xno"; then + AC_MSG_CHECKING([for MAP_HUGETLB]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [ +#ifdef HAVE_SYS_MMAN_H +# include <sys/mman.h> +#endif /* HAVE_SYS_MMAN_H */ + ], + [MAP_HUGETLB;] + )], + [ + AC_DEFINE(GROONGA_USE_MAP_HUGETLB, [1], [use MAP_HUGETLB]) + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + AC_MSG_ERROR("MAP_HUGETLB isn't available.") + ] + ) +fi + # log path AC_ARG_WITH(log_path, [AS_HELP_STRING([--with-log-path=PATH], Modified: lib/dat/Makefile.am (+5 -0) =================================================================== --- lib/dat/Makefile.am 2011-12-26 14:21:31 +0900 (fc1b975) +++ lib/dat/Makefile.am 2011-12-26 15:50:06 +0900 (66bb5e5) @@ -1,5 +1,10 @@ DEFS += -D_REENTRANT $(GRN_DEFS) +DEFAULT_INCLUDES = \ + -I$(top_builddir) \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/lib + noinst_LTLIBRARIES = libgrndat.la libgrndat_la_SOURCES = \ Modified: lib/dat/file-impl.cpp (+4 -2) =================================================================== --- lib/dat/file-impl.cpp 2011-12-26 14:21:31 +0900 (29a1bfc) +++ lib/dat/file-impl.cpp 2011-12-26 15:50:06 +0900 (b46a2f7) @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <groonga_in.h> + #include "file-impl.hpp" #include <sys/types.h> @@ -201,10 +203,10 @@ void FileImpl::create_(const char *path, UInt64 size) { #endif // MAP_ANONYMOUS length_ = static_cast< ::size_t>(size); -#if defined(GROONGA_USE_MAP_HUGETLB) && defined(MAP_HUGETLB) +#ifdef GROONGA_USE_MAP_HUGETLB addr_ = ::mmap(NULL, length_, PROT_READ | PROT_WRITE, flags | MAP_HUGETLB, fd_, 0); -#endif // defined(GROONGA_USE_MAP_HUGETLB) && defined(MAP_HUGETLB) +#endif // GROONGA_USE_MAP_HUGETLB if (addr_ == MAP_FAILED) { addr_ = ::mmap(NULL, length_, PROT_READ | PROT_WRITE, flags, fd_, 0); GRN_DAT_THROW_IF(IO_ERROR, addr_ == MAP_FAILED);