all repos — mgba @ ecb1939ff1ecbb190a28a9eb3544c2a58d210305

mGBA Game Boy Advance Emulator

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

 1#include "util/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}