* g++: __attribute__ ((aligned)) weirdness
@ 2003-03-18 16:16 Andrew Haley
2003-03-18 20:24 ` Piotr Wyderski
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2003-03-18 16:16 UTC (permalink / raw)
To: gcc
The doc says
The `aligned' attribute can only increase the alignment; but you
can decrease it by specifying `packed' as well. See below.
but this doesn't seem to be true. For example, on x86 g++ you have a non-POD
class and a subclass:
-----------------------------------------------------------------------------
class Boof
{
int arse ()
{
return 25;
}
void *prickle;
};
class foo : Boof
{
public: long long i;
};
-----------------------------------------------------------------------------
then try:
-----------------------------------------------------------------------------
foo f;
fprintf(stderr, "offset: %d\n", (char *)&f.i - (char *)&f);
-----------------------------------------------------------------------------
offset: 4
Fair enough, this long long is probably 4-aligned.
Now do this:
-----------------------------------------------------------------------------
class bar : Boof
{
public: long long __attribute__((aligned(4))) i;
};
bar b;
fprintf(stderr, "offset: %d\n", (char *)&b.i - (char *)&b);
-----------------------------------------------------------------------------
offset: 8
So you have a field at offset 4. You ask for it to be 4-aligned, and
it jumps to offset 8.
What is going on?
Andrew.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __attribute__ ((aligned)) weirdness
2003-03-18 16:16 g++: __attribute__ ((aligned)) weirdness Andrew Haley
@ 2003-03-18 20:24 ` Piotr Wyderski
2003-03-18 20:28 ` Andrew Haley
0 siblings, 1 reply; 7+ messages in thread
From: Piotr Wyderski @ 2003-03-18 20:24 UTC (permalink / raw)
To: gcc
> So you have a field at offset 4. You ask for it to be 4-aligned, and
> it jumps to offset 8.
>
> What is going on?
The alignment of x means that the offset of a variable is divisible
by x with no remainder. Each y=x*2^n (where n is natural) is
a good alignment too, because f mod y = 0 => f mod x = 0;
8-aligned field is also 4-aligned. So where's the problem?
Best regards
Piotr Wyderski
Serwis www.logo.hoga.pl - sciagaj bajery na telefony
Nokia, Siemens, Alcatel, Ericsson, Motorola,Samsung
------------------------------------------------------------
Promocja!!! rabat 40 % na zakup mks_vir 2003 dla klientów Connect , którzy
posiadaja kupony rabatowe.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __attribute__ ((aligned)) weirdness
2003-03-18 20:24 ` Piotr Wyderski
@ 2003-03-18 20:28 ` Andrew Haley
2003-03-18 22:34 ` Andreas Tobler
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2003-03-18 20:28 UTC (permalink / raw)
To: Piotr Wyderski; +Cc: gcc
Piotr Wyderski writes:
> > So you have a field at offset 4. You ask for it to be 4-aligned, and
> > it jumps to offset 8.
> >
> > What is going on?
>
> The alignment of x means that the offset of a variable is divisible
> by x with no remainder. Each y=x*2^n (where n is natural) is
> a good alignment too, because f mod y = 0 => f mod x = 0;
> 8-aligned field is also 4-aligned. So where's the problem?
I need to know why this happens.
Andrew.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __attribute__ ((aligned)) weirdness
2003-03-18 20:28 ` Andrew Haley
@ 2003-03-18 22:34 ` Andreas Tobler
2003-04-08 8:01 ` PPC support in GCC ? A.R. Ashok Kumar
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Tobler @ 2003-03-18 22:34 UTC (permalink / raw)
To: Andrew Haley; +Cc: Piotr Wyderski, gcc
Andrew Haley wrote:
> Piotr Wyderski writes:
> > > So you have a field at offset 4. You ask for it to be 4-aligned, and
> > > it jumps to offset 8.
> > >
> > > What is going on?
> >
> > The alignment of x means that the offset of a variable is divisible
> > by x with no remainder. Each y=x*2^n (where n is natural) is
> > a good alignment too, because f mod y = 0 => f mod x = 0;
> > 8-aligned field is also 4-aligned. So where's the problem?
>
> I need to know why this happens.
Could this be related? No explanation, sorry.
http://gcc.gnu.org/ml/gcc/2003-02/msg00353.html
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* PPC support in GCC ?
2003-03-18 22:34 ` Andreas Tobler
@ 2003-04-08 8:01 ` A.R. Ashok Kumar
2003-04-08 14:45 ` Falk Hueffner
0 siblings, 1 reply; 7+ messages in thread
From: A.R. Ashok Kumar @ 2003-04-08 8:01 UTC (permalink / raw)
To: gcc
Hi,
I have gcc 2.95.3 source. As per the source, there is no support for
PowerPC in GCC. But GCC website(http://gcc.gnu.org/install/specific.html)
says that the following configurations are supported in GCC,
powerpc-*-*
powerpc-*-darwin*
powerpc-*-elf, powerpc-*-sysv4
powerpc-*-linux-gnu*
powerpc-*-netbsd*
powerpc-*-eabiaix
powerpc-*-eabisim
powerpc-*-eabi
powerpcle-*-elf, powerpcle-*-sysv4
powerpcle-*-eabisim
I couldn't find any target specific config directory for PowerPC under
"gcc/config". Can any one help me?
Thanks,
-AshokA-
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PPC support in GCC ?
2003-04-08 8:01 ` PPC support in GCC ? A.R. Ashok Kumar
@ 2003-04-08 14:45 ` Falk Hueffner
2003-04-08 14:51 ` A.R. Ashok Kumar
0 siblings, 1 reply; 7+ messages in thread
From: Falk Hueffner @ 2003-04-08 14:45 UTC (permalink / raw)
To: A.R. Ashok Kumar; +Cc: gcc
"A.R. Ashok Kumar" <ashokar@sankhya.com> writes:
> I couldn't find any target specific config directory for PowerPC
> under "gcc/config".
It's integrated into rs6000.
--
Falk
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PPC support in GCC ?
2003-04-08 14:45 ` Falk Hueffner
@ 2003-04-08 14:51 ` A.R. Ashok Kumar
0 siblings, 0 replies; 7+ messages in thread
From: A.R. Ashok Kumar @ 2003-04-08 14:51 UTC (permalink / raw)
To: Falk Hueffner; +Cc: gcc
Hi,
> > I couldn't find any target specific config directory for PowerPC
> > under "gcc/config".
>
> It's integrated into rs6000.
Thanks for the info.
Does GCC has support for MPC555? If so, can you please mention which
configuration is to be used for "--target" option for building
GCC for MPC555 on HP-UX.
(I am new to PowerPC architecture).
-AshokA-
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-04-08 11:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18 16:16 g++: __attribute__ ((aligned)) weirdness Andrew Haley
2003-03-18 20:24 ` Piotr Wyderski
2003-03-18 20:28 ` Andrew Haley
2003-03-18 22:34 ` Andreas Tobler
2003-04-08 8:01 ` PPC support in GCC ? A.R. Ashok Kumar
2003-04-08 14:45 ` Falk Hueffner
2003-04-08 14:51 ` A.R. Ashok Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).