diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-12-17 21:50:58 +0800 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2019-12-18 20:09:52 +0800 |
commit | 3d3d8f10120dd2311ef8195d19389c4a1e85786b (patch) | |
tree | ad44351a9b9048263cf858550a66175cf7606099 /storage | |
parent | 984b3c15449e0b5c7b3d66047a3c490c7be40faf (diff) | |
download | mariadb-git-3d3d8f10120dd2311ef8195d19389c4a1e85786b.tar.gz |
MDEV-21337 fix aligned_malloc()
do not fallback to malloc(), always return properly aligned buffer
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/CMakeLists.txt | 5 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 17 | ||||
-rw-r--r-- | storage/xtradb/CMakeLists.txt | 5 | ||||
-rw-r--r-- | storage/xtradb/buf/buf0buf.cc | 9 |
4 files changed, 10 insertions, 26 deletions
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 44db4552e74..6558c3ae0dc 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -94,11 +94,6 @@ IF(NOT MSVC) SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) ENDIF() - CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) - IF(HAVE_POSIX_MEMALIGN) - ADD_DEFINITIONS(-DHAVE_POSIX_MEMALIGN) - ENDIF() - # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not # workaround for old gcc on x86, gcc atomic ops only work under -march=i686 IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 4d5b3f29f82..b6aab663f3c 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -82,19 +82,16 @@ Created 11/5/1995 Heikki Tuuri #include "snappy-c.h" #endif -inline void* aligned_malloc(size_t size, size_t align) { - void *result; +static void *aligned_malloc(size_t size, size_t align) +{ #ifdef _MSC_VER - result = _aligned_malloc(size, align); -#elif defined (HAVE_POSIX_MEMALIGN) - if(posix_memalign(&result, align, size)) { - result = 0; - } + return _aligned_malloc(size, align); #else - /* Use unaligned malloc as fallback */ - result = malloc(size); + void *result; + if (posix_memalign(&result, align, size)) + result= NULL; #endif - return result; + return result; } inline void aligned_free(void *ptr) { diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index cc269b44201..465d93eafc5 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -93,11 +93,6 @@ MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-class-memaccess") IF(NOT MSVC) - CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) - IF(HAVE_POSIX_MEMALIGN) - ADD_DEFINITIONS(-DHAVE_POSIX_MEMALIGN) - ENDIF() - # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not # workaround for old gcc on x86, gcc atomic ops only work under -march=i686 IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 6ddcc3521da..398e1e84994 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -92,17 +92,14 @@ buf_mark_space_corrupt( /* prototypes for new functions added to ha_innodb.cc */ trx_t* innobase_get_trx(); -inline void* aligned_malloc(size_t size, size_t align) { +static void* aligned_malloc(size_t size, size_t align) { void *result; #ifdef _MSC_VER result = _aligned_malloc(size, align); -#elif defined (HAVE_POSIX_MEMALIGN) +#else if(posix_memalign(&result, align, size)) { - result = 0; + result = NULL; } -#else - /* Use unaligned malloc as fallback */ - result = malloc(size); #endif return result; } |