diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-08 19:56:19 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-08 19:56:19 -0400 |
commit | ae42383d5d1c5b2a4306b2991ac13153f7e562bf (patch) | |
tree | 5004930e491a4f1d6f2ecc0b1b4dc3d447f5f5d7 /src/lib/libc/src/musl-math/nearbyintf.c | |
parent | e76431a073907b676518aa6bdd9874a4d8b790b8 (diff) |
libc: Add musl math port
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/lib/libc/src/musl-math/nearbyintf.c')
-rw-r--r-- | src/lib/libc/src/musl-math/nearbyintf.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/libc/src/musl-math/nearbyintf.c b/src/lib/libc/src/musl-math/nearbyintf.c new file mode 100644 index 0000000..092e9ff --- /dev/null +++ b/src/lib/libc/src/musl-math/nearbyintf.c @@ -0,0 +1,18 @@ +#include <fenv.h> +#include <math.h> + +float nearbyintf(float x) +{ +#ifdef FE_INEXACT + #pragma STDC FENV_ACCESS ON + int e; + + e = fetestexcept(FE_INEXACT); +#endif + x = rintf(x); +#ifdef FE_INEXACT + if (!e) + feclearexcept(FE_INEXACT); +#endif + return x; +} |