From 148f5f7499362d2931f507906974146c924ef5e1 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 7 Jun 2022 01:02:53 +1000 Subject: [PATCH 1/2] (WiiU) Implement sysconf() _SC_PAGESIZE is used in some cores. --- wiiu/system/missing_libc_functions.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wiiu/system/missing_libc_functions.c b/wiiu/system/missing_libc_functions.c index bf401f1752..060785d63f 100644 --- a/wiiu/system/missing_libc_functions.c +++ b/wiiu/system/missing_libc_functions.c @@ -127,6 +127,21 @@ int clock_gettime(clockid_t clk_id, struct timespec* tp) return 0; } +/* Fake sysconf for page size and processor count */ +long sysconf(int name) { + switch (name) { + case _SC_PAGESIZE: + //case _SC_PAGE_SIZE: + return 128 * 1024; + case _SC_NPROCESSORS_CONF: + case _SC_NPROCESSORS_ONLN: + return 3; + default: + errno = EINVAL; + return -1; + } +} + /** * Implementation of getifaddrs() and freeifaddrs() for WiiU. */ From d6250fd58cd34538244f4b249d4b8afb23f6dcc6 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 7 Jun 2022 01:07:01 +1000 Subject: [PATCH 2/2] (WiiU) Implement __clear_cache This seems to maybe be a libgcc builtin and even explicit calls to it are removed.. so we have a Makefile workaround! --- wiiu/system/missing_libc_functions.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wiiu/system/missing_libc_functions.c b/wiiu/system/missing_libc_functions.c index 060785d63f..ed66918984 100644 --- a/wiiu/system/missing_libc_functions.c +++ b/wiiu/system/missing_libc_functions.c @@ -142,6 +142,15 @@ long sysconf(int name) { } } +/** + * Intended to replace libgcc's __clear_cache builtin. + * For cores that need it, add -D__clear_cache=wiiu_clear_cache to CFLAGS. + */ +void wiiu_clear_cache (char *beg, char *end) { + DCFlushRange(beg, (uint32_t)(end - beg)); + ICInvalidateRange(beg, (uint32_t)(end - beg)); +} + /** * Implementation of getifaddrs() and freeifaddrs() for WiiU. */