view src/context.c @ 0:85ee6174f90a default tip

add paper
author ryokka
date Wed, 12 Feb 2020 17:55:00 +0900
parents
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);
}