Improve signal handling and math

- Polyfill ucontext_t on FreeBSD/OpenBSD/NetBSD
- Add tests confirming signals can edit CPU state
- Work towards supporting ZIP filesystem on bare metal
- Add more tinymath unit tests for POSIX conformance
- Add X87 and SSE status flags to crash report
- Fix some bugs in blinkenlights
- Fix llvm build breakage
This commit is contained in:
Justine Tunney 2021-02-25 18:30:17 -08:00
parent cdc54ea1fd
commit 40291c9db3
109 changed files with 2316 additions and 520 deletions

View file

@ -24,9 +24,13 @@
#include "libc/sysv/consts/sig.h"
textwindows wontreturn void sys_abort_nt(void) {
int rva;
siginfo_t info;
memset(&info, 0, sizeof(info));
info.si_signo = SIGABRT;
__sigenter(SIGABRT, &info, NULL);
rva = __sighandrvas[SIGABRT];
if (rva >= kSigactionMinRva) {
((sigaction_f)(_base + rva))(SIGABRT, &info, NULL);
}
_Exit(128 + SIGABRT);
}

View file

@ -81,7 +81,7 @@ __msabi noasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle,
* Allocates and clears PC-compatible memory and copies image.
*/
SystemTable->BootServices->AllocatePages(
EfiConventionalMemory, AllocateAddress,
AllocateAddress, EfiConventionalMemory,
MAX(2 * 1024 * 1024, 1024 * 1024 + (_end - _base)) / 4096, 0);
SystemTable->BootServices->SetMem(0, 0x80000, 0);
SystemTable->BootServices->CopyMem((void *)(1024 * 1024), _base,

View file

@ -19,13 +19,13 @@
#include "libc/macros.h"
#include "libc/notice.inc"
.initbss 300,_init___argc
/ Global variable holding _start(argc) parameter.
.initbss 300,_init_argc
// Global variable holding _start(argc) parameter.
__argc: .quad 0
.endobj __argc,globl
.previous
.init.start 300,_init___argc
.init.start 300,_init_argc
mov %r12,%rax
stosq
.init.end 300,_init___argc
.init.end 300,_init_argc

View file

@ -58,8 +58,12 @@
B: FPU Busy
*/
#define FPU_IE 0b0000000000100000000000001
#define FPU_ZE 0b0000000000100000000000100
#define FPU_IE 0b0000000000000000000000001
#define FPU_DE 0b0000000000000000000000010
#define FPU_ZE 0b0000000000000000000000100
#define FPU_OE 0b0000000000000000000001000
#define FPU_UE 0b0000000000000000000010000
#define FPU_PE 0b0000000000000000000100000
#define FPU_SF 0b0000000000000000001000000
#define FPU_C0 0b0000000000000000100000000
#define FPU_C1 0b0000000000000001000000000

View file

@ -66,7 +66,20 @@ static noasan textwindows void SetTrueColor(void) {
}
static noasan textwindows void MakeLongDoubleLongAgain(void) {
int x87cw = 0x037f; /* let's hope win32 won't undo this */
/* 8087 FPU Control Word
IM: Invalid Operation
DM: Denormal Operand
ZM: Zero Divide
OM: Overflow
UM: Underflow
PM: Precision
PC: Precision Control
{float,,double,long double}
RC: Rounding Control
{even, -, +, 0}
drr*/
int x87cw = 0b0000000000000000001101111111;
asm volatile("fldcw\t%0" : /* no outputs */ : "m"(x87cw));
}