mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
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.
This commit is contained in:
@@ -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,7 +1328,7 @@ 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,
|
||||
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);
|
||||
|
@@ -4430,7 +4430,7 @@ page_zip_dir_insert(
|
||||
}
|
||||
|
||||
/* Shift the dense directory to allocate place for rec. */
|
||||
memmove(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, 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.
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/***********************************************************//**
|
||||
|
Reference in New Issue
Block a user