[RFA]: Add declaration for `alloca' to stdlib.h
Wed Jan 10 22:41:00 GMT 2001
Corinna Vinschen wrote:
> newlib omits a declaration for alloca() in stdlib.h as it's described
> e.g. in the Linux man pages.
> The following patch to libc/include/stdlib.h does that. It declares
> alloca() as external unless __GNUC__ is defined. In that case alloca()
> is defined as __builtin_alloca().
> Another way to implement that would be to include <alloca.h> if the
> system has that file (as e.g. for linux in libc/sys/linux/include).
> If you prefer that, I will propose another patch which only includes
> alloca.h for Linux and Cygwin and add a alloca.h file to libc/sys/cygwin.
This is a BSD-extension, it is not ANSI, POSIX, nor Single Unix.
It should be protected from __STRICT_ANSI__ applications.
IMO, the file from libc/sys/linux/include could be copied to the common
include directory with an added __GNUC__ check. There is no reason that
other platforms couldn't use this functionality as well.
The stdlib.h directory should include <alloca.h> only if not
-- Jeff J.
> 2001-11-12 Corinna Vinschen <email@example.com>
> * libc/include/stdlib.h: Add declaration for alloca().
> Index: libc/include/stdlib.h
> RCS file: /cvs/src/src/newlib/libc/include/stdlib.h,v
> retrieving revision 1.11
> diff -u -p -r1.11 stdlib.h
> --- stdlib.h 2001/10/01 18:05:09 1.11
> +++ stdlib.h 2001/11/12 12:50:04
> @@ -45,6 +45,12 @@ extern __IMPORT int __mb_cur_max;
> _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn)));
> int _EXFUN(abs,(int));
> +#ifdef __GNUC__
> +#define alloca(size) __builtin_alloca(size)
> +void * _EXFUN(alloca,(size_t));
> int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
> double _EXFUN(atof,(const char *__nptr));
> #ifndef __STRICT_ANSI__
> Corinna Vinschen
> Cygwin Developer
> Red Hat, Inc.
More information about the Newlib