Commit e4a96078 authored by Sergey Vojtovich's avatar Sergey Vojtovich

my_next_large_page_size() cleanup

Make it static, coding style cleanup, declare consistently with all
callers (same ifdefs).
parent fc6e8b4b
...@@ -176,12 +176,6 @@ extern void *my_memdup(PSI_memory_key key, const void *from,size_t length,myf My ...@@ -176,12 +176,6 @@ extern void *my_memdup(PSI_memory_key key, const void *from,size_t length,myf My
extern char *my_strdup(PSI_memory_key key, const char *from,myf MyFlags); extern char *my_strdup(PSI_memory_key key, const char *from,myf MyFlags);
extern char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf MyFlags); extern char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf MyFlags);
#if defined(__linux__) || defined(HAVE_GETPAGESIZES)
extern size_t my_next_large_page_size(size_t sz, int *start);
#else
#define my_next_large_page_size(A,B) (0)
#endif
#if defined(_WIN32) || (defined(HAVE_MMAP) && !defined(__linux__) \ #if defined(_WIN32) || (defined(HAVE_MMAP) && !defined(__linux__) \
&& !defined(MAP_ALIGNED)) && !defined(MAP_ALIGNED))
extern void my_get_large_page_size(void); extern void my_get_large_page_size(void);
......
...@@ -60,6 +60,65 @@ static my_bool my_large_free_int(void *ptr, size_t size); ...@@ -60,6 +60,65 @@ static my_bool my_large_free_int(void *ptr, size_t size);
#ifdef HAVE_LARGE_PAGE_OPTION #ifdef HAVE_LARGE_PAGE_OPTION
#if defined(HAVE_GETPAGESIZES) || defined(__linux__)
/* Descending sort */
static int size_t_cmp(const void *a, const void *b)
{
const size_t ia= *(const size_t *) a;
const size_t ib= *(const size_t *) b;
if (ib > ia)
{
return 1;
}
else if (ib < ia)
{
return -1;
}
return 0;
}
/**
Returns the next large page size smaller or equal to the passed in size.
The search starts at my_large_page_sizes[*start].
Assumes my_get_large_page_sizes(my_large_page_sizes) has been called before
use.
For first use, have *start=0. There is no need to increment *start.
@param[in] sz size to be searched for.
@param[in,out] start ptr to int representing offset in my_large_page_sizes to
start from.
*start is updated during search and can be used to search again if 0 isn't
returned.
@returns the next size found. *start will be incremented to the next potential
size.
@retval a large page size that is valid on this system or 0 if no large page
size possible.
*/
static size_t my_next_large_page_size(size_t sz, int *start)
{
DBUG_ENTER("my_next_large_page_size");
while (*start < my_large_page_sizes_length && my_large_page_sizes[*start] > 0)
{
size_t cur= *start;
(*start)++;
if (my_large_page_sizes[cur] <= sz)
{
DBUG_RETURN(my_large_page_sizes[cur]);
}
}
DBUG_RETURN(0);
}
#endif /* defined(HAVE_GETPAGESIZES) || defined(__linux__) */
int my_init_large_pages(my_bool super_large_pages) int my_init_large_pages(my_bool super_large_pages)
{ {
my_use_large_pages= 1; my_use_large_pages= 1;
...@@ -168,60 +227,6 @@ void my_large_free(void *ptr, size_t size) ...@@ -168,60 +227,6 @@ void my_large_free(void *ptr, size_t size)
} }
#endif /* HAVE_LARGE_PAGE_OPTION */ #endif /* HAVE_LARGE_PAGE_OPTION */
#if defined(HAVE_GETPAGESIZES) || defined(__linux__)
/* Descending sort */
static int size_t_cmp(const void *a, const void *b)
{
const size_t *ia= (const size_t *)a; // casting pointer types
const size_t *ib= (const size_t *)b;
if (*ib > *ia)
{
return 1;
}
else if (*ib < *ia)
{
return -1;
}
return 0;
}
/*
Returns the next large page size smaller or equal to the passed in size.
The search starts at my_large_page_sizes[*start].
Assumes my_get_large_page_sizes(my_large_page_sizes) has been called before use.
For first use, have *start=0. There is no need to increment *start.
@param[in] sz size to be searched for.
@param[in,out] start ptr to int representing offset in my_large_page_sizes to start from.
*start is updated during search and can be used to search again if 0 isn't returned.
@returns the next size found. *start will be incremented to the next potential size.
@retval a large page size that is valid on this system or 0 if no large page size possible.
*/
size_t my_next_large_page_size(size_t sz, int *start)
{
size_t cur;
DBUG_ENTER("my_next_large_page_size");
while (*start < my_large_page_sizes_length
&& my_large_page_sizes[*start] > 0)
{
cur= *start;
(*start)++;
if (my_large_page_sizes[cur] <= sz)
{
DBUG_RETURN(my_large_page_sizes[cur]);
}
}
DBUG_RETURN(0);
}
#endif /* defined(HAVE_GETPAGESIZES) || defined(__linux__) */
#ifdef __linux__ #ifdef __linux__
/* Linux-specific function to determine the sizes of large pages */ /* Linux-specific function to determine the sizes of large pages */
......
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