blob: e028166b60876e27cad77add778e1cd7470761de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/* Origin: hp@bitrange.com
Test that return values come out right from a 1000-level call chain to
functions without parameters that each need at least one "long"
preserved. Exposed problems related to the MMIX port. */
long level = 0;
extern long foo (void);
extern long bar (void);
#ifdef STACK_SIZE
#define DEPTH ((STACK_SIZE) / 512 + 1)
#else
#define DEPTH 500
#endif
int
main (void)
{
if (foo () == -42)
exit (0);
abort ();
}
long
foo (void)
{
long tmp = ++level;
return bar () + tmp;
}
long
bar (void)
{
long tmp = level;
return tmp > DEPTH - 1 ? -42 - tmp : foo () - tmp;
}
|