diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-15 11:20:40 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-15 11:20:40 -0800 |
| commit | f0a6c6757a795b8e186de0076836a87acef59fa7 (patch) | |
| tree | ef45c1b58093420bbd2de6647274139e46539bfe /chapter31/src/main/c/simple_crt.c | |
| parent | 7e66b7ae6b00a2e1652db32f01f0bf480508ef05 (diff) | |
| download | Simple-f0a6c6757a795b8e186de0076836a87acef59fa7.tar.gz Simple-f0a6c6757a795b8e186de0076836a87acef59fa7.zip | |
Graphics now allow resizemain
Reorganize docs.
Fix bugs X86 LOad+cmp scheduling.
Math intrinsics
Diffstat (limited to 'chapter31/src/main/c/simple_crt.c')
| -rw-r--r-- | chapter31/src/main/c/simple_crt.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/chapter31/src/main/c/simple_crt.c b/chapter31/src/main/c/simple_crt.c index 39708629..e50042c2 100644 --- a/chapter31/src/main/c/simple_crt.c +++ b/chapter31/src/main/c/simple_crt.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <math.h> #include <termios.h> #include <unistd.h> @@ -19,6 +20,15 @@ double simple_f64_from_bits(int64_t bits) { return value; } +// Floating remainder's machine instruction uses this memory-preserving helper. +double simple_f64_mod(double x, double y) { + // fmod can set errno for NaN-producing inputs; arithmetic leaves it alone. + int saved_errno = errno; + double result = fmod(x, y); + errno = saved_errno; + return result; +} + // errno may be thread-local or a macro calling a platform accessor. int32_t simple_errno(void) { return errno; } int32_t simple_set_errno(int32_t error) { errno = error; return -1; } |
