view paper/src/context.c @ 1:19917a6272f6

sigos_test
author suruga
date Thu, 20 Apr 2017 16:29:05 +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->codeNum = Code3;

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

    struct Worker* worker = ALLOC_DATA(context, Worker);
    worker->num = 0;
    worker->contexts = 0;

    struct Allocate* allocate = ALLOC_DATA(context, Allocate);
    allocate->size = 0;

    struct Tree* tree = ALLOC_DATA(context, Tree);
    tree->root = 0;

    struct Node* node = ALLOC_DATA(context, Node);
    node->key = 0;
    node->value = 0;
    node->left = 0;
    node->right = 0;
}