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