Re: will __attribute__((aligned(CACHE_LINE_SIZE))) break struct alignment

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

 



Thanks Florian,

2017年11月6日星期一,Florian Weimer <fweimer@xxxxxxxxxx> 写道:

> On 11/06/2017 06:04 AM, Yubin Ruan wrote:
>
>> I am using something like this:
>>
>>    struct S1 {
>>      int index __attribute__((aligned(CACHE_LINE_SIZE)));
>>      struct S2 some_other;
>>    };
>>
>> I am not using anything like `#pragma pack`.
>>
>> I am wondering whether adding that
>> `__attribute__((aligned(CACHE_LINE_SIZE)))` will break GCC's automatic
>> alignment for S1 and S2. Can anyone point me to any document which
>> specify this behavior?
>>
>
> It will change the alignment of struct S1, so code which allocates objects
> of struct S1 will have to be modified, and the offset in structs of a
> member of type struct S1 will likely change (and so will the offsets of
> members after it).
>
> So in general, this is not an ABI-compatible change.
>

Hmm... if struct S1 was aligned at a power of 4 boundary, then will that
alignment be changed after adding that
"__attribute__((aligned(CACHE_LINE_SIZE)))"? The same for "someother" ?

Yubin




[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