public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mo McKinlay <mmckinlay@labs.interopen.org>
To: rlau@csc.com
Cc: gcc@gcc.gnu.org
Subject: Re: alloca()
Date: Tue, 21 Mar 2000 13:21:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.04.10003212112330.10384-100000@inet-gw0.labs.ekto.org> (raw)
In-Reply-To: <852568A9.0073A9A6.00@csc.com>

# I have cygwin32 and gcc/g77 and use it to compile some FORTRAN code.  Does
# anyone know where alloca() comes from?
# I heard that alloca() is built-in, but does that eventually calls something that
# is inherent to MICROSOFT or Kernel32 libraries?

I recently looked into this as part of our Synergist project, and I as far
as I could muster (bear in mind I'm working in C, not FORTRAN), the C
libraries declare alloca as:

extern void *alloca(size_t len);

(or similar).

GCC then catches this and uses the builtin instead. My best guess is that
because of the nature of alloca(), it has to be a builtin, or at the
outset, a macro -- I'm not too hot on the exact semantics of function
prolog/epilog code and stack state, but the prospect of reserving memory
on the caller of the current function's stack got me so confused I gave up
:-)

As far as I know, all the other C compilers do pretty much the same thing
(including MSVC++, Borland C++, and so on).

As g77 uses gcc as it's back end, I'd guess that declaring a function
called alloca using C calling/naming conventions (how you do this in
FORTRAN I have no idea), and let the compiler manage it. If you get link
errors, I've missed something, and if it just crashes horribly when you
run your program, it's something to do with the state that g77 puts the
stack into.

If anybody could shed any more light onto alloca(), I'd like to feast on
you knowledge :-)

Hope this helps (at all!)

-- 
Mo McKinlay                                T: +44 (0) 709 22 55 05  x1
Chief Software Architect                   F: +44 (0) 709 22 55 05  x3
inter/open                                 E: mmckinlay@labs.interopen.org
A division of Bekon Marketing Limited      W: http://www.interopen.org

      reply	other threads:[~2000-03-21 13:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-21 13:03 alloca() rlau
2000-03-21 13:21 ` Mo McKinlay [this message]

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=Pine.LNX.4.04.10003212112330.10384-100000@inet-gw0.labs.ekto.org \
    --to=mmckinlay@labs.interopen.org \
    --cc=gcc@gcc.gnu.org \
    --cc=rlau@csc.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).