3DS: Get core library building on 3DS
Jeffrey Pfau jeffrey@endrift.com
Mon, 08 Dec 2014 16:04:02 -0800
2 files changed,
25 insertions(+),
19 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -106,6 +106,9 @@ add_definitions(-D_WIN32_WINNT=0x0600)
list(APPEND OS_LIB ws2_32) file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c) source_group("Windows-specific code" FILES ${OS_SRC}) +elseif(3DS) + add_definitions(-D__3DS) + list(APPEND OS_LIB ctru) else() add_definitions(-DUSE_PTHREADS) list(APPEND OS_LIB pthread)
M
src/util/vfs.c
→
src/util/vfs.c
@@ -10,13 +10,15 @@
#include <fcntl.h> #include <dirent.h> -#ifndef _WIN32 -#include <sys/mman.h> -#define PATH_SEP '/' -#else +#ifdef _WIN32 #include <io.h> #include <windows.h> #define PATH_SEP '\\' +#elif defined(__3DS) +#define PATH_SEP '/' +#else +#include <sys/mman.h> +#define PATH_SEP '/' #endif struct VFileFD {@@ -114,21 +116,7 @@ struct VFileFD* vfd = (struct VFileFD*) vf;
return write(vfd->fd, buffer, size); } -#ifndef _WIN32 -static void* _vfdMap(struct VFile* vf, size_t size, int flags) { - struct VFileFD* vfd = (struct VFileFD*) vf; - int mmapFlags = MAP_PRIVATE; - if (flags & MAP_WRITE) { - mmapFlags = MAP_SHARED; - } - return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, vfd->fd, 0); -} - -static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) { - UNUSED(vf); - munmap(memory, size); -} -#else +#ifdef _WIN32 static void* _vfdMap(struct VFile* vf, size_t size, int flags) { struct VFileFD* vfd = (struct VFileFD*) vf; int createFlags = PAGE_WRITECOPY;@@ -153,6 +141,21 @@ struct VFileFD* vfd = (struct VFileFD*) vf;
UnmapViewOfFile(memory); CloseHandle(vfd->hMap); vfd->hMap = 0; +} +#elif defined(__3DS) +#else +static void* _vfdMap(struct VFile* vf, size_t size, int flags) { + struct VFileFD* vfd = (struct VFileFD*) vf; + int mmapFlags = MAP_PRIVATE; + if (flags & MAP_WRITE) { + mmapFlags = MAP_SHARED; + } + return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, vfd->fd, 0); +} + +static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) { + UNUSED(vf); + munmap(memory, size); } #endif