all repos — mgba @ c5d243fca282cf11d7f2c38010fce18361babdc2

mGBA Game Boy Advance Emulator

src/platform/posix/memory.c (view raw)

 1#include "memory.h"
 2
 3#include <sys/mman.h>
 4
 5void* anonymousMemoryMap(size_t size) {
 6	return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
 7}
 8void* fileMemoryMap(int fd, size_t size, int flags) {
 9	int mmapFlags = MAP_PRIVATE;
10	if (flags & MEMORY_WRITE) {
11		mmapFlags = MAP_SHARED;
12	}
13	return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, fd, 0);
14}
15
16void mappedMemoryFree(void* memory, size_t size) {
17	munmap(memory, size);
18}