Skip to contentSkip to conversation

multiboot2 structs and packed attribute

DISCUSSION Daniel Kiper 2 participants 4 messages Mar 7, 2016 – Mar 10, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Does anybody know why only multiboot2 multiboot_mmap_entry struct has packed attribute? Is it by design or by mistake? I think that we should use packed attribute for every multiboot2 protocol related struct. If not then we should probably remove this attribute from multiboot_mmap_entry struct too. What do you think about that?

Daniel

#1 lore raw
Quoted 8 lines · Daniel Kiper

Hi,

Does anybody know why only multiboot2 multiboot_mmap_entry struct has packed attribute? Is it by design or by mistake? I think that we should use packed attribute for every multiboot2 protocol related struct. If not then we should probably remove this attribute from multiboot_mmap_entry struct too. What do you think about that?

We put packed only when it changes relative offsets of members or size of the structure. Is it the case for structures you have in mind?

Quoted 3 lines

Daniel

#2 lore raw
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
Quoted 2 lines · Daniel Kiper

Hi,

Quoted 8 lines
Quoted 6 lines

Does anybody know why only multiboot2 multiboot_mmap_entry struct has packed attribute? Is it by design or by mistake? I think that we should use packed attribute for every multiboot2 protocol related struct. If not then we should probably remove this attribute from multiboot_mmap_entry struct too. What do you think about that?

We put packed only when it changes relative offsets of members or size of the structure. Is it the case for structures you have in mind?

I do not have anything specific. However, it looks like stray stuff.

Hmmm... I took a look at multiboot_mmap_entry once again and it seems that this struct really does not need packed attribute. All members are in right order and even compiler should not add padding. Am I right?

Anyway, maybe we should add somewhere in the header comment saying that all/most of multiboot2 structures are build in a way that fulfill alignment requirements out of the box and compiler does not need to do any rearrangements. However, we should warn that new extensions should be added carefully and some structs may require GRUB_PACKED attribute in the future to properly represent added interface.

Or we can add GRUB_PACKED to every struct. However, this seems redundant here. There is no chance that somebody will rearrange, especially blindly, existing structs.

Daniel

#3 lore raw
Quoted 13 lines · Daniel Kiper
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Le lun. 7 mars 2016 14:35, Daniel Kiper <[email protected]

Quoted 9 lines · <javascript:;>> a écrit :
Quoted 9 lines

Hi,

Does anybody know why only multiboot2 multiboot_mmap_entry struct has packed attribute? Is it by design or by mistake? I think that we should use packed attribute for every multiboot2 protocol related struct. If not then we should probably remove this attribute from multiboot_mmap_entry struct too. What do you think about that?

Quoted 9 lines
Quoted 2 lines

We put packed only when it changes relative offsets of members or size of the structure. Is it the case for structures you have in mind?

I do not have anything specific. However, it looks like stray stuff.

Hmmm... I took a look at multiboot_mmap_entry once again and it seems that this struct really does not need packed attribute. All members are in right order and even compiler should not add padding. Am I right?

Yes, good catch.

Quoted 9 lines

Anyway, maybe we should add somewhere in the header comment saying that all/most of multiboot2 structures are build in a way that fulfill alignment requirements out of the box and compiler does not need to do any rearrangements.
However, we should warn that new extensions should be added carefully and some structs may require GRUB_PACKED attribute in the future to properly represent added interface.

This probably should go to spec rather than the header file.

Quoted 8 lines

Or we can add GRUB_PACKED to every struct. However, this seems redundant here.
There is no chance that somebody will rearrange, especially blindly, existing structs.

Daniel

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko