mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
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:
parent
cdc54ea1fd
commit
40291c9db3
109 changed files with 2316 additions and 520 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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} │┌┤ ││││││
|
||||
┌┤││ ││││││
|
||||
d││││rr││││││*/
|
||||
int x87cw = 0b0000000000000000001101111111;
|
||||
asm volatile("fldcw\t%0" : /* no outputs */ : "m"(x87cw));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue