mirror of https://github.com/mgba-emu/mgba.git
Create Windows and POSIX platform directories
This commit is contained in:
parent
270c1a35d7
commit
b8167f55b1
|
@ -16,6 +16,11 @@ include_directories(${CMAKE_SOURCE_DIR}/src/util)
|
||||||
|
|
||||||
find_package(SDL 1.2 REQUIRED)
|
find_package(SDL 1.2 REQUIRED)
|
||||||
file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
|
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)
|
include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl)
|
||||||
|
|
||||||
if(USE_DEBUGGER)
|
if(USE_DEBUGGER)
|
||||||
|
@ -47,5 +52,5 @@ if(BUILD_PERF)
|
||||||
set(EXTRA_LIB ${EXTRA_LIB} rt)
|
set(EXTRA_LIB ${EXTRA_LIB} rt)
|
||||||
endif()
|
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})
|
target_link_libraries(${BINARY_NAME} m pthread ${DEBUGGER_LIB} ${SDL_LIBRARY} ${OPENGL_LIBRARY} ${EXTRA_LIB})
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
@ -29,21 +28,3 @@ void* fileMemoryMap(int fd, size_t size, int flags) {
|
||||||
void mappedMemoryFree(void* memory, size_t size) {
|
void mappedMemoryFree(void* memory, size_t size) {
|
||||||
// TODO fill in
|
// 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
|
|
Loading…
Reference in New Issue