- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Fib2.c
ra573c22 r466fa01 1 1 #include <stdio.h> 2 2 3 void mary() { 4 printf( "MARY\n" ); 5 } 6 3 7 #define FIB_INIT { 0 } 4 typedef struct { int restart; int fn1, fn2; } Fib;8 typedef struct { int next; int fn1, fn2; } Fib; 5 9 int 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(); 9 14 f->fn1 = 0; 10 f-> restart = 1;15 f->next = 1; 11 16 return f->fn1; 12 s1: 17 s2: 18 mary(); 13 19 f->fn2 = f->fn1; 14 20 f->fn1 = 1; 15 f-> restart = 2;21 f->next = 2; 16 22 return f->fn1; 17 s2:; 23 s3:; 24 mary(); 18 25 int fn = f->fn1 + f->fn2; 19 26 f->fn2 = f->fn1;
Note:
See TracChangeset
for help on using the changeset viewer.