view runtime/context.h @ 186:ba35ab624ec2

Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2011 00:10:02 -0700
parents f2cb85c53ced
children
line wrap: on
line source

#ifndef _CONTEXT_H_
#define _CONTEXT_H_

#include "thread.h"
#include "plat_types.h"
#include "func.h"
#include "transaction.h"

#define STACK_CHUNK_SIZE 4096-(sizeof(struct stackchunk *)*2+sizeof(char *))

#ifdef RAW_FUNC
//hack
typedef int context;
#else

typedef struct stackchunk {
	struct    stackchunk * next;
	struct    stackchunk * prev;
	char      *free_space;
	char      data[STACK_CHUNK_SIZE];
} stackchunk;

typedef struct context {
	stackchunk     *stack_begin;
	stackchunk     *current_stack;
	transaction    *transaction;
	struct context *runafter;
	calldata       *resume_cdata;
	int32_t        resumeable;
} context;
#endif

Box(context *,ct,Context);
#ifndef RAW_FUNC
stackchunk * new_stack();
context * new_context();
void * alloc_stack(context * ct, uint32_t size);
calldata * alloc_cdata(context * ct, calldata * lastframe, uint32_t num_params);
void free_stack(context * ct, void * data);
void free_context(context * c);
void cqueue_init();
context * get_cqueue();
int32_t put_cqueue(context * ct);
#endif
object * make_Context(context * ct);
#endif //_CONTEXT_H_