Skip to content

Commit

Permalink
Merge 10.6 into 10.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 22, 2022
2 parents 6680fd8 + 0fa19fd commit 8ebff3b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
9 changes: 8 additions & 1 deletion configure.cmake
Expand Up @@ -324,7 +324,14 @@ ENDIF()
CHECK_FUNCTION_EXISTS (accept4 HAVE_ACCEPT4)
CHECK_FUNCTION_EXISTS (access HAVE_ACCESS)
CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM)
CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT WITH_ASAN)
# When an old custom memory allocator library is used, aligned_alloc()
# could invoke the built-in allocator in libc, not matching
# the overriden free() in the custom memory allocator.
SET(HAVE_ALIGNED_ALLOC 0)
ELSE()
CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC)
ENDIF()
SET(HAVE_ALLOCA 1)
CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE)
CHECK_FUNCTION_EXISTS (backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
Expand Down
7 changes: 7 additions & 0 deletions include/aligned.h
Expand Up @@ -14,12 +14,19 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */

#ifdef HAVE_ALIGNED_ALLOC
#elif defined __linux__
# include <malloc.h>
#endif

inline void *aligned_malloc(size_t size, size_t alignment)
{
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#elif defined HAVE_ALIGNED_ALLOC
return aligned_alloc(alignment, size);
#elif defined __linux__
return memalign(alignment, size);
#else
void *result;
if (posix_memalign(&result, alignment, size))
Expand Down
12 changes: 11 additions & 1 deletion storage/innobase/buf/buf0flu.cc
Expand Up @@ -573,9 +573,19 @@ static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot)
buffer be bigger than input buffer. Adjust the allocated size. */
ulint size= srv_page_size;
if (provider_service_lzo->is_loaded)
size+= LZO1X_1_15_MEM_COMPRESS;
{
size= LZO1X_1_15_MEM_COMPRESS;
#ifdef HAVE_ALIGNED_ALLOC
size= MY_ALIGN(size, srv_page_size);
#endif
}
else if (provider_service_snappy->is_loaded)
{
size= snappy_max_compressed_length(size);
#ifdef HAVE_ALIGNED_ALLOC
size= MY_ALIGN(size, srv_page_size);
#endif
}
slot->comp_buf= static_cast<byte*>(aligned_malloc(size, srv_page_size));
}

Expand Down
4 changes: 3 additions & 1 deletion storage/perfschema/unittest/stub_pfs_global.h
Expand Up @@ -26,6 +26,7 @@
#include <pfs_global.h>
#include <string.h>
#include "aligned.h"
#include "assume_aligned.h"

bool pfs_initialized= false;
size_t pfs_allocated_memory_size= 0;
Expand All @@ -47,9 +48,10 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf)
if (--stub_alloc_fails_after_count <= 0)
return NULL;

size= MY_ALIGN(size, CPU_LEVEL1_DCACHE_LINESIZE);
void *ptr= aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE);
if (ptr != NULL)
memset(ptr, 0, size);
memset_aligned<CPU_LEVEL1_DCACHE_LINESIZE>(ptr, 0, size);
return ptr;
}

Expand Down

0 comments on commit 8ebff3b

Please sign in to comment.