all repos — mgba @ b8167f55b1e69819ee4c74174502b9f31fbb5538

mGBA Game Boy Advance Emulator

Create Windows and POSIX platform directories
Jeffrey Pfau jeffrey@endrift.com
Wed, 15 Jan 2014 01:28:30 -0800
commit

b8167f55b1e69819ee4c74174502b9f31fbb5538

parent

270c1a35d765b833c2b5a2c5f46655f5a31915a9

3 files changed, 24 insertions(+), 20 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -16,6 +16,11 @@ include_directories(${CMAKE_SOURCE_DIR}/src/util)

find_package(SDL 1.2 REQUIRED) file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c) +if(WIN32) + file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c) +else() + file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c) +endif() include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl) if(USE_DEBUGGER)

@@ -47,5 +52,5 @@ set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)

set(EXTRA_LIB ${EXTRA_LIB} rt) endif() -add_executable(${BINARY_NAME} WIN32 ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${PLATFORM_SRC} ${MAIN_SRC}) +add_executable(${BINARY_NAME} WIN32 ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${PLATFORM_SRC} ${OS_SRC} ${MAIN_SRC}) target_link_libraries(${BINARY_NAME} m pthread ${DEBUGGER_LIB} ${SDL_LIBRARY} ${OPENGL_LIBRARY} ${EXTRA_LIB})
A src/platform/posix/memory.c

@@ -0,0 +1,18 @@

+#include "memory.h" + +#include <sys/mman.h> + +void* anonymousMemoryMap(size_t size) { + return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); +} +void* fileMemoryMap(int fd, size_t size, int flags) { + int mmapFlags = MAP_PRIVATE; + if (flags & MEMORY_WRITE) { + mmapFlags = MAP_SHARED; + } + return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, fd, 0); +} + +void mappedMemoryFree(void* memory, size_t size) { + munmap(memory, size); +}
M src/util/memory.csrc/platform/windows/memory.c

@@ -1,6 +1,5 @@

#include "memory.h" -#ifdef _WIN32 #include <io.h> #include <Windows.h>

@@ -29,21 +28,3 @@

void mappedMemoryFree(void* memory, size_t size) { // TODO fill in } -#else -#include <sys/mman.h> - -void* anonymousMemoryMap(size_t size) { - return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); -} -void* fileMemoryMap(int fd, size_t size, int flags) { - int mmapFlags = MAP_PRIVATE; - if (flags & MEMORY_WRITE) { - mmapFlags = MAP_SHARED; - } - return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, fd, 0); -} - -void mappedMemoryFree(void* memory, size_t size) { - munmap(memory, size); -} -#endif