Linux PARISC architecture development
 help / color / mirror / Atom feed
From: "Michael S. Zick" <mszick@morethan.org>
To: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] Re: Looking at vfprintf.c and alloca.
Date: Tue, 18 Jul 2006 11:51:52 -0500	[thread overview]
Message-ID: <200607181151.53069.mszick@morethan.org> (raw)
In-Reply-To: <44BD0369.3090905@tausq.org>

On Tue July 18 2006 10:51, Randolph Chung wrote:
> Carlos O'Donell wrote:
> > I was looking at our tst-printfsz failures in glibc, and I noticed
> > some very cute code in vfprintf.c. The code uses alloca to create a
> > specs structure, and then using certain know addresses decides if the
> > stack grows down or up.
> > 
> > Does this look right? Anyone care to review if this actually works
> > with a newer GCC on hppa?
> 
> I tried this with both old (gcc-3.[34]) and new gcc (gcc-4.[01]) and i 
> don't think this works....
> 
> tausq@riot:~$ cat alloca.c
> #include <alloca.h>
> #include <stdio.h>
> 
> int main(int argc, char **argv)
> {
>          int *old;
>          int *ptr = alloca(100 * sizeof(int));
> 
>          old = ptr;
> 
>          ptr = alloca(100 * sizeof(int));
> 
>          printf("ptr = %p\nold = %p\n&old[100] = %p\n", ptr, old, 
> &old[100]);
>          return 0;
> }
> tausq@riot:~$ gcc-4.1 -Wall -o alloca alloca.c; ./alloca
> ptr = 0xc04ca590
> old = 0xc04ca3d0
> &old[100] = 0xc04ca560
> 

For the case of gcc-4.2, stack-grows down...

ptr = 0xbfea1fc0
old = 0xbfea2160
&old[100] = 0xbfea22f0

In both the cases (up/down) &old[100] has an offset of
400 bytes (correct).

There is some compiler generated, machine dependent,
optimization dependent, space between "ptr" and "old[100]"
Most likely the "guaranteed stack alignment" thingy.

Mike
> randolph
> _______________________________________________
> parisc-linux mailing list
> parisc-linux@lists.parisc-linux.org
> http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
> 
> 
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

  reply	other threads:[~2006-07-18 16:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-18  3:40 [parisc-linux] Looking at vfprintf.c and alloca Carlos O'Donell
2006-07-18 15:51 ` [parisc-linux] " Randolph Chung
2006-07-18 16:51   ` Michael S. Zick [this message]
2006-07-19  3:22     ` John David Anglin
2006-07-18 19:30   ` Carlos O'Donell
2006-07-18 20:11     ` Michael S. Zick
2006-07-18 20:22     ` Matthew Wilcox
2006-07-18 20:49       ` Carlos O'Donell
2006-07-19  2:48   ` John David Anglin
2006-07-19  3:04     ` Randolph Chung
2006-07-19 15:22       ` Michael S. Zick
2006-07-20  4:54         ` John David Anglin
2006-07-19  2:36 ` John David Anglin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200607181151.53069.mszick@morethan.org \
    --to=mszick@morethan.org \
    --cc=parisc-linux@lists.parisc-linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox