00001
00002
00003
00004
00005
00006
00007 #ifndef _ONSTACK_H_
00008 #define _ONSTACK_H_
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if HAVE_ALLOCA
00024
00025
00026
00027
00028 #if defined(__GNUC__)
00029 # if !defined(alloca)
00030 # define alloca __builtin_alloca
00031 # endif
00032 #else
00033 # if HAVE_ALLOCA_H
00034 # include <alloca.h>
00035 # elif defined(_AIX)
00036 # pragma alloca
00037 # endif
00038 #endif
00039
00040 # if !defined(ALLOCA_ARG_T)
00041 # define ALLOCA_ARG_T int
00042 # endif
00043
00044 # define ALLOC_ONSTACK(name, type, nelems) \
00045 type *const name = (type *) alloca((ALLOCA_ARG_T)((nelems) * sizeof(type)))
00046
00047 # define FREE_ONSTACK(name)
00048
00049 #elif defined(_CRAYC) && !__cplusplus && __STDC__ > 1
00050
00051
00052
00053
00054 # define ALLOC_ONSTACK(name, type, nelems) \
00055 type name[nelems]
00056
00057 # define FREE_ONSTACK(name)
00058
00059 #else
00060
00061
00062
00063
00064 # define ALLOC_ONSTACK(name, type, nelems) \
00065 type *const name = (type *) malloc((nelems) * sizeof(type))
00066
00067 # define FREE_ONSTACK(name) \
00068 free(name)
00069
00070 #endif
00071
00072 #endif