Data structure alignment: Difference between revisions

Content deleted Content added
No edit summary
Line 6:
 
== Definitions ==
A [[computer memory|memory]] address ''a'', is said to be ''n-byte aligned'' when ''n'' is a power of two and ''a'' is a multiple of ''n'' [[byte|bytes]]. In this context a byte is the smallest unit of memory access, i.e. each memory address specifies a different byte. An ''n''-byte aligned address would have ''log<sub>2</sub> n'' least-significant zeros when expressed in [[Binary numeral system|binary]].
A [[computer memory|above assume that each primitive datum is an even power of two bytes long. When this is not the case (as with 80-bit floating-point on x86) the context influences the conditions where the datum is considered aligned or not.
 
==A <nowiki>memory]] address ''a'',access is said to be ''n-byte aligned'' when ''n''the is[[Data a(computing)|datum]] powerbeing ofaccessed two andis ''an'' isbytes along multipleand ofthe datum address is ''n''-byte [[byte|bytes]]aligned. In this contextWhen a byte is the smallest unit of memory access, i.e.is eachnot memoryaligned, addressit specifiesis asaid differentto byte. Anbe ''nmisaligned''-byte. alignedNote addressthat wouldby havedefinition ''log<sub>2</sub>byte n''memory least-significantaccesses zerosare whenalways expressed in [[Binary numeral system|binary]]aligned.
 
A memory access is said to be ''aligned'' when the [[Data (computing)|datum]] being accessed is ''n'' bytes long and the jjjjjjjjjjjjjjjjjjḌ~~~~Symbols: ~ | ¡ ¿ † ‡ ↔ ↑ ↓ • ¶ # ¹ ² ³ ½ ⅓ ⅔ ¼ ¾ ⅛ ⅜ ⅝ ⅞ ∞ ‘ “ ’ ” ฿ ¢ ₡ $ ₫ € ₭ ₤ ₦ £ ₨ ₪ ৳ ₮ ₩ ¥ ♠ ♣ ♥ ♦
Characters: Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź À à È è Ì ì Ò ò Ù ù  â Ĉ ĉ Ê ê Ĝ ĝ Ĥ ĥ Î î Ĵ ĵ Ô ô Ŝ ŝ Û û Ŵ ŵ Ŷ ŷ Ä ä Ë ë Ï ï Ö ö Ü ü Ÿ ÿ ß Ã ã Ẽ ẽ Ĩ ĩ Ñ ñ Õ õ Ũ ũ Ỹ ỹ Ç ç Ģ ģ Ķ ķ Ļ ļ Ņ ņ Ŗ ŗ Ş ş Ţ ţ Đ đ Ů ů Ǎ ǎ Č č Ď ď Ě ě Ǐ ǐ Ľ ľ Ň ň Ǒ ǒ Ř ř Š š Ť ť Ǔ ǔ Ž ž Ā ā Ē ē Ī ī Ō ō Ū ū Ȳ ȳ Ǣ ǣ ǖ ǘ ǚ ǜ Ă ă Ĕ ĕ Ğ ğ Ĭ ĭ Ŏ ŏ Ŭ ŭ Ċ ċ Ė ė Ġ ġ İ ı Ż ż Ą ą Ę ę Į į Ǫ ǫ Ų ų Ḍ ḍ Ḥ ḥ Ḷ ḷ Ḹ ḹ Ṃ ṃ Ṇ ṇ Ṛ ṛ Ṝ ṝ Ṣ ṣ Ṭ ṭ Ł ł Ő ő Ű ű Ŀ ŀ Ħ ħ Ð ð Þ þ Œ œ Æ æ Ø ø Å å Ə ə • {{Unicode|}}
Greek: Ά ά Έ έ Ή ή Ί ί Ό ό Ύ ύ Ώ ώ Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ Φ φ Χ χ Ψ ψ Ω ω • {{Polytonic|}} • (polytonic list)
Cyrillic: А а Б б В в Г г Ґ ґ Ѓ ѓ Д д Ђ ђ Е е Ё ё Є є Ж ж З з Ѕ ѕ И и І і Ї ї Й й Ј ј К к Ќ ќ Л л Љ љ М м Н н Њ њ О о П п Р р С с Т т Ћ ћ У у Ў ў Ф ф Х х Ц ц Ч ч Џ џ Ш ш Щ щ Ъ ъ Ы ы Ь ь Э э Ю ю Я я
IPA: t̪ d̪ ʈ ɖ ɟ ɡ ɢ ʡ ʔ ɸ ʃ ʒ ɕ ʑ ʂ ʐ ʝ ɣ ʁ ʕ ʜ ʢ ɦ ɱ ɳ ɲ ŋ ɴ ʋ ɹ ɻ ɰ ʙ ʀ ɾ ɽ ɫ ɬ ɮ ɺ ɭ ʎ ʟ ɥ ʍ ɧ ɓ ɗ ʄ ɠ ʛ ʘ ǀ ǃ ǂ ǁ ɨ ʉ ɯ ɪ ʏ ʊ ɘ ɵ ɤ ə ɚ ɛ ɜ ɝ ɞ ʌ ɔ ɐ ɶ ɑ ɒ ʰ ʷ ʲ ˠ ˤ ⁿ ˡ ˈ ˌ ː ˑ ̪ • {{IPA|}}tum address is ''n''-byte aligned. When a memory access is not aligned, it is said to be ''misaligned''. Note that by definition byte memory accesses are always aligned.
 
A memory pointer that refers to primitive data that is ''n'' bytes long is said to be ''aligned'' if it is only allowed to contain addresses that are ''n''-byte aligned, otherwise it is said to be ''unaligned''. A memory pointer that refers to a data aggregate (a data structure or array) is ''aligned'' if (and only if) each primitive datum in the aggregate is aligned.
 
ANote [[computerthat the definitions memory|above assume that each primitive datum is an even power of two bytes long. When this is not the case (as with 80-bit floating-point on x86) the context influences the conditions where the datum is considered aligned or not.
Note that the definitions</nowiki> ==
 
== Problems ==