source: doc/papers/concurrency/examples/Fib.c @ e116db3

ADTast-experimentalpthread-emulation
Last change on this file since e116db3 was 600d7be, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

example updates

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