Compare commits

...

4 Commits

Author SHA1 Message Date
Maschell 82d1ce0f1b Implement assert and abort 2024-04-24 17:22:11 +02:00
Maschell 501ef2d595 Fix version in Makefile 2024-04-24 17:22:11 +02:00
Maschell 541fc00a8d Publish dev docker images 2024-04-24 17:22:11 +02:00
Maschell f0dbd47aad Allow exports with custom name 2024-04-24 17:22:11 +02:00
6 changed files with 74 additions and 16 deletions

View File

@ -3,6 +3,7 @@ on:
push:
branches:
- main
- '*-dev'
env:
REGISTRY: ghcr.io
@ -24,9 +25,10 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
type=raw,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}}
type=raw,value={{date 'YYYYMMDD'}},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2.1.0
with:

View File

@ -3,7 +3,7 @@ include $(TOPDIR)/share/wums_rules
export WUMS_MAJOR := 0
export WUMS_MINOR := 3
export WUMS_PATCH := 1
export WUMS_PATCH := 2
VERSION := $(WUMS_MAJOR).$(WUMS_MINOR).$(WUMS_PATCH)

View File

@ -42,8 +42,10 @@ typedef struct wums_entry_t {
const void *address; /* pointer to the export */
} wums_loader_entry_t;
#define WUMS_EXPORT_FUNCTION(function) WUMS_EXPORT(WUMS_FUNCTION_EXPORT, function, function)
#define WUMS_EXPORT_DATA(pointer) WUMS_EXPORT(WUMS_DATA_EXPORT, pointer, &pointer)
#define WUMS_EXPORT_FUNCTION_EX(function, name) WUMS_EXPORT(WUMS_FUNCTION_EXPORT, name, function)
#define WUMS_EXPORT_FUNCTION(function) WUMS_EXPORT_FUNCTION_EX(function, function)
#define WUMS_EXPORT_DATA_EX(pointer, name) WUMS_EXPORT(WUMS_DATA_EXPORT, name, &pointer)
#define WUMS_EXPORT_DATA(pointer) WUMS_EXPORT_DATA_EX(pointer, pointer)
#define WUMS_EXPORT(_type, pointer, value) \
extern const wums_loader_entry_t wums_entry_##pointer \

View File

@ -50,13 +50,9 @@ extern "C" {
WUMS_USE_WUT_STDCPP(); \
WUMS___INIT_WRAPPER(); \
WUMS___FINI_WRAPPER(); \
__EXTERN_C_MACRO void abort(); \
void abort() { \
OSFatal(__module_name ": abort() called. Uncaught exception?"); \
while (1) \
; \
} \
WUMS_META(buildtimestamp, __DATE__ " " __TIME__); \
extern const char wums_meta_module_name[] WUMS_SECTION("meta"); \
const char wums_meta_module_name[] = __module_name; \
extern const char wums_meta_info_dump[] WUMS_SECTION("meta"); \
const char wums_meta_info_dump[] = "(module: " __module_name ";" \
"wums " WUMS_VERSION ";" \

View File

@ -1,5 +1,7 @@
#include "wums_reent.h"
#include "wums_thread_specific.h"
#include <cstdio>
#include <cstring>
extern "C" void OSFatal(const char *);
@ -52,3 +54,59 @@ extern "C" void *__attribute__((weak)) wut_get_thread_specific(__wut_thread_spec
void *wut_get_thread_specific(__wut_thread_specific_id id) {
return wums_get_thread_specific(id);
}
extern "C" const char wums_meta_module_name[];
extern "C" void __attribute__((weak)) abort(void);
extern "C" void __attribute__((weak)) __assert_func(const char *file, int line, const char *func, const char *failedexpr);
extern "C" void __attribute__((weak)) __assert(const char *file, int line, const char *failedexpr);
void __attribute__((weak))
abort(void) {
char buffer[512] = {};
strcat(buffer, "Wii U Module System (module: \"");
strcat(buffer, wums_meta_module_name);
strcat(buffer, "\"):\n Abort called. Uncaught exception?");
OSFatal(buffer);
/* NOTREACHED */
while (1)
;
}
void __attribute__((weak))
__assert_func(const char *file,
int line,
const char *func,
const char *failedexpr) {
char tmp[512] = {};
char buffer[512] = {};
snprintf(tmp, sizeof(tmp), "Wii U Module System (module: \"%s\"):\n\n"
"assertion \"%s\" failed:\n\n"
"file \"%s\", line %d%s%s",
wums_meta_module_name, failedexpr, file, line, func ? ", function: " : "", func ? func : "");
// make sure to add a \n every 64 characters to fit on the DRC screen.
char *target_ptr = buffer;
int i = 0, j = 0, lineLength = 0;
while (tmp[i] != '\0' && j < (int) sizeof(buffer) - 2) {
if (tmp[i] == '\n') {
lineLength = 0;
} else if (lineLength >= 64) {
target_ptr[j++] = '\n';
lineLength = 0;
}
target_ptr[j++] = tmp[i++];
lineLength++;
}
OSFatal(buffer);
/* NOTREACHED */
}
void __attribute__((weak))
__assert(const char *file,
int line,
const char *failedexpr) {
__assert_func(file, line, NULL, failedexpr);
/* NOTREACHED */
}

View File

@ -9,14 +9,14 @@ typedef uint32_t OSThread;
extern const char wums_meta_info_dump[];
extern void OSFatal(const char *);
extern void OSReport(const char *, ...);
extern "C" void OSFatal(const char *);
extern "C" void OSReport(const char *, ...);
extern OSThread *OSGetCurrentThread();
extern "C" OSThread *OSGetCurrentThread();
typedef void (*OSThreadCleanupCallbackFn)(OSThread *thread, void *stack);
OSThreadCleanupCallbackFn
extern "C" OSThreadCleanupCallbackFn
OSSetThreadCleanupCallback(OSThread *thread,
OSThreadCleanupCallbackFn callback);