redox/recipes/emulators/flycast/redox.patch

221 lines
7.3 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8340288f..c64fad9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,7 +260,7 @@ if(WINDOWS_STORE)
set(USE_VULKAN OFF)
endif()
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)
+
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /GR /GS-)
if(WINDOWS_STORE)
@@ -466,7 +466,7 @@ if(NOT LIBRETRO)
endif()
if(NOT ANDROID AND NOT IOS)
- if (NOT NINTENDO_SWITCH)
+ if (NOT NINTENDO_SWITCH AND NOT REDOX)
# DreamLink enabled for non-mobile Linux, MacOS, and Windows
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DREAMLINK_DEVICES=1)
set(USE_DREAMLINK_DEVICES ON) # Must be set before adding core/sdl
@@ -493,7 +493,7 @@ if(NOT LIBRETRO)
endif()
if(USE_HOST_SDL)
- find_package(SDL2 2.0.9)
+ find_package(SDL2 REQUIRED)
endif()
if(NOT SDL2_FOUND)
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
@@ -691,11 +691,11 @@ target_sources(${PROJECT_NAME} PRIVATE
core/deps/chdpsr/cdipsr.cpp
core/deps/chdpsr/cdipsr.h)
-add_subdirectory(core/deps/nowide EXCLUDE_FROM_ALL)
+add_subdirectory(core/deps/nowide)
target_link_libraries(${PROJECT_NAME} PRIVATE nowide::nowide)
if(NOT MINIUPNP_FOUND)
- if(NINTENDO_SWITCH)
+ if(NINTENDO_SWITCH OR REDOX)
target_compile_definitions(${PROJECT_NAME} PRIVATE FEAT_NO_MINIUPNPC)
else()
option(UPNPC_BUILD_SHARED "Build shared library" OFF)
diff --git a/core/build.h b/core/build.h
index 6ea53550..b7b0d1d5 100755
--- a/core/build.h
+++ b/core/build.h
@@ -110,7 +110,7 @@
#endif
#if !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_UWP) \
- && !defined(__SWITCH__) && !defined(LIBRETRO) && !defined(__NetBSD__) && !defined(__OpenBSD__)
+ && !defined(__SWITCH__) && !defined(LIBRETRO) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__redox__)
#define NAOMI_MULTIBOARD
#endif
Submodule core/deps/asio contains modified content
diff --git a/core/deps/asio/asio/include/asio/detail/config.hpp b/core/deps/asio/asio/include/asio/detail/config.hpp
index 61ee752..4b140b9 100644
--- a/core/deps/asio/asio/include/asio/detail/config.hpp
+++ b/core/deps/asio/asio/include/asio/detail/config.hpp
@@ -828,6 +828,7 @@
|| defined(__NetBSD__) \
|| defined(__OpenBSD__) \
|| defined(__linux__) \
+ || defined(__redox__) \
|| defined(__HAIKU__)
# define ASIO_HAS_UNISTD_H 1
# endif
@@ -1093,7 +1094,6 @@
# endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_THREADS)
# endif // !defined(ASIO_DISABLE_THREADS)
#endif // !defined(ASIO_HAS_THREADS)
-
// POSIX threads.
#if !defined(ASIO_HAS_PTHREADS)
# if defined(ASIO_HAS_THREADS)
diff --git a/core/deps/picotcp/modules/pico_dev_ppp.c b/core/deps/picotcp/modules/pico_dev_ppp.c
index dcffacee..121ac27f 100644
--- a/core/deps/picotcp/modules/pico_dev_ppp.c
+++ b/core/deps/picotcp/modules/pico_dev_ppp.c
@@ -7,6 +7,7 @@
*********************************************************************/
+#include <alloca.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/core/hw/sh4/modules/mmu.cpp b/core/hw/sh4/modules/mmu.cpp
index af9de30e..6f839fc7 100644
--- a/core/hw/sh4/modules/mmu.cpp
+++ b/core/hw/sh4/modules/mmu.cpp
@@ -439,6 +439,7 @@ retry_ITLB_Match:
void mmu_set_state()
{
+ /* // TODO: crashing a thread in redox
if (CCN_MMUCR.AT == 1)
{
// Detect if we're running Windows CE
@@ -450,7 +451,7 @@ void mmu_set_state()
NOTICE_LOG(SH4, "Enabling Full MMU support");
}
}
- else
+ else*/
{
mmuOn = false;
}
diff --git a/core/hw/sh4/modules/serial.cpp b/core/hw/sh4/modules/serial.cpp
index aca43a01..11991e9e 100644
--- a/core/hw/sh4/modules/serial.cpp
+++ b/core/hw/sh4/modules/serial.cpp
@@ -475,7 +475,7 @@ struct PTYPipe : public SerialPort::Pipe
void init()
{
-#if defined(__unix__) || defined(__APPLE__)
+#if (defined(__unix__) || defined(__APPLE__)) && !defined(__redox__)
if (config::SerialConsole && config::SerialPTY && tty == 1)
{
tty = open("/dev/ptmx", O_RDWR | O_NDELAY | O_NOCTTY | O_NONBLOCK);
diff --git a/core/linux/context.cpp b/core/linux/context.cpp
index 7ab2d8e9..8a2bb2c7 100644
--- a/core/linux/context.cpp
+++ b/core/linux/context.cpp
@@ -8,11 +8,11 @@
#define __USE_GNU 1
#endif
- #if !defined(__OpenBSD__)
+ #if !defined(__OpenBSD__) && !defined(__redox__)
#include <ucontext.h>
#endif
- #if defined(__OpenBSD__)
+ #if defined(__OpenBSD__) || defined(__redox__)
#include <signal.h>
#endif
@@ -112,6 +112,11 @@ static void context_segfault(host_context_t* hostctx, void* segfault_ctx)
bicopy<ToSegfault>(hostctx->rsp, MCTX(.__gregs[_REG_RSP]));
bicopy<ToSegfault>(hostctx->r9, MCTX(.__gregs[_REG_R9]));
bicopy<ToSegfault>(hostctx->rdi, MCTX(.__gregs[_REG_RDI]));
+ #elif defined(__redox__)
+ bicopy<ToSegfault>(hostctx->pc, MCTX(.rip));
+ bicopy<ToSegfault>(hostctx->rsp, MCTX(.rsp));
+ bicopy<ToSegfault>(hostctx->r9, MCTX(.r9));
+ bicopy<ToSegfault>(hostctx->rdi, MCTX(.rdi));
#elif defined(__unix__)
bicopy<ToSegfault>(hostctx->pc, MCTX(.gregs[REG_RIP]));
bicopy<ToSegfault>(hostctx->rsp, MCTX(.gregs[REG_RSP]));
diff --git a/core/linux/posix_vmem.cpp b/core/linux/posix_vmem.cpp
index 46105157..c2205c17 100644
--- a/core/linux/posix_vmem.cpp
+++ b/core/linux/posix_vmem.cpp
@@ -163,6 +163,10 @@ static size_t reserved_size;
// memory using a fallback (that is, regular mallocs and falling back to slow memory JIT).
bool init(void **vmem_base_addr, void **sh4rcb_addr, size_t ramSize)
{
+#ifdef __redox__
+ // shared memory is broken
+ return false;
+#endif
// Firt let's try to allocate the shm-backed memory
vmem_fd = allocate_shared_filemem(ramSize);
if (vmem_fd < 0)
diff --git a/core/network/dns.cpp b/core/network/dns.cpp
index 4d45c4a2..96752ef4 100644
--- a/core/network/dns.cpp
+++ b/core/network/dns.cpp
@@ -153,7 +153,7 @@ pico_ip4 parseDnsResponsePacket(const void *buf, size_t len)
return { ~0u };
}
-#if !defined(_WIN32) && !defined(__SWITCH__)
+#if !defined(_WIN32) && !defined(__SWITCH__) && !defined(__redox__)
#include <ifaddrs.h>
#include <net/if.h>
#endif
@@ -200,7 +200,7 @@ bool is_local_address(u32 addr)
}
closesocket(sd);
-#elif defined(__SWITCH__)
+#elif defined(__SWITCH__) || defined(__redox__)
// TODO
#else // !_WIN32 && !__SWITCH__
diff --git a/core/network/net_platform.h b/core/network/net_platform.h
index 8b5ea488..1a20e0b7 100644
--- a/core/network/net_platform.h
+++ b/core/network/net_platform.h
@@ -91,7 +91,7 @@ static inline void set_tcp_nodelay(sock_t fd)
#if defined(_WIN32)
struct protoent *tcp_proto = getprotobyname("TCP");
setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, (const char *)&optval, optlen);
-#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
+#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__redox__)
setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen);
#else
struct protoent *tcp_proto = getprotobyname("TCP");
diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp
index 35b41b70..b62edfc2 100644
--- a/core/rend/TexCache.cpp
+++ b/core/rend/TexCache.cpp
@@ -242,6 +242,10 @@ bool BaseTextureCacheData::NeedsUpdate() {
void BaseTextureCacheData::protectVRam()
{
+ // TODO: No SIGSEGV handler on redox
+ #ifdef __redox__
+ return;
+ #endif
u32 end = mmStartAddress + size - 1;
if (end >= VRAM_SIZE)
{