Commit f6d1933e authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Fix #6293. Don't use {{{mincore()}}} on Darwin.

git-svn-id: file:///svn/toku/tokudb@54523 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1de5e9a3
......@@ -59,6 +59,7 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
endif ()
check_symbol_exists(O_DIRECT "fcntl.h" HAVE_O_DIRECT)
check_symbol_exists(F_NOCACHE "fcntl.h" HAVE_F_NOCACHE)
check_symbol_exists(MAP_ANONYMOUS "sys/mman.h" HAVE_MAP_ANONYMOUS)
include(CheckFunctionExists)
......@@ -71,6 +72,7 @@ check_function_exists(valloc HAVE_VALLOC)
## check whether we have random_r or nrand48 to use as a reentrant random function
check_function_exists(nrand48 HAVE_NRAND48)
check_function_exists(random_r HAVE_RANDOM_R)
check_function_exists(mincore HAVE_MINCORE)
set(EXTRA_SYSTEM_LIBS "")
check_function_exists(dlsym HAVE_DLSYM_WITHOUT_DL)
......
......@@ -50,9 +50,15 @@ static bool check_huge_pages_config_file(const char *fname)
static bool check_huge_pages_in_practice(void)
// Effect: Return true if huge pages appear to be defined in practice.
{
#ifdef HAVE_MINCORE
#ifdef HAVE_MAP_ANONYMOUS
const int map_anonymous = MAP_ANONYMOUS;
#else
const int map_anonymous = MAP_ANON;
#endif
const size_t TWO_MB = 2UL*1024UL*1024UL;
void *first = mmap(NULL, 2*TWO_MB, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
void *first = mmap(NULL, 2*TWO_MB, PROT_READ|PROT_WRITE, MAP_PRIVATE|map_anonymous, -1, 0);
if ((long)first==-1) perror("mmap failed");
{
int r = munmap(first, 2*TWO_MB);
......@@ -60,7 +66,7 @@ static bool check_huge_pages_in_practice(void)
}
void *second_addr = (void*)(((unsigned long)first + TWO_MB) & ~(TWO_MB -1));
void *second = mmap(second_addr, TWO_MB, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
void *second = mmap(second_addr, TWO_MB, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_PRIVATE|map_anonymous, -1, 0);
if ((long)second==-1) perror("mmap failed");
assert((long)second%TWO_MB == 0);
......@@ -96,6 +102,10 @@ static bool check_huge_pages_in_practice(void)
} else {
return false;
}
#else
// No mincore, so no way to check this in practice
return false;
#endif
}
bool complain_and_return_true_if_huge_pages_are_enabled(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment