compiler/clib: Rename IoErr2errno() to __arosc_ioerr2errno(); function is now defined...
[AROS.git] / compiler / clib / include / alloca.h
blob3ca37a2c0be3a975126d0de9e5b118229aa392ba
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 System header file <alloca.h>
6 */
8 #ifndef _ALLOCA_H
9 #define _ALLOCA_H
11 #include <aros/system.h>
12 #include <stddef.h>
14 /* Discard any previous definition. */
15 #undef alloca
17 __BEGIN_DECLS
19 /* Allocate a block of memory which will be automatically freed upon function exiting. */
20 extern void *alloca(size_t size);
22 /* Private function to get the upper or lower bound (depending on the architecture)
23 of the stack. */
24 extern void *__alloca_get_stack_limit(void);
25 __END_DECLS
27 /* GNU C provides a builtin alloca function. */
28 #ifdef __GNUC__
29 # if AROS_STACK_GROWS_DOWNWARDS
30 # define alloca(size) \
31 ({ \
32 ((void *)(AROS_GET_SP - AROS_ALIGN(size)) <= __alloca_get_stack_limit()) ? \
33 NULL : \
34 __builtin_alloca(size); \
36 # else
37 # define alloca(size) \
38 ({ \
39 ((void *)(AROS_GET_SP + AROS_ALIGN(size)) >= __alloca_get_stack_limit()) ? \
40 NULL : \
41 __builtin_alloca(size); \
43 # endif /* AROS_STACK_GROWS_DOWNWARDS */
44 #endif /* GCC. */
47 #endif /* alloca.h */