mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-21 20:08:30 +00:00
Introduce support for trapping math
The feenableexcept() and fedisableexcept() APIs are now provided which let you detect when NaNs appear the moment it happens from anywhere in your program. Tests have also been added for the mission critical math functions expf() and erff(), whose perfect operation has been assured. See examples/trapping.c to see how to use this powerful functionality.
This commit is contained in:
parent
403bc25412
commit
5c6877b02b
13 changed files with 576 additions and 2 deletions
|
@ -43,14 +43,55 @@ struct FpuStackEntry {
|
|||
};
|
||||
|
||||
struct thatispacked FpuState {
|
||||
|
||||
/* 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││││││
|
||||
0b0000001001111111 */
|
||||
uint16_t cwd;
|
||||
|
||||
/* 8087 FPU Status Word */
|
||||
uint16_t swd;
|
||||
|
||||
uint16_t ftw;
|
||||
uint16_t fop;
|
||||
uint64_t rip;
|
||||
uint64_t rdp;
|
||||
|
||||
/* SSE CONTROL AND STATUS REGISTER
|
||||
IE: Invalid Operation Flag ──────────────┐
|
||||
DE: Denormal Flag ──────────────────────┐│
|
||||
ZE: Divide-by-Zero Flag ───────────────┐││
|
||||
OE: Overflow Flag ────────────────────┐│││
|
||||
UE: Underflow Flag ──────────────────┐││││
|
||||
PE: Precision Flag ─────────────────┐│││││
|
||||
DAZ: Denormals Are Zeros ──────────┐││││││
|
||||
IM: Invalid Operation Mask ───────┐│││││││
|
||||
DM: Denormal Operation Mask ─────┐││││││││
|
||||
ZM: Divide-by-Zero Mask ────────┐│││││││││
|
||||
OM: Overflow Mask ─────────────┐││││││││││
|
||||
UM: Underflow Mask ───────────┐│││││││││││
|
||||
PM: Precision Mask ──────────┐││││││││││││
|
||||
RC: Rounding Control ───────┐│││││││││││││
|
||||
{even, →-∞, →+∞, →0} ││││││││││││││
|
||||
FTZ: Flush To Zero ───────┐ ││││││││││││││
|
||||
│┌┤│││││││││││││
|
||||
┌──────────────┐││││││││││││││││
|
||||
│ reserved │││││││││││││││││
|
||||
0b00000000000000000001111110000000 */
|
||||
uint32_t mxcsr;
|
||||
uint32_t mxcr_mask;
|
||||
|
||||
struct FpuStackEntry st[8];
|
||||
struct XmmRegister xmm[16];
|
||||
uint32_t __padding[24];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue