mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-23 19:10:30 +00:00
Add syscalls to Blinkenlights and fix bugs
This commit is contained in:
parent
f6df29cc3d
commit
578cb21591
25 changed files with 187 additions and 108 deletions
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
@ -26,7 +27,7 @@ static char g_strsignal[12];
|
|||
/**
|
||||
* Returns string describing signal code.
|
||||
*
|
||||
* This returns SIGUNKNOWN for 0 which is the empty value. Textual names
|
||||
* This returns SIGZERO for 0 which is the empty value. Textual names
|
||||
* should be available for signals 1 through 32. Signals in the range 33
|
||||
* and 128 are returned as a `SIG%03d` string. Everything else is SIGWUT
|
||||
*
|
||||
|
@ -34,24 +35,36 @@ static char g_strsignal[12];
|
|||
* @return pointer to static memory that mutates on subsequent calls
|
||||
* @see sigaction()
|
||||
*/
|
||||
char *strsignal(int sig) {
|
||||
noasan noinstrument char *strsignal(int sig) {
|
||||
char *p;
|
||||
const char *s;
|
||||
strcpy(g_strsignal, "SIG");
|
||||
p = g_strsignal;
|
||||
p[0] = 'S';
|
||||
p[1] = 'I';
|
||||
p[2] = 'G';
|
||||
p[3] = 0;
|
||||
if (sig) {
|
||||
if ((s = GetMagnumStr(kSignalNames, sig))) {
|
||||
strcpy(g_strsignal + 3, s);
|
||||
return g_strsignal;
|
||||
__stpcpy(p + 3, s);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
if (!sig) {
|
||||
strcpy(g_strsignal + 3, "UNKNOWN");
|
||||
p[3] = 'Z';
|
||||
p[4] = 'E';
|
||||
p[5] = 'R';
|
||||
p[6] = 'O';
|
||||
p[7] = 0;
|
||||
} else if (1 <= sig && sig <= 128) {
|
||||
g_strsignal[3] = '0' + sig / 100;
|
||||
g_strsignal[4] = '0' + sig / 10 % 10;
|
||||
g_strsignal[5] = '0' + sig % 10;
|
||||
g_strsignal[6] = 0;
|
||||
p[3] = '0' + sig / 100;
|
||||
p[4] = '0' + sig / 10 % 10;
|
||||
p[5] = '0' + sig % 10;
|
||||
p[6] = 0;
|
||||
} else {
|
||||
strcpy(g_strsignal + 3, "WUT");
|
||||
p[3] = 'W';
|
||||
p[4] = 'U';
|
||||
p[5] = 'T';
|
||||
p[6] = 0;
|
||||
}
|
||||
return g_strsignal;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue