[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MULTIBOOT2 DOC PATCH 08/10] multiboot2: Add C structure alignment a
From: |
Andrew Cooper |
Subject: |
Re: [MULTIBOOT2 DOC PATCH 08/10] multiboot2: Add C structure alignment and padding consideration section |
Date: |
Thu, 9 Jun 2016 23:07:12 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 09/06/2016 21:30, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <address@hidden>
> ---
> doc/multiboot.texi | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/doc/multiboot.texi b/doc/multiboot.texi
> index c81b2ea..bf02a1b 100644
> --- a/doc/multiboot.texi
> +++ b/doc/multiboot.texi
> @@ -1384,6 +1384,7 @@ document, but are included for prospective operating
> system and boot
> loader writers.
>
> @menu
> +* C structure alignment and padding consideration::
> * Notes on PC::
> * BIOS device mapping techniques::
> * Example OS code::
> @@ -1391,6 +1392,22 @@ loader writers.
> @end menu
>
>
> address@hidden C structure alignment and padding consideration
> address@hidden C structure alignment and padding consideration
> +
> +Many C compilers try to optimize memory accesses aligning structure
"by aligning"
> +members properly. Usually they reach the goal by adding some padding.
What does "properly" mean here? The default padding will be specified
by the default ABI the compiler conforms to.
> +This is very useful thing in general. However, if you try to mix assembler
> +with C or use C to implement structure low level access this behavior
> +may lead, at least, to quite surprising results. Hence, compiler should
> +be instructed to not optimize such accesses. Usually it is done by special
> +attribute added to structure definition, e.g. GCC compatible sources use
> address@hidden ((__packed__))} for this purpose. However, this is not
> +required if it is known that its members are properly aligned and compiler
> +does not do any optimization. Very good example of this is shown below in
> address@hidden file.
I am not sure what you are trying to say.
~Andrew
- Re: [Xen-devel] [MULTIBOOT2 DOC PATCH 02/10] multiboot2: Clarify meaning of information request header tag, (continued)
- [MULTIBOOT2 DOC PATCH 03/10] multiboot2: Fix description of EFI boot services tag, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 05/10] multiboot2: Add description of EFI image handle tags, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 04/10] multiboot2: Add description of support for EFI boot services, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 06/10] multiboot2: Add description of support for relocatable images, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 09/10] multiboot2: Add me to authors, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 08/10] multiboot2: Add C structure alignment and padding consideration section, Daniel Kiper, 2016/06/09
- Re: [MULTIBOOT2 DOC PATCH 08/10] multiboot2: Add C structure alignment and padding consideration section,
Andrew Cooper <=
- [MULTIBOOT2 DOC PATCH 07/10] multiboot2: Say that memory maps may not be available on EFI platforms, Daniel Kiper, 2016/06/09
- [MULTIBOOT2 DOC PATCH 10/10] multiboot2: Bump version to 2.0, Daniel Kiper, 2016/06/09