view Paper/src/context.c @ 15:4c7666f60b9b

fix
author mir3636
date Sat, 23 Dec 2017 18:15:08 +0900
parents aa9a59aea7fa
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);
}