Commit 51a4260f authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21133: Introduce memmove_aligned()

Both variants of the InnoDB page directory are aligned to the entry size
(16 bits). Inform the compiler about it.
parent 0f71e9e6
......@@ -210,6 +210,13 @@ inline void *memcpy_aligned(void *dest, const void *src, size_t n)
MY_ASSUME_ALIGNED(src, Alignment), n);
}
template <size_t Alignment>
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 <size_t Alignment>
inline int memcmp_aligned(const void *s1, const void *s2, size_t n)
{
static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2");
......
......@@ -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;
......
......@@ -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));
}
/***********************************************************//**
......
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