1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-23 23:32:45 +00:00
erc-c/include/vm_segment.h

32 lines
761 B
C
Raw Normal View History

2017-11-22 05:24:51 +00:00
#ifndef _VM_SEGMENT_H_
#define _VM_SEGMENT_H_
2017-12-02 19:05:53 +00:00
#include "vm_bits.h"
2017-11-22 05:24:51 +00:00
2017-12-07 03:37:14 +00:00
/*
* The bounds check is just some inline code to try and cut down on the
* cost of it.
*/
#define vm_segment_bounds_check(segment, index) \
(index == index % segment->size)
2017-11-22 05:24:51 +00:00
typedef struct {
2017-12-07 03:37:14 +00:00
/*
* The size of our memory segment. This is used for bounds checking.
*/
2017-11-22 05:24:51 +00:00
size_t size;
2017-12-07 03:37:14 +00:00
/*
* This is the actual chunk of memory we allocate.
*/
2017-12-02 19:05:53 +00:00
vm_8bit *memory;
2017-11-22 05:24:51 +00:00
} vm_segment;
extern void vm_segment_copy(vm_segment *, vm_segment *, size_t, size_t, size_t);
extern vm_segment *vm_segment_create(size_t);
2017-12-02 19:05:53 +00:00
extern void vm_segment_free(vm_segment *);
extern vm_8bit vm_segment_get(vm_segment *, size_t);
extern void vm_segment_set(vm_segment *, size_t, vm_8bit);
2017-11-22 05:24:51 +00:00
#endif