Switch to mmap w/ executable memory.
This commit is contained in:
@ -96,8 +96,8 @@ static cell_t *eval1(cell_t *sp, cell_t *call) {
|
||||
return sp;
|
||||
}
|
||||
|
||||
static void ueforth(const char *src, cell_t src_len) {
|
||||
g_sys.heap = malloc(HEAP_SIZE);
|
||||
static void ueforth(void *heap, const char *src, cell_t src_len) {
|
||||
g_sys.heap = (cell_t *) heap;
|
||||
register cell_t *sp = g_sys.heap; g_sys.heap += STACK_SIZE;
|
||||
register cell_t *rp = g_sys.heap; g_sys.heap += STACK_SIZE;
|
||||
register cell_t tos = 0, *ip, t, w;
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "common/opcodes.h"
|
||||
|
||||
#define HEAP_SIZE (10 * 1024 * 1024)
|
||||
#define STACK_SIZE (16 * 1024)
|
||||
|
||||
#define PLATFORM_OPCODE_LIST \
|
||||
@ -23,6 +22,9 @@
|
||||
|
||||
#include "gen/posix_boot.h"
|
||||
|
||||
#define HEAP_SIZE (10 * 1024 * 1024)
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
ueforth(boot, sizeof(boot));
|
||||
void *heap = mmap(0, HEAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
ueforth(heap, boot, sizeof(boot));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user