gpt4 book ai didi

c - 对齐8的原因是什么?

转载 作者:太空狗 更新时间:2023-10-29 14:55:27 25 4
gpt4 key购买 nike

  struct {              /* Fileheader */
uchar file_version[4];
uchar options[2];
uchar header_length[2];
uchar state_info_length[2];
uchar base_info_length[2];
uchar base_pos[2];
uchar key_parts[2]; /* Key parts */
uchar unique_key_parts[2]; /* Key parts + unique parts */
uchar keys; /* number of keys in file */
uchar uniques; /* number of UNIQUE definitions */
uchar language; /* Language for indexes */
uchar max_block_size_index; /* max keyblock size */
uchar fulltext_keys;
uchar not_used; /* To align to 8 */
} header;

以上内容摘自MySQL源码,

为什么要对齐8

最佳答案

这是一种优化,允许 CPU 更有效地访问内存中的结构。

http://en.wikipedia.org/wiki/Data_structure_alignment

关于c - 对齐8的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7870903/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com