Re-factored sandbox into a single executable

This commit is contained in:
2022-12-29 19:47:25 +00:00
parent 2b59afcaf3
commit 2ac3e8602f
7 changed files with 44 additions and 46 deletions

View File

@@ -1,29 +0,0 @@
#include <stdio.h>
#include <sys/mman.h>
#include "vm.h"
/* amount of memory to allocate for system RAM in megabytes */
#define SIMULATED_MEMORY_MB 16
#define MEMPTR(offset) ((void *)((uintptr_t)system_memory) + (offset))
int main(int argc, const char **argv)
{
printf("Hello, world!\n");
void *system_memory = mmap(
NULL,
SIMULATED_MEMORY_MB * 0x100000,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
if (system_memory == MAP_FAILED) {
perror("mmap");
fprintf(stderr, "cannot allocated simulated system RAM buffer\n");
return -1;
}
munmap(system_memory, SIMULATED_MEMORY_MB * 0x100000);
return 0;
}