view src/parallel_execution/examples/add.cbc @ 370:59c694722ce6

Rename Code Gears
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Thu, 06 Jul 2017 16:40:02 +0900
parents src/parallel_execution/examples/Add.cbc@b07078bd1f2c
children
line wrap: on
line source

#include "../../context.h"
#include <stdio.h>
__code add(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
    struct Integer* output = *O_output;
    output->value = input1->value + input2->value;
    printf("%d + %d = %d\n", input1->value, input2->value, output->value);
    *O_output = output;
    goto meta(context, next);
}

__code add_stub(struct Context* context) {
    Integer** O_output = (struct Integer **)&context->data[context->odg];
    goto add(context,
            &context->data[context->idg]->Integer,
            &context->data[context->idg + 1]->Integer,
            context->next,
            O_output);
}