Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/concurrency/examples/Fib2.c

    ra573c22 r466fa01  
    11#include <stdio.h>
    22
     3void mary() {
     4        printf( "MARY\n" );
     5}
     6
    37#define FIB_INIT { 0 }
    4 typedef struct { int restart; int fn1, fn2; } Fib;
     8typedef struct { int next; int fn1, fn2; } Fib;
    59int fib( Fib * f ) {
    6         static void * states[] = { &&s0, &&s1, &&s2 };
    7         goto *states[f->restart];
    8   s0:
     10        static void * states[] = { &&s1, &&s2, &&s3 };
     11        goto *states[f->next];
     12  s1:
     13        mary();
    914        f->fn1 = 0;
    10         f->restart = 1;
     15        f->next = 1;
    1116        return f->fn1;
    12   s1:
     17  s2:
     18        mary();
    1319        f->fn2 = f->fn1;
    1420        f->fn1 = 1;
    15         f->restart = 2;
     21        f->next = 2;
    1622        return f->fn1;
    17   s2:;
     23  s3:;
     24        mary();
    1825        int fn = f->fn1 + f->fn2;
    1926        f->fn2 = f->fn1;
Note: See TracChangeset for help on using the changeset viewer.