Created
April 25, 2017 05:13
-
-
Save mrpippy/d3ca854ad2c5e4fe01861f0f2a241486 to your computer and use it in GitHub Desktop.
mgba patch to build on Leopard with gcc 4.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 04a4f1c..3a49def 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6) | |
project(mGBA C) | |
set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries") | |
if(NOT MSVC) | |
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -std=c99") | |
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -std=gnu99") | |
else() | |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146") | |
endif() | |
@@ -223,8 +223,8 @@ endif() | |
list(APPEND OS_LIB ${M_LIBRARY}) | |
if(APPLE OR CMAKE_C_COMPILER_ID STREQUAL "GNU" AND BUILD_LTO) | |
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto") | |
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto") | |
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") | |
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | |
endif() | |
if(BUILD_BBB OR BUILD_RASPI OR BUILD_PANDORA) | |
diff --git a/include/mgba-util/common.h b/include/mgba-util/common.h | |
index 63e3dd3..cf66e94 100644 | |
--- a/include/mgba-util/common.h | |
+++ b/include/mgba-util/common.h | |
@@ -61,6 +61,10 @@ typedef intptr_t ssize_t; | |
#include <sys/syslimits.h> | |
#endif | |
+#ifdef __APPLE__ | |
+#include <libkern/OSByteOrder.h> | |
+#endif | |
+ | |
#ifndef SSIZE_MAX | |
#define SSIZE_MAX ((ssize_t) (SIZE_MAX >> 1)) | |
#endif | |
@@ -73,7 +77,7 @@ typedef intptr_t ssize_t; | |
#define M_PI 3.141592654f | |
#endif | |
-#ifndef _MSC_VER | |
+#if 0 | |
#define ATOMIC_STORE(DST, SRC) __atomic_store_n(&DST, SRC, __ATOMIC_RELEASE) | |
#define ATOMIC_LOAD(DST, SRC) DST = __atomic_load_n(&SRC, __ATOMIC_ACQUIRE) | |
#define ATOMIC_ADD(DST, OP) __atomic_add_fetch(&DST, OP, __ATOMIC_RELEASE) | |
@@ -126,8 +130,13 @@ typedef intptr_t ssize_t; | |
__asm__("sthbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr)); \ | |
} | |
+#if defined(__APPLE__) | |
+#define LOAD_64LE(DEST, ADDR, ARR) DEST = OSSwapInt64(((uint64_t*) ARR)[(ADDR) >> 3]) | |
+#define STORE_64LE(SRC, ADDR, ARR) ((uint64_t*) ARR)[(ADDR) >> 3] = OSSwapInt64(SRC) | |
+#else | |
#define LOAD_64LE(DEST, ADDR, ARR) DEST = __builtin_bswap64(((uint64_t*) ARR)[(ADDR) >> 3]) | |
#define STORE_64LE(SRC, ADDR, ARR) ((uint64_t*) ARR)[(ADDR) >> 3] = __builtin_bswap64(SRC) | |
+#endif | |
#elif defined __BIG_ENDIAN__ | |
#if defined(__llvm__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) | |
#define LOAD_64LE(DEST, ADDR, ARR) DEST = __builtin_bswap64(((uint64_t*) ARR)[(ADDR) >> 3]) | |
diff --git a/include/mgba-util/platform/posix/threading.h b/include/mgba-util/platform/posix/threading.h | |
index b880c54..577df37 100644 | |
--- a/include/mgba-util/platform/posix/threading.h | |
+++ b/include/mgba-util/platform/posix/threading.h | |
@@ -84,7 +84,9 @@ static inline int ThreadJoin(Thread thread) { | |
static inline int ThreadSetName(const char* name) { | |
#ifdef __APPLE__ | |
- return pthread_setname_np(name); | |
+ //return pthread_setname_np(name); | |
+ UNUSED(name); | |
+ return 0; | |
#elif defined(__FreeBSD__) || defined(__OpenBSD__) | |
pthread_set_name_np(pthread_self(), name); | |
return 0; | |
diff --git a/src/platform/sdl/CMakeLists.txt b/src/platform/sdl/CMakeLists.txt | |
index 9a653fc..b606848 100644 | |
--- a/src/platform/sdl/CMakeLists.txt | |
+++ b/src/platform/sdl/CMakeLists.txt | |
@@ -86,6 +86,10 @@ else() | |
endif() | |
endif() | |
+if(APPLE) | |
+ list(APPEND PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/SDLMain.m) | |
+endif() | |
+ | |
add_executable(${BINARY_NAME}-sdl WIN32 ${PLATFORM_SRC} ${MAIN_SRC}) | |
set_target_properties(${BINARY_NAME}-sdl PROPERTIES COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES}") | |
target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to file a PR, I can try to do a proper review. That said, here are some preliminary things:
OSWriteLittleInt64
is probably a better approach thanOSSwapInt64
check_function_exists
forpthread_set_name_np
/pthread_setname_np
/just dummying out the function is a good idea.