Mercurial > hg > Members > Moririn
view src/allocate/allocate.c @ 235:05e61405cc88
fix worker compile error
author | mir3636 |
---|---|
date | Mon, 23 Jan 2017 17:49:36 +0900 |
parents | 1eb599acffe4 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "allocateContext.h" #include "allocate.h" #include "origin_cs.h" #ifdef CLANG #define _CbC_retrun __return #define _CbC_environment __environment #endif #define NUM 100 #define ALLOCATE_SIZE 1024 extern __code initAllocateContext(struct Context* context); /* __code code1(Allocate allocate) { allocate.size = sizeof(long); allocate.next = Code2; goto Allocate(allocate); } */ __code code1(struct Context* context) { context->data[0]->allocate.size = sizeof(long); context->data[0]->allocate.next = Code2; goto meta(context, Allocate); } __code meta(struct Context* context, enum Code next) { goto (context->code[next])(context); } /* __code code2(Allocate allocate, Count count) { count.count = 0; goto code3(count); } */ __code code2(struct Context* context) { context->data[1]->count = 0; goto meta(context, Code3); } __code code3(struct Context* context) { long loop = context->data[1]->count; if (loop == NUM) { goto meta(context, Exit); } printf("%ld\n", loop); context->data[1]->count++; goto meta(context, Code3); } int main() { struct Context* context = (struct Context*)malloc(sizeof(struct Context)); context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); context->data = malloc(sizeof(union Data**)*ALLOCATE_SIZE); context->heap = malloc(sizeof(union Data*)*ALLOCATE_SIZE); initAllocateContext(context); goto start_code(context, Code1); }