comparison src/initContext.c @ 4:52eec0b77576

Gears OS: allocate
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 09 Feb 2016 04:21:34 +0900
parents
children
comparison
equal deleted inserted replaced
3:0fa000320b6a 4:52eec0b77576
1 #include <stdlib.h>
2
3 #include "context.h"
4
5 extern __code code1_stub(struct Context*);
6 extern __code code2_stub(struct Context*);
7 extern __code allocator_stub(struct Context*);
8 extern __code exit_code(struct Context*);
9
10 __code initContext(struct Context* context, int num) {
11 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
12 context->heapStart = malloc(context->heapLimit);
13 context->heap = context->heapStart;
14 context->codeNum = Exit;
15
16 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
17 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
18
19 context->code[Code1] = code1_stub;
20 context->code[Code2] = code2_stub;
21 context->code[Allocator] = allocator_stub;
22 context->code[Exit] = exit_code;
23
24 context->data[Allocate] = context->heap;
25 context->heap += sizeof(struct Allocate);
26
27 context->dataNum = Allocate;
28 }