alloca.in.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Memory allocation on the stack.
  2. Copyright (C) 1995, 1999, 2001-2007 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /* When this file is included, it may be preceded only by preprocessor
  14. declarations. Thanks to AIX. Therefore we include it right after
  15. "config.h", not later. */
  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 (void* or char*) to N bytes of memory
  21. allocated on the stack, and 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. # else
  34. # ifdef _MSC_VER
  35. # include <malloc.h>
  36. # define alloca _alloca
  37. # else
  38. # if HAVE_ALLOCA_H
  39. # include <alloca.h>
  40. # else
  41. # ifdef _AIX
  42. #pragma alloca
  43. # else
  44. # ifdef __hpux /* This section must match that of bison generated files. */
  45. # ifdef __cplusplus
  46. extern "C" void *alloca (unsigned int);
  47. # else /* not __cplusplus */
  48. extern void *alloca ();
  49. # endif /* not __cplusplus */
  50. # else /* not __hpux */
  51. # ifndef alloca
  52. extern char *alloca ();
  53. # endif
  54. # endif /* __hpux */
  55. # endif
  56. # endif
  57. # endif
  58. # endif
  59. #endif
  60. #endif /* _GL_ALLOCA_H */