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

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

 



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.

Thanks,
Florian



[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