tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: alloca() declaration



On 08/25/2012 02:48 PM, Christos Zoulas wrote:
In article <50387B13.4020709%ludd.ltu.se@localhost>,
Anders Magnusson  <ragge%ludd.ltu.se@localhost> wrote:
I noticed that there is a difference between whether alloca() is in libc
or not for our ports.
arm, i386, m68k, vax, amd64 has the functions, others not.

Also, the stuff in is not correct either:

#if defined(alloca) && (alloca == __builtin_alloca) && \
     defined(__GNUC__) && (__GNUC__ < 2)
void    *alloca(int);     /* built-in for gcc */
#elif defined(__PCC__) && !defined(__GNUC__)
#define alloca(size) __builtin_alloca(size)
#else
void    *alloca(size_t);
#endif /* __GNUC__ */

besides the fact that string comparison is not possible in cpp this
would in fact usually just end up in declaring alloca().

This means that alloca won't be available if using gcc -std=c99 on a
bunch of ports, which is not the desired behavior.

One way to solve this would be to replace the stuff above with:
#if defined(__GNUC__)
#define alloca(size) __builtin_alloca(size)
#endif

so that gcc always uses the builtin alloca.

Comments?
That will break gcc-1.x, but we don't support it :-)
Please go ahead and simplify it. Don't you need a #else
void *alloca(size_t)?
Yes, of course :-)  Thanks.

-- Ragge



Home | Main Index | Thread Index | Old Index