source: doc/papers/concurrency/examples/Fib.c@ 9131e54

ADT arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 9131e54 was 17c6c1c3, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

add more paper examples

  • Property mode set to 100644
File size: 405 bytes
Line 
1#include <stdio.h>
2
3#define FIB_INIT { 0, 1 }
4typedef struct { int fn1, fn; } Fib;
5int fib( Fib * f ) {
6
7 int ret = f->fn1;
8 f->fn1 = f->fn;
9 f->fn = ret + f->fn;
10
11 return ret;
12}
13int main() {
14 Fib f1 = FIB_INIT, f2 = FIB_INIT;
15 for ( int i = 0; i < 10; i += 1 ) {
16 printf( "%d %d\n", fib( &f1 ), fib( &f2 ) );
17 }
18}
19
20// Local Variables: //
21// tab-width: 4 //
22// compile-command: "gcc Fib.c" //
23// End: //
Note: See TracBrowser for help on using the repository browser.