Aligning on some odd address?

Philipp Marek philipp.marek@emerion.com
Fri Apr 17 06:28:00 GMT 2009


On Donnerstag, 16. April 2009, Brian Budge wrote:
> Are these structs packed as-in the "packed" attribute?  Do you expect
> to have arrays of the outer structs, or will they all be instantiated
> separately?  Do you know the alignment of the something_else_t?  Is
> this to support something legacy, or is this a new design?
>
> I'm not sure there's quite enough information yet to know how to help.
Sorry, I'll try to expand a bit.

If you look into the linux kernel sources you'll find lots of pci_device_id 
and similar structures, which are used to identify hardware.
These structures are at least 16 bytes, and there are (as of some quick count 
with perl) 1260 such arrays - all of which are terminated by an empty 
structure, ie. one consisting of zero bytes.

That means that (at most) about 12k are "wasted" (on disk and in memory) by 
the terminating entries.

So I thought about whether it's possible to put a small length description in 
front of them - but if this length gets padded to the same amount as the 
array, this doesn't make sense, as no space is saved.
The arrays hold up to (again, quick survey with a perl script) 508 entries ...  
so it's not easy to use a few low bits in some pointer.


Currently I'm thinking about extending the pci_driver (and similar) 
structures, to add a "id_table_len" member after the "id_table" pointer, to 
hold the number of elements.


Regards,

Phil



More information about the Gcc-help mailing list