diff --git a/include/m_string.h b/include/m_string.h index cc7ff48e390..068460f878c 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -210,6 +210,13 @@ inline void *memcpy_aligned(void *dest, const void *src, size_t n) MY_ASSUME_ALIGNED(src, Alignment), n); } template +inline void *memmove_aligned(void *dest, const void *src, size_t n) +{ + static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2"); + return memmove(MY_ASSUME_ALIGNED(dest, Alignment), + MY_ASSUME_ALIGNED(src, Alignment), n); +} +template inline int memcmp_aligned(const void *s1, const void *s2, size_t n) { static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2"); diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 230a1a17573..e3ff2086f92 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1273,7 +1273,8 @@ static void page_dir_split_slot(page_t* page, page_zip_des_t* page_zip, const ulint n_slots = page_dir_get_n_slots(page); page_dir_set_n_slots(page, page_zip, n_slots + 1); page_dir_slot_t* last_slot = page_dir_get_nth_slot(page, n_slots); - memmove(last_slot, last_slot + PAGE_DIR_SLOT_SIZE, slot - last_slot); + memmove_aligned<2>(last_slot, last_slot + PAGE_DIR_SLOT_SIZE, + slot - last_slot); /* 3. We store the appropriate values to the new slot. */ @@ -1327,8 +1328,8 @@ static void page_dir_balance_slot(page_t* page, page_zip_des_t* page_zip, /* Shift the slots */ page_dir_slot_t* last_slot = page_dir_get_nth_slot( page, n_slots - 1); - memmove(last_slot + PAGE_DIR_SLOT_SIZE, last_slot, - slot - last_slot); + memmove_aligned<2>(last_slot + PAGE_DIR_SLOT_SIZE, last_slot, + slot - last_slot); mach_write_to_2(last_slot, 0); page_dir_set_n_slots(page, page_zip, n_slots - 1); return; diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index a01100f2f0d..e0586fdb763 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4430,8 +4430,8 @@ page_zip_dir_insert( } /* Shift the dense directory to allocate place for rec. */ - memmove(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, slot_free, - ulint(slot_rec - slot_free)); + memmove_aligned<2>(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, slot_free, + ulint(slot_rec - slot_free)); /* Write the entry for the inserted record. The "owned" and "deleted" flags must be zero. */ @@ -4489,9 +4489,8 @@ page_zip_dir_delete( } if (UNIV_LIKELY(slot_rec > slot_free)) { - memmove(slot_free + PAGE_ZIP_DIR_SLOT_SIZE, - slot_free, - ulint(slot_rec - slot_free)); + memmove_aligned<2>(slot_free + PAGE_ZIP_DIR_SLOT_SIZE, + slot_free, ulint(slot_rec - slot_free)); } /* Write the entry for the deleted record. @@ -4585,7 +4584,8 @@ page_zip_dir_add_slot( /* Move the uncompressed area backwards to make space for one directory slot. */ - memmove(stored - PAGE_ZIP_DIR_SLOT_SIZE, stored, ulint(dir - stored)); + memmove_aligned<2>(stored - PAGE_ZIP_DIR_SLOT_SIZE, stored, + ulint(dir - stored)); } /***********************************************************//**