public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: xm-alpha.h alloca patch
@ 1997-08-19 19:45 Fred Fish
  0 siblings, 0 replies; 2+ messages in thread
From: Fred Fish @ 1997-08-19 19:45 UTC (permalink / raw)
  To: egcs

> ! /* If compiled with GNU C, use the builtin alloca.  */
> ! #ifdef __GNUC__
> ! #undef alloca
> ! #define alloca  __builtin_alloca
> ! #else

This sequence appears rather pervasively in current GNU code.  The
problem with it, is it assumes that if you are using GNU C that you
always want to use the stack based built in alloca.  I believe that
the code should not be making this assumption.  There are systems
where stack space is limited while heap space is virtually unlimited,
and the C based alloca is a better choice if you want to continue
using alloca.

A good example is the highly threaded BeOS, where the original default
was 64K of nonexpandable stack (recently been changed to 256K of
nonexpandable stack).

It seems that for current gcc's, this define isn't even necessary,
since the default is to automatically remap alloca() calls to
__builtin_alloca, unless -fno-builtin is given (or is set up to be the
default).  For the BeOS port, I made -fno-builtin be the default,
though there is probably a better way to disable this automatic
conversion.  Then I had to go through all the GNU utils and fix all
the places where the code made the above assumption.  At one point I
sent mail to rms about this and he agreed that unconditionally
defining alloca to __builtin_alloca for GNU C was the wrong thing to
do.

One possibility is to change it to be:

	#if defined (__GNUC__) && !defined (C_ALLOCA)
	#undef alloca
	#define alloca  __builtin_alloca
	#else

Then, if in a particular configuration, gcc does not automatically
remap alloca to __builtin_alloca, the autoconf tests for alloca will
fail to find a working alloca, the package will substitute the C based
alloca, and the code will refrain from undoing this work.

Another option of course is to simply remove all instances of
#defining alloca to be __builtin_alloca.  But I recently ran into a
problem with that when some other gcc option (besides -fno-builtin)
disabled the automatic use of __builtin_alloca and the package was not
prepared to substitute the C based alloca.  I forget now just what
option that was.

-Fred

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

* xm-alpha.h alloca patch
@ 1997-08-19 19:00 Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 1997-08-19 19:00 UTC (permalink / raw)
  To: egcs

GCC & G77 do not correctly bootstrap due to redefinitions of alloca.


r~


Tue Aug 19 11:49:54 1997  Richard Henderson  <rth@cygnus.com>

	* config/alpha/xm-alpha.h: Do the right thing with __GNUC__ and alloca.


diff -rpc2 -x CVS egcs/config/alpha/xm-alpha.h egcs-work/config/alpha/xm-alpha.h
*** egcs/config/alpha/xm-alpha.h	Mon Aug 18 08:49:48 1997
--- egcs-work/config/alpha/xm-alpha.h	Mon Aug 18 12:14:18 1997
*************** Boston, MA 02111-1307, USA.  */
*** 42,50 ****
  #define	FATAL_EXIT_CODE		33
  
! /* If not compiled with GNU C, use the builtin alloca.  */
! #if !defined(__GNUC__) && !defined(_WIN32)
  #include <alloca.h>
  #else
  extern void *alloca ();
  #endif
  
--- 42,55 ----
  #define	FATAL_EXIT_CODE		33
  
! /* If compiled with GNU C, use the builtin alloca.  */
! #ifdef __GNUC__
! #undef alloca
! #define alloca  __builtin_alloca
! #else
! #ifndef _WIN32
  #include <alloca.h>
  #else
  extern void *alloca ();
+ #endif
  #endif
  

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

end of thread, other threads:[~1997-08-19 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-19 19:45 xm-alpha.h alloca patch Fred Fish
  -- strict thread matches above, loose matches on Subject: below --
1997-08-19 19:00 Richard Henderson

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