view meta_connector/example/synchronizedQueueContext.c @ 26:b9f88346cecd support auto stub generation

generate stub
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Mon, 02 Nov 2015 04:02:13 +0900
parents
children
line wrap: on
line source

#include <stdlib.h>

#include "synchronizedQueueContext.h"

extern __code code1_stub(struct Context*);
extern __code code2_stub(struct Context*);
extern __code code3_stub(struct Context*);
extern __code code4_stub(struct Context*);
extern __code code5_stub(struct Context*);
extern __code code6_stub(struct Context*);
extern __code code7_stub(struct Context*);
extern __code code8_stub(struct Context*);
extern __code code9_stub(struct Context*);
extern __code code10_stub(struct Context*);
extern __code code11_stub(struct Context*);
extern __code meta(struct Context*);
extern __code sender_stub(struct Context*);
extern __code put_stub(struct Context*);
extern __code continue_put_stub(struct Context*);
extern __code receiver_stub(struct Context*);
extern __code get_stub(struct Context*);
extern __code continue_get_stub(struct Context*);
extern __code exit_code(struct Context*);
extern __code thread_exit_stub(struct Context*);

__code initSynchronizedQueueContext(struct Context* context) {
    context->dataSize   = sizeof(union Data)*ALLOCATE_SIZE;
    context->code       = malloc(sizeof(__code*)*ALLOCATE_SIZE);
    context->data       = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
    context->heapStart = malloc(context->dataSize);

    context->codeNum           = Exit;
    context->code[Code1]       = code1_stub;
    context->code[Code2]       = code2_stub;
    context->code[Code3]       = code3_stub;
    context->code[Code4]       = code4_stub;
    context->code[Code5]       = code5_stub;
    context->code[Code6]       = code6_stub;
    context->code[Code7]       = code7_stub;
    //    context->code[Code8]       = code8_stub;
    //    context->code[Code9]       = code9_stub;
    //    context->code[Code10]      = code10_stub;
    //    context->code[Code11]      = code11_stub;
    context->code[Sender]      = sender_stub;
    context->code[Put]         = put_stub;
    //    context->code[ContinuePut] = continue_put_stub;
    context->code[Receiver]    = receiver_stub;
    context->code[Get]         = get_stub;
    //    context->code[ContinueGet] = continue_get_stub;
    context->code[Thread_exit]  = thread_exit_stub;
    context->code[Exit]        = exit_code;

    context->heap = context->heapStart;

    context->data[Allocate] = context->heap;
    context->heap          += sizeof(struct Allocate);

    context->data[Queue]    = context->heap;
    context->heap          += sizeof(struct Queue);
    context->data[Queue]->queue.first = 0;
    pthread_mutex_init(&context->data[Queue]->queue.mutex, NULL);
    pthread_cond_init(&context->data[Queue]->queue.cond, NULL);

    context->dataNum = Queue;
}