view src/parallel_execution/examples/twice/createArray.cbc @ 468:ac244346c85d

Change used interface syntax from #include to #interface
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 25 Dec 2017 18:10:56 +0900
parents 7d67c9cf09ee
children
line wrap: on
line source

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

extern int length;
extern int split;

__code createArray(__code next(struct Array* output, struct Timer* output1, ...), struct LoopCounter* loopCounter) {
    struct Array* output = *O_output;
    struct Timer* output1 = *O_output1;
    int i = loopCounter->i;
    if (i == 0){
        output->array = (Int*)ALLOCATE_ARRAY(context, Int, length);
        output->prefix = length/split;
    }
    if (i == GET_LEN(output->array)){
        printf("created Array\n");
        loopCounter->i = 0;
        *O_output = output;
        *O_output1 = output1;
        goto output1->start(next(...));
    }
    output->array[i] = i;
    loopCounter->i++;
    *O_output = output;
    *O_output1 = output1;
    goto meta(context, C_createArray);
}

__code createArray_stub(struct Context* context) {
    Array** O_output = (struct Array **)&context->data[context->odg];
    Timer** O_output1 = (struct Timer**)&context->data[context->odg+1];
    goto createArray(context,
            context->next,
            O_output,
            O_output1,
            Gearef(context, LoopCounter));
}