view runtime/context.h @ 54:243d013a49cb

Defer processing of string literals until after simpler ones to avoid a segfault
author Mike Pavone <pavone@retrodev.com>
date Thu, 29 Apr 2010 01:12:43 -0400
parents 70af7fa155d0
children 04baa003de5a
line wrap: on
line source

#ifndef _CONTEXT_H_
#define _CONTEXT_H_

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

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

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

typedef struct {
	rhope_func       func;
	calldata  *params;
} unwind_cell;

typedef struct context {
	stackchunk   *stack_begin;
	stackchunk   *current_stack;
	unwind_cell  *unwind;
} context;

stackchunk * new_stack();
context * new_context();
void * alloc_stack(context * ct, uint32_t size);
calldata * alloc_cdata(context * ct, uint32_t num_params);
void free_stack(context * ct, void * data);
void free_context(context * c);
#endif //_CONTEXT_H_