Mercurial > hg > Papers > 2023 > soto-master
view Paper/src/context.h @ 28:423f59b098ac
Add svg
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 15 Feb 2023 17:18:23 +0900 |
parents | a72446879486 |
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; };