1 /* Test of c-stack module.
2 Copyright (C) 2002, 2004, 2006, 2008 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 # include <sys/resource.h>
28 #define ASSERT(expr) \
33 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
45 return *p + recurse (array);
51 main (int argc, char **argv)
53 program_name = argv[0];
54 #if HAVE_SETRLIMIT && defined RLIMIT_STACK
55 /* Before starting the endless recursion, try to be friendly to the
56 user's machine. On some Linux 2.2.x systems, there is no stack
57 limit for user processes at all. We don't want to kill such
60 rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */
61 setrlimit (RLIMIT_STACK, &rl);
64 if (c_stack_action (0) == 0)
65 return recurse ("\1");
66 perror ("c_stack_action");