commit e6ac1b77f0b958f8cefc6e357620f9fdef2c0eed (tree)
parent c857fce05bb8f0fd8053a5f15825704fb6506fd4
Author: rpkak <rpkak@noreply.codeberg.org>
Date: Tue, 20 Jan 2026 18:02:15 +0100
libzigc: test and fix acos
Diffstat:
4 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/lib/libc/musl/src/math/i386/acos.s b/lib/libc/musl/src/math/i386/acos.s
@@ -1,18 +0,0 @@
-# use acos(x) = atan2(fabs(sqrt((1-x)*(1+x))), x)
-
-.global acos
-.type acos,@function
-acos:
- fldl 4(%esp)
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs # fix sign of zero (matters in downward rounding mode)
- fxch %st(1)
- fpatan
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/std/math/acos.zig b/lib/std/math/acos.zig
@@ -48,7 +48,7 @@ fn acos32(x: f32) f32 {
return 0.0;
}
} else {
- return math.nan(f32);
+ return (x - x) / 0;
}
}
@@ -117,7 +117,7 @@ fn acos64(x: f64) f64 {
}
}
- return math.nan(f64);
+ return (x - x) / 0;
}
// |x| < 0.5
diff --git a/src/libs/musl.zig b/src/libs/musl.zig
@@ -890,7 +890,6 @@ const src_files = [_][]const u8{
"musl/src/math/hypotl.c",
"musl/src/math/i386/acosf.s",
"musl/src/math/i386/acosl.s",
- "musl/src/math/i386/acos.s",
"musl/src/math/i386/asinf.s",
"musl/src/math/i386/asinl.s",
"musl/src/math/i386/asin.s",
diff --git a/test/libc.zig b/test/libc.zig
@@ -138,7 +138,7 @@ pub fn addCases(cases: *tests.LibcContext) void {
cases.addLibcTestCase("regression/wcsncpy-read-overflow.c", true, .{});
cases.addLibcTestCase("regression/wcsstr-false-negative.c", true, .{});
- // cases.addLibcTestCase("math/acos.c", true, .{});
+ cases.addLibcTestCase("math/acos.c", true, .{});
// cases.addLibcTestCase("math/acosf.c", true, .{});
// cases.addLibcTestCase("math/acosh.c", true, .{});
cases.addLibcTestCase("math/acoshf.c", true, .{});