Changeset 5452673 for doc/papers/concurrency/examples/Fib2.c
- Timestamp:
- Feb 27, 2020, 11:51:04 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 331eacbe, 37cdd97
- Parents:
- c886f4b (diff), 930b504 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Fib2.c
rc886f4b r5452673 1 1 #include <stdio.h> 2 2 3 void mary() {4 printf( "MARY\n" );5 }6 7 3 #define FIB_INIT { 0 } 8 typedef struct { int next; int fn1, fn2; } Fib;4 typedef struct { int restart; int fn1, fn2; } Fib; 9 5 int fib( Fib * f ) { 10 static void * states[] = { &&s1, &&s2, &&s3 }; 11 goto *states[f->next]; 6 static void * states[] = { &&s0, &&s1, &&s2 }; 7 goto *states[f->restart]; 8 s0: 9 f->fn1 = 0; 10 f->restart = 1; 11 return f->fn1; 12 12 s1: 13 mary();14 f->fn1 = 0;15 f->next = 1;16 return f->fn1;17 s2:18 mary();19 13 f->fn2 = f->fn1; 20 14 f->fn1 = 1; 21 f-> next = 2;15 f->restart = 2; 22 16 return f->fn1; 23 s3:; 24 mary(); 17 s2:; 25 18 int fn = f->fn1 + f->fn2; 26 19 f->fn2 = f->fn1;
Note: See TracChangeset
for help on using the changeset viewer.