Content deleted Content added
Peter Flass (talk | contribs) →Computing padding: note on byte/word sizes |
Guy Harris (talk | contribs) Separate reference and non-reference footnotes. Punctuation before footnotes. |
||
Line 86:
For example, the padding to add to offset 0x59d for a 4-byte aligned structure is 3. The structure will then start at 0x5a0, which is a multiple of 4. However, when the alignment of ''offset'' is already equal to that of ''align'', the second modulo in ''(align - (offset mod align)) mod align'' will return zero, therefore the original value is left unchanged.
Since the alignment is by [[#Definitions|definition]] a power of two
The following formulas produce the aligned offset (where ''&'' is a [[bitwise AND]] and ''~'' a [[bitwise NOT]]):
Line 280:
#define aligntonext(p, bits) alignto(((p) + (1 << bits) - 1), bits)
</syntaxhighlight>
==Notes==
{{notelist}}
==References==
|