view src/parallel_execution/examples/twice/printArray.cbc @ 1031:2caac93dee00

try to compile each app independentry. move context.h to c-twice/context.h
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 24 Oct 2023 12:15:07 +0900
parents 39b5adbcd83f
children
line wrap: on
line source

#include "context.h"
#interface "Timer.h"
#include <stdio.h>

__code printArray(struct Array* array, struct Timer* inputTimer, __code next(...)){
    goto inputTimer->end(printArray1);
}

__code printArray1(struct Array* array, __code next(...), struct LoopCounter* loopCounter){
    int i = loopCounter->i;
    //printf("%d\n", array->array[i]);
    if (i < GET_LEN(array->array)) {
        if (array->array[i].value == i*2) {
            loopCounter->i++;
            goto printArray1();
        } else {
            printf("wrong result\n");
        }
    }
   loopCounter->i = 0;
    goto next(...);
}