Mercurial > hg > Papers > 2017 > ikkun-sigos
view paper/src/context.h @ 35:7c5d27175aa4 default tip
fix
author | ikkun |
---|---|
date | Tue, 16 May 2017 16:19:47 +0900 |
parents | 38b037c42c34 |
children |
line wrap: on
line source
/* define context */ #define ALLOCATE_SIZE 20000000 #define NEWN(n, type) (type*)(calloc(n, sizeof(type))) #define ALLOC_DATA(context, dseg) ({ context->data[dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[dseg]; }) enum Code { Code1, Code2, Code3, }; enum UniqueData { Allocate, Tree, Queue, Worker, }; struct Context { enum Code next; int codeNum; __code (**code) (struct Context*); void* heapStart; void* heap; long heapLimit; pthread_t thread; int thread_num; int dataNum; union Data **data; }; union Data { struct Worker { int num; struct Context* contexts; } worker; struct Tree { struct Node* root; } tree; struct Node { // need to tree enum Code next; int key; // comparable data segment union Data* value; struct Node* left; struct Node* right; // need to balancing enum Color { Red, Black, } color; } node; struct Allocate { enum Code next; long size; } allocate; };