view Paper/src/context.c @ 1:aa9a59aea7fa

fix
author mir3636
date Thu, 23 Nov 2017 19:33:17 +0900
parents dbbe5ef644fb
children
line wrap: on
line source

#include <stdlib.h>

#include "context.h"

extern __code code1_stub(struct Context*);
extern __code code2_stub(struct Context*);
extern __code code3_stub(struct Context*);

__code initContext(struct Context* context) {
    context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
    context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
    context->data = NEWN(ALLOCATE_SIZE, union Data*);
    context->heapStart = NEWN(context->heapLimit, char);
    context->heap = context->heapStart;

    context->code[Code1]      = code1_stub;
    context->code[Code2]      = code2_stub;
    context->code[Code3]      = code3_stub;

#include "dataGearInit.c"
    context->dataNum = 39;
    context->tasks = createSingleLinkedQueue(context);
}