diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2020-04-03 20:46:48 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2020-04-04 14:55:51 +0400 |
commit | e4a960780f162ad39da63423a02665bc3be878ba (patch) | |
tree | 5fe6b814dc0f989f96071a6efb936a22577d83f8 /mysys | |
parent | fc6e8b4b1b2f9fcb62d0459892c59ece759fd144 (diff) | |
download | mariadb-git-e4a960780f162ad39da63423a02665bc3be878ba.tar.gz |
my_next_large_page_size() cleanup
Make it static, coding style cleanup, declare consistently with all
callers (same ifdefs).
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_largepage.c | 113 |
1 files changed, 59 insertions, 54 deletions
diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 95813ccee1c..9d84cbca6ec 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -60,6 +60,65 @@ static my_bool my_large_free_int(void *ptr, size_t size); #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) { my_use_large_pages= 1; @@ -168,60 +227,6 @@ void my_large_free(void *ptr, size_t size) } #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__ /* Linux-specific function to determine the sizes of large pages */ |