Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine/fibonacci.c

    r71b50f36 raf1ed1ad  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fibonacci.c -- 3-state finite-state machine
    8 
     7// fibonacci.c --
    98//
    109// Author           : Thierry Delisle
    1110// Created On       : Thu Jun  8 07:29:37 2017
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Apr 27 08:55:31 2018
    14 // Update Count     : 19
     12// Last Modified On : Thu Mar 22 22:45:44 2018
     13// Update Count     : 15
    1514//
    1615
     
    2019coroutine Fibonacci { int fn; };                                                // used for communication
    2120
    22 void main( Fibonacci & fib ) with( fib ) {                              // called on first resume
     21void ?{}( Fibonacci & fib ) with( fib ) { fn = 0; }
     22
     23// main automatically called on first resume
     24void main( Fibonacci & fib ) with( fib ) {
    2325        int fn1, fn2;                                                                           // retained between resumes
    2426        fn = 0;  fn1 = fn;                                                                      // 1st case
     
    2729        suspend();                                                                                      // restart last resume
    2830        for ( ;; ) {
    29                 fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
     31                fn = fn1 + fn2; fn2 = fn1;  fn1 = fn;                   // general case
    3032                suspend();                                                                              // restart last resume
    3133        } // for
Note: See TracChangeset for help on using the changeset viewer.