blackhole.c
changeset 0 af501b0c1716
child 9 c3fecc82ade6
equal deleted inserted replaced
-1:000000000000 0:af501b0c1716
       
     1 /*
       
     2  *     $Id: blackhole.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
       
     3  * $Source: /development/c/demos/blackhole.c,v $
       
     4  */
       
     5 
       
     6 /* compile with -O0 or without optimizations or it won't crash */
       
     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 }