This source file includes following definitions.
- recurse_1
- recurse
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #include "c-stack.h"
20
21 #include "exitfail.h"
22 #include <stdio.h>
23 #if HAVE_SETRLIMIT
24
25
26 # include <sys/types.h>
27 # include <sys/time.h>
28 # include <sys/resource.h>
29 #endif
30
31 #include "macros.h"
32
33 static volatile int *
34 recurse_1 (volatile int n, volatile int *p)
35 {
36 if (n >= 0)
37 *recurse_1 (n + 1, p) += n;
38 return p;
39 }
40
41 static int
42 recurse (volatile int n)
43 {
44 int sum = 0;
45 return *recurse_1 (n, &sum);
46 }
47
48 int
49 main (int argc, char **argv)
50 {
51 #if HAVE_SETRLIMIT && defined RLIMIT_STACK
52
53
54
55
56 struct rlimit rl;
57 rl.rlim_cur = rl.rlim_max = 0x100000;
58 setrlimit (RLIMIT_STACK, &rl);
59 #endif
60
61 if (c_stack_action (NULL) == 0)
62 {
63 if (1 < argc)
64 {
65 exit_failure = 77;
66 ++*argv[argc];
67 }
68 return recurse (0);
69 }
70 fputs ("skipping test: ", stderr);
71 perror ("c_stack_action");
72 return 77;
73 }