alloca.m4 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # alloca.m4 serial 11
  2. dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
  3. dnl Inc.
  4. dnl This file is free software; the Free Software Foundation
  5. dnl gives unlimited permission to copy and/or distribute it,
  6. dnl with or without modifications, as long as this notice is preserved.
  7. AC_DEFUN([gl_FUNC_ALLOCA],
  8. [
  9. AC_REQUIRE([AC_FUNC_ALLOCA])
  10. if test $ac_cv_func_alloca_works = no; then
  11. gl_PREREQ_ALLOCA
  12. fi
  13. # Define an additional variable used in the Makefile substitution.
  14. if test $ac_cv_working_alloca_h = yes; then
  15. AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
  16. AC_EGREP_CPP([Need own alloca], [
  17. #if defined __GNUC__ || defined _AIX || defined _MSC_VER
  18. Need own alloca
  19. #endif
  20. ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
  21. ])
  22. if test $gl_cv_rpl_alloca = yes; then
  23. dnl OK, alloca can be implemented through a compiler built-in.
  24. AC_DEFINE([HAVE_ALLOCA], [1],
  25. [Define to 1 if you have 'alloca' after including <alloca.h>,
  26. a header that may be supplied by this distribution.])
  27. ALLOCA_H=alloca.h
  28. else
  29. dnl alloca exists as a library function, i.e. it is slow and probably
  30. dnl a memory leak. Don't define HAVE_ALLOCA in this case.
  31. ALLOCA_H=
  32. fi
  33. else
  34. ALLOCA_H=alloca.h
  35. fi
  36. AC_SUBST([ALLOCA_H])
  37. AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
  38. ])
  39. # Prerequisites of lib/alloca.c.
  40. # STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
  41. AC_DEFUN([gl_PREREQ_ALLOCA], [:])