pandora_stack_direction.m4 1011 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. dnl Copyright (C) 2009 Sun Microsystems
  2. dnl This file is free software; Sun Microsystems
  3. dnl gives unlimited permission to copy and/or distribute it,
  4. dnl with or without modifications, as long as this notice is preserved.
  5. #--------------------------------------------------------------------
  6. # Check what direction the stack runs in
  7. #--------------------------------------------------------------------
  8. AC_DEFUN([PANDORA_STACK_DIRECTION],[
  9. AC_REQUIRE([AC_FUNC_ALLOCA])
  10. AC_CACHE_CHECK([stack direction], [ac_cv_c_stack_direction],[
  11. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  12. #include <stdlib.h>
  13. int find_stack_direction ()
  14. {
  15. static char *addr = 0;
  16. auto char dummy;
  17. if (addr == 0)
  18. {
  19. addr = &dummy;
  20. return find_stack_direction ();
  21. }
  22. else
  23. return (&dummy > addr) ? 1 : -1;
  24. }
  25. ]],[[
  26. exit (find_stack_direction() < 0);
  27. ]])],[
  28. ac_cv_c_stack_direction=1
  29. ],[
  30. ac_cv_c_stack_direction=-1
  31. ])
  32. ])
  33. AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
  34. ])