From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fred Fish To: egcs@cygnus.com Subject: Re: xm-alpha.h alloca patch Date: Tue, 19 Aug 1997 19:45:02 -0000 Message-id: <199708191958.MAA17720@ninemoons.com> In-reply-to: 199708191854.LAA15143@rtl.cygnus.com X-SW-Source: 1997-08/0191.html > ! /* 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