* memory alignment question
@ 2002-03-25 6:56 Guillaume Morin
0 siblings, 0 replies; 2+ messages in thread
From: Guillaume Morin @ 2002-03-25 6:56 UTC (permalink / raw)
To: gcc-help
Hi folks,
I am trying to get some memory aligned on a quad word on the stack for
Altivec.
I made this program :
#include <stdio.h>
int main(void) {
int tab[6][64] __attribute__ ((__aligned__(16)));
printf("%p\n",&tab);
return 0;
}
Unfortunately, when I run this program on PPC or x86, I never got
something aligned on 16 bytes.
e.g
guillaum@siri:~/dev/c/try$ ./uffu
0x7ffff328
guillaum@cedar ~$ ./try
tab == 0xbffff8cc
I tried with gcc 2.95 or gcc 3.0.x, ld version 2.12.90.0.1 or 2.9.5.
Am I missing something ? Sorry if it is obvious, I am new to this kind
of problems. I tried to RTFM before asking, got no results.
TIA. Regards,
--
Guillaume Morin <guillaume@morinfr.org>
A friend in need is a friend indeed. A friend who bleeds is better.
My friend confessed, she passed the test. We will never sever.
(Placebo)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Memory Alignment question.
@ 2004-07-22 13:20 Barlad
0 siblings, 0 replies; 2+ messages in thread
From: Barlad @ 2004-07-22 13:20 UTC (permalink / raw)
To: gcc-help
Greetings everyone,
I am using gcc 3.3.4 on a pentium M and noticed a
behaviour in memory allocation that confused me. So
far, the only thing I knew of memory
allocation/alignment was this: memory areas can only
be addressed by a multiple of the word size (in my
case a word is 4 bytes).
I did some testing to verify what I knew was correct
and was proved totally wrong. Here are two basic
examples
void function() {
char buffer1;
char buffer2;
}
Only 4 bytes are allocated for buffer1 & buffer2 (sub
$0x4 %esp) while I would have expected 8 bytes.
Someone told me it was for memory optimization which
seems rational but then... I guess one of the buffer
cannot be addressed by a multiple of 4 bytes, right?
Is not it a problem?
There is something even more confusing. I have been
chewing on it for a few days and came up with no
possible explanation. Take this:
void function() {
char buffer1[5];
char buffer2[6];
}
28 bytes are allocated for both buffers! I would have
expected 16 at most (8 for each). I did other tests
and came up with as surprising results.
Could anyone explain me how this works please and/or
point me to some documentation concerning this?
Thanks in advance,
Barlad.
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Yahoo! Messenger: dialoguez instantanément avec vos amis. Téléchargez GRATUITEMENT sur http://fr.messenger.yahoo.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-22 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-25 6:56 memory alignment question Guillaume Morin
2004-07-22 13:20 Memory Alignment question Barlad
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).