This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC patch] spindep: add cross cache lines checking
- From: Alex Shi <alex dot shi at intel dot com>
- To: Arnd Bergmann <arnd at arndb dot de>
- Cc: gcc at gcc dot gnu dot org, Ingo Molnar <mingo at elte dot hu>, tglx at linutronix dot de, "mingo at redhat dot com" <mingo at redhat dot com>, hpa at zytor dot com, akpm at linux-foundation dot org, linux-kernel at vger dot kernel dot org, x86 at kernel dot org, andi dot kleen at intel dot com, gcc-help at gcc dot gnu dot org
- Date: Thu, 08 Mar 2012 10:30:47 +0800
- Subject: Re: [RFC patch] spindep: add cross cache lines checking
- References: <1330917630.18835.44.camel@debian> <201203060932.45223.arnd@arndb.de> <1331108607.18835.343.camel@debian> <201203071154.36059.arnd@arndb.de>
> > 1, it is alignof bug for default gcc on my fc15 and Ubuntu 11.10 etc?
> >
> > struct sub {
> > int raw_lock;
> > char a;
> > };
> > struct foo {
> > struct sub z;
> > int slk;
> > char y;
> > }__attribute__((packed));
> >
> > struct foo f1;
> >
> > __alignof__(f1.z.raw_lock) is 4, but its address actually can align on
> > one byte.
>
> That looks like correct behavior, because the alignment of raw_lock inside of
> struct sub is still 4. But it does mean that there can be cases where the
> compile-time check is not sufficient, so we might want the run-time check
> as well, at least under some config option.
According to explanation of gcc, seems it should return 1 when it can be
align on char. And then it's useful for design intend. Any comments from
gcc guys?
====
http://gcc.gnu.org/onlinedocs/gcc/Alignment.html
The keyword __alignof__ allows you to inquire about how an object is
aligned, or the minimum alignment usually required by a type. Its syntax
is just like sizeof.