Usermode/libc - Makefile update, move stdin/... to .data for R_*_COPY to work
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / signals.c
index c33019e..532f09b 100644 (file)
@@ -6,20 +6,22 @@
 #include <stdlib.h>
 #include <signal.h>
 #include "lib.h"
+#include <errno.h>
 
 // === CONSTANTS ===
-#define NUM_SIGNALS    32
+#define NUM_SIGNALS    40
 
 // === GLOBALS ===
-sighandler_t   sighandlers[NUM_SIGNALS];
+struct sigaction       sighandlers[NUM_SIGNALS];
 
 // === CODE ===
 sighandler_t signal(int num, sighandler_t handler)
 {
        sighandler_t    prev;
        if(num < 0 || num >= NUM_SIGNALS)       return NULL;
-       prev = sighandlers[num];
-       sighandlers[num] = handler;
+       prev = sighandlers[num].sa_handler;
+       sighandlers[num].sa_handler = handler;
+       sighandlers[num].sa_mask = 0;
        return prev;
 }
 
@@ -39,5 +41,33 @@ int raise(int signal)
 void abort(void)
 {
        // raise(SIGABRT);
+       _SysDebug("abort() - %p", __builtin_return_address(0));
        _exit(-1);
 }
+
+// POSIX
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
+{
+       if( signum < 0 || signum >= NUM_SIGNALS ) {
+               errno = EINVAL;
+               return 1;
+       }
+
+       if( oldact )
+               *oldact = sighandlers[signum];
+       if( act )
+               sighandlers[signum] = *act;     
+
+       return 0;
+}
+
+int sigemptyset(sigset_t *set)
+{
+       *set = 0;
+       return 0;
+}
+int sigfillset(sigset_t *set)
+{
+       *set = -1;
+       return 0;
+}

UCC git Repository :: git.ucc.asn.au