alloca.in.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Memory allocation on the stack.
  2. Copyright (C) 1995, 1999, 2001-2004, 2006-2017 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, see
  14. <http://www.gnu.org/licenses/>.
  15. */
  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. # elif defined __TANDEM && defined _TNS_E_TARGET
  41. # ifdef __cplusplus
  42. extern "C"
  43. # endif
  44. void *_alloca (unsigned short);
  45. # pragma intrinsic (_alloca)
  46. # define alloca _alloca
  47. # elif defined __MVS__
  48. # include <stdlib.h>
  49. # else
  50. # include <stddef.h>
  51. # ifdef __cplusplus
  52. extern "C"
  53. # endif
  54. void *alloca (size_t);
  55. # endif
  56. #endif
  57. #endif /* _GL_ALLOCA_H */