author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 17:58:02 +0100 | |
changeset 9 | c3fecc82ade6 |
parent 0 | af501b0c1716 |
child 77 | 49e0babccb23 |
permissions | -rw-r--r-- |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
1 |
/** |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
2 |
* test/demos/blackhole.c |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
4 |
* |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
5 |
* compile with -O0 or without optimizations or it won't crash |
0 | 6 |
*/ |
7 |
||
8 |
#include <stdio.h> |
|
9 |
#include <stdlib.h> |
|
10 |
||
11 |
unsigned long blackhole (unsigned long i) |
|
12 |
{ |
|
13 |
/* |
|
14 |
* blackhole stops after a datatype overrun |
|
15 |
*/ |
|
16 |
if ((i + 1) < i) |
|
17 |
return i; |
|
18 |
||
19 |
if (!(i % 10000)) |
|
20 |
printf ("Recursion %lu\n", i); |
|
21 |
||
22 |
return blackhole (i + 1); |
|
23 |
} |
|
24 |
||
25 |
int main (void) |
|
26 |
{ |
|
27 |
printf ("MAXIMUM RECURSION DEPTH ON YOUR MACHINE: %lu\n", blackhole (0)); |
|
28 |
||
29 |
return EXIT_SUCCESS; |
|
30 |
} |