alloca.in.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Memory allocation on the stack.
  2. Copyright (C) 1995, 1999, 2001-2004, 2006-2011 Free Software Foundation,
  3. Inc.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  15. USA. */
  16. /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
  17. means there is a real alloca function. */
  18. #ifndef _GL_ALLOCA_H
  19. #define _GL_ALLOCA_H
  20. /* alloca (N) returns a pointer to N bytes of memory
  21. allocated on the stack, which will last until the function returns.
  22. Use of alloca should be avoided:
  23. - inside arguments of function calls - undefined behaviour,
  24. - in inline functions - the allocation may actually last until the
  25. calling function returns,
  26. - for huge N (say, N >= 65536) - you never know how large (or small)
  27. the stack is, and when the stack cannot fulfill the memory allocation
  28. request, the program just crashes.
  29. */
  30. #ifndef alloca
  31. # ifdef __GNUC__
  32. # define alloca __builtin_alloca
  33. # elif defined _AIX
  34. # define alloca __alloca
  35. # elif defined _MSC_VER
  36. # include <malloc.h>
  37. # define alloca _alloca
  38. # elif defined __DECC && defined __VMS
  39. # define alloca __ALLOCA
  40. # else
  41. # include <stddef.h>
  42. # ifdef __cplusplus
  43. extern "C"
  44. # endif
  45. void *alloca (size_t);
  46. # endif
  47. #endif
  48. #endif /* _GL_ALLOCA_H */