public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* alloca()
@ 2000-03-21 13:03 rlau
  2000-03-21 13:21 ` alloca() Mo McKinlay
  0 siblings, 1 reply; 2+ messages in thread
From: rlau @ 2000-03-21 13:03 UTC (permalink / raw)
  To: gcc

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?

If gcc is not using anything from MICROSOFT libraries, how can I find it.  I
have looked the the symbol table for all the libraries
that come with cygwin32, but could not find where alloca is actually
implemented.

alloca() is a cool function because it allocates memory from the stack segment -
for those of you interesed in alloca.


Thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: alloca()
  2000-03-21 13:03 alloca() rlau
@ 2000-03-21 13:21 ` Mo McKinlay
  0 siblings, 0 replies; 2+ messages in thread
From: Mo McKinlay @ 2000-03-21 13:21 UTC (permalink / raw)
  To: rlau; +Cc: gcc

# 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-03-21 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-21 13:03 alloca() rlau
2000-03-21 13:21 ` alloca() Mo McKinlay

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).