什么是“严格对齐”意思? [英] what does "strict alignment" mean?

查看:115
本文介绍了什么是“严格对齐”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标准说char *或void *指针具有最不严格的

对齐。但我不知道什么是严格的对齐。这是什么

是什么意思?

The standard says that a char* or void* pointer has the least strict
alignment. But I do not know what is a strict alignment. What does that
mean?

推荐答案

L. Chen写道:
L. Chen wrote:

标准说char *或void *指针具有最不严格的
对齐。但我不知道什么是严格的对齐。
这是什么意思?

The standard says that a char* or void* pointer has the least strict
alignment. But I do not know what is a strict alignment.
What does that mean?




char类型的对象可以存在于任何字节地址。

其他类型,可能只能存在于某些地址。


N869

3.1

[#1]对齐

要求特定类型的对象位于具有特定地址的
存储边界上

一个字节的倍数地址


-

pete



An object of type char, can exist at any byte address.
Other types, may only be able to exist at some addresses.

N869
3.1
[#1] alignment
requirement that objects of a particular type be located on
storage boundaries with addresses that are particular
multiples of a byte address

--
pete




" pete" ; < PF ***** @ mindspring.com>在消息中写道

news:41 *********** @ mindspring.com ...

"pete" <pf*****@mindspring.com> wrote in message
news:41***********@mindspring.com...
L. Chen写道:
L. Chen wrote:

标准说char *或void *指针具有最不严格的
对齐。但是我不知道什么是严格对齐。
这是什么意思?

The standard says that a char* or void* pointer has the least strict
alignment. But I do not know what is a strict alignment.
What does that mean?



char类型的对象可以存在于任何字节地址。
其他类型,可能只能存在于某些地址。



An object of type char, can exist at any byte address.
Other types, may only be able to exist at some addresses.



或者,在最常见的CPU上,性能可能会下降70%或更多,如果它们是

不太一致。


Or, on the most common CPUs, performance may drop by 70% or more if they are
not so aligned.




" L.陈" < CH ******* @ citiz.net>写了

"L. Chen" <ch*******@citiz.net> wrote

标准说char *或void *指针具有最不严格的
对齐。但我不知道什么是严格的对齐。那是什么意思?

The standard says that a char* or void* pointer has the least strict
alignment. But I do not know what is a strict alignment. What does that
mean?



在某些机器上,除了单词

边界外,不可能读取某些类型。例如,如果整数是32位


Load Accumulator 0x80000001 / *错误,不是边界* /

Load Accumulator 0x80000004 / * ok。 32位边界* /


为了生成有效的代码,C编译器将遵守这些

限制,例如在结构中插入填充位和

从最严格的边界上对齐的malloc()返回值。

C的一个怪癖是char表示字节。根据定义,一个字节是内存的最小可寻址单位,因此字符必须具有最不严格的

对齐。任何地址都可以包含字符。


On some machines, it is not possible to read certain types except on word
boundaries. For instance, if integers are 32 bits

Load Accumulator 0x80000001 /* error, not a boundary */
Load Accumulator 0x80000004 /* ok. 32 bit boundary */

In order to produce efficient code, the C compiler will respect these
restrictions, for instance inserting padding bits in structures and
returning values from malloc() aligned on the strictest boundary.

One of the quirks of C is that "char" means "byte". By definition, a byte is
the smallest addressable unit of memory, so chars must have the least strict
alignment. Any address can contain a char.


这篇关于什么是“严格对齐”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆