Re: Aligning on some odd address?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

  Brian

On Thu, Apr 16, 2009 at 1:43 AM, Philipp Marek
<philipp.marek@xxxxxxxxxxx> wrote:
> Fabian Cenedese <Cenedese <at> indel.ch> writes:
>> >You'd lose that memory anyway if the compiler aligns it himself.
>>
>> I overlooked the packed requirement, but in that case you can just turn
>> it around:
>>
>>         struct {
>>                 unsigned char dummy[7]; // for 8 byte alignment
>>                 unsigned char count;
>>                 struct something_else_t array[];
>>         }
>>
>> Align the struct to 8 bytes and you have your array aligned to 8 bytes.
> Yes ... but that wastes a bit of storage, especially if you have several
> thousand of these structures, and need to align to 32byte ...
>
> As I can say "align this to 16 byte", I thought I'll ask whether I can say
> "align this to 15 (module 16) byte", and maybe get the linker to use the space
> before that for some odd data (like ASCIIZ-strings).
>
> Well, thanks anyway.
>
>
> Regards,
>
> Phil
>
>
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux