Match MSL signal #120

Merged
coah80 merged 1 commits from agent/continue-0922/65-signal into main 2026-09-22 05:51:23 +00:00
3 changed files with 44 additions and 1 deletions

View File

@@ -1961,7 +1961,7 @@ config.libs = [
Object(Matching, "MSL_Common/qsort.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/rand.c"),
Object(NonMatching, "MSL_Common/scanf.c"),
Object(NonMatching, "MSL_Common/signal.c"),
Object(Matching, "MSL_Common/signal.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/string.c"),
Object(Matching, "MSL_Common/float.c"),
Object(NonMatching, "MSL_Common/strtold.c"),

View File

@@ -5,6 +5,19 @@
extern "C" {
#endif
#define SIGNAL_ACTION_DEFAULT ((__signal_func_ptr)0)
#define SIGNAL_ACTION_IGNORE ((__signal_func_ptr)1)
#define SIGNAL_ABORT 1
#define SIGNAL_UNK2 2
#define SIGNAL_UNK3 3
#define SIGNAL_UNK4 4
#define SIGNAL_UNK5 5
#define SIGNAL_UNK6 6
#define SIGNAL_UNK7 7
typedef void (*__signal_func_ptr)(int);
int raise(int signal);
#ifdef __cplusplus

View File

@@ -0,0 +1,30 @@
#include <signal.h>
int exit(int);
__signal_func_ptr signal_funcs[8];
int raise(int sig) {
__signal_func_ptr signal_func;
if (sig < SIGNAL_ABORT || sig > SIGNAL_UNK7) {
return -1;
}
signal_func = signal_funcs[sig - 1];
if (signal_func != SIGNAL_ACTION_IGNORE) {
signal_funcs[sig - 1] = SIGNAL_ACTION_DEFAULT;
}
if (signal_func == SIGNAL_ACTION_IGNORE || (signal_func == SIGNAL_ACTION_DEFAULT && sig == SIGNAL_ABORT)) {
return 0;
}
if (signal_func == SIGNAL_ACTION_DEFAULT) {
exit(0);
}
(*signal_func)(sig);
return 0;
}