| author | |
| committer | |
| log | 3dc2a1f9ac572e1205cc2202e12f4d948ca67fd5 |
| tree | bb9bf1add91a7ea0ca69b193b79d907f4650d24a |
| parent | 4ea99049230b5be00ca5a09d3a3fd78ecba30594 |
6 files changed, 6 insertions(+), 91 deletions(-)
lib/c/math.zig+5| ... | @@ -51,6 +51,7 @@ comptime { | ... | @@ -51,6 +51,7 @@ comptime { |
| 51 | symbol(&pow, "pow"); | 51 | symbol(&pow, "pow"); |
| 52 | symbol(&pow10, "pow10"); | 52 | symbol(&pow10, "pow10"); |
| 53 | symbol(&pow10f, "pow10f"); | 53 | symbol(&pow10f, "pow10f"); |
| 54 | symbol(&acosf, "acosf"); | ||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | if (builtin.target.isMuslLibC()) { | 57 | if (builtin.target.isMuslLibC()) { |
| ... | @@ -84,6 +85,10 @@ fn atanl(x: c_longdouble) callconv(.c) c_longdouble { | ... | @@ -84,6 +85,10 @@ fn atanl(x: c_longdouble) callconv(.c) c_longdouble { |
| 84 | }; | 85 | }; |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 88 | fn acosf(x: f32) callconv(.c) f32 { | ||
| 89 | return std.math.acos(x); | ||
| 90 | } | ||
| 91 | |||
| 87 | fn isnan(x: f64) callconv(.c) c_int { | 92 | fn isnan(x: f64) callconv(.c) c_int { |
| 88 | return if (math.isNan(x)) 1 else 0; | 93 | return if (math.isNan(x)) 1 else 0; |
| 89 | } | 94 | } |
lib/libc/musl/src/math/acosf.c deleted-71| ... | @@ -1,71 +0,0 @@ | ||
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/e_acosf.c */ | ||
| 2 | /* | ||
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | */ | ||
| 5 | /* | ||
| 6 | * ==================================================== | ||
| 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 8 | * | ||
| 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 10 | * Permission to use, copy, modify, and distribute this | ||
| 11 | * software is freely granted, provided that this notice | ||
| 12 | * is preserved. | ||
| 13 | * ==================================================== | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include "libm.h" | ||
| 17 | |||
| 18 | static const float | ||
| 19 | pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ | ||
| 20 | pio2_lo = 7.5497894159e-08, /* 0x33a22168 */ | ||
| 21 | pS0 = 1.6666586697e-01, | ||
| 22 | pS1 = -4.2743422091e-02, | ||
| 23 | pS2 = -8.6563630030e-03, | ||
| 24 | qS1 = -7.0662963390e-01; | ||
| 25 | |||
| 26 | static float R(float z) | ||
| 27 | { | ||
| 28 | 	float_t p, q; | ||
| 29 | 	p = z*(pS0+z*(pS1+z*pS2)); | ||
| 30 | 	q = 1.0f+z*qS1; | ||
| 31 | 	return p/q; | ||
| 32 | } | ||
| 33 | |||
| 34 | float acosf(float x) | ||
| 35 | { | ||
| 36 | 	float z,w,s,c,df; | ||
| 37 | 	uint32_t hx,ix; | ||
| 38 | |||
| 39 | 	GET_FLOAT_WORD(hx, x); | ||
| 40 | 	ix = hx & 0x7fffffff; | ||
| 41 | 	/* |x| >= 1 or nan */ | ||
| 42 | 	if (ix >= 0x3f800000) { | ||
| 43 | 		if (ix == 0x3f800000) { | ||
| 44 | 			if (hx >> 31) | ||
| 45 | 				return 2*pio2_hi + 0x1p-120f; | ||
| 46 | 			return 0; | ||
| 47 | 		} | ||
| 48 | 		return 0/(x-x); | ||
| 49 | 	} | ||
| 50 | 	/* |x| < 0.5 */ | ||
| 51 | 	if (ix < 0x3f000000) { | ||
| 52 | 		if (ix <= 0x32800000) /* |x| < 2**-26 */ | ||
| 53 | 			return pio2_hi + 0x1p-120f; | ||
| 54 | 		return pio2_hi - (x - (pio2_lo-x*R(x*x))); | ||
| 55 | 	} | ||
| 56 | 	/* x < -0.5 */ | ||
| 57 | 	if (hx >> 31) { | ||
| 58 | 		z = (1+x)*0.5f; | ||
| 59 | 		s = sqrtf(z); | ||
| 60 | 		w = R(z)*s-pio2_lo; | ||
| 61 | 		return 2*(pio2_hi - (s+w)); | ||
| 62 | 	} | ||
| 63 | 	/* x > 0.5 */ | ||
| 64 | 	z = (1-x)*0.5f; | ||
| 65 | 	s = sqrtf(z); | ||
| 66 | 	GET_FLOAT_WORD(hx,s); | ||
| 67 | 	SET_FLOAT_WORD(df,hx&0xfffff000); | ||
| 68 | 	c = (z-df*df)/(s+df); | ||
| 69 | 	w = R(z)*s+c; | ||
| 70 | 	return 2*(df+w); | ||
| 71 | } | ||
lib/libc/musl/src/math/i386/acosf.s deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | .global acosf | ||
| 2 | .type acosf,@function | ||
| 3 | acosf: | ||
| 4 | 	flds 4(%esp) | ||
| 5 | 	fld %st(0) | ||
| 6 | 	fld1 | ||
| 7 | 	fsub %st(0),%st(1) | ||
| 8 | 	fadd %st(2) | ||
| 9 | 	fmulp | ||
| 10 | 	fsqrt | ||
| 11 | 	fabs # fix sign of zero (matters in downward rounding mode) | ||
| 12 | 	fxch %st(1) | ||
| 13 | 	fpatan | ||
| 14 | 	fstps 4(%esp) | ||
| 15 | 	flds 4(%esp) | ||
| 16 | 	ret | ||
src/libs/musl.zig-2| ... | @@ -798,7 +798,6 @@ const src_files = [_][]const u8{ | ... | @@ -798,7 +798,6 @@ const src_files = [_][]const u8{ |
| 798 | "musl/src/math/aarch64/nearbyint.c", | 798 | "musl/src/math/aarch64/nearbyint.c", |
| 799 | "musl/src/math/aarch64/nearbyintf.c", | 799 | "musl/src/math/aarch64/nearbyintf.c", |
| 800 | "musl/src/math/aarch64/rintf.c", | 800 | "musl/src/math/aarch64/rintf.c", |
| 801 | "musl/src/math/acosf.c", | ||
| 802 | "musl/src/math/acosh.c", | 801 | "musl/src/math/acosh.c", |
| 803 | "musl/src/math/acoshf.c", | 802 | "musl/src/math/acoshf.c", |
| 804 | "musl/src/math/acoshl.c", | 803 | "musl/src/math/acoshl.c", |
| ... | @@ -852,7 +851,6 @@ const src_files = [_][]const u8{ | ... | @@ -852,7 +851,6 @@ const src_files = [_][]const u8{ |
| 852 | "musl/src/math/frexp.c", | 851 | "musl/src/math/frexp.c", |
| 853 | "musl/src/math/frexpf.c", | 852 | "musl/src/math/frexpf.c", |
| 854 | "musl/src/math/frexpl.c", | 853 | "musl/src/math/frexpl.c", |
| 855 | "musl/src/math/i386/acosf.s", | ||
| 856 | "musl/src/math/i386/acosl.s", | 854 | "musl/src/math/i386/acosl.s", |
| 857 | "musl/src/math/i386/asinf.s", | 855 | "musl/src/math/i386/asinf.s", |
| 858 | "musl/src/math/i386/asinl.s", | 856 | "musl/src/math/i386/asinl.s", |
src/libs/wasi_libc.zig-1| ... | @@ -664,7 +664,6 @@ const libc_top_half_src_files = [_][]const u8{ | ... | @@ -664,7 +664,6 @@ const libc_top_half_src_files = [_][]const u8{ |
| 664 | "musl/src/locale/strtod_l.c", | 664 | "musl/src/locale/strtod_l.c", |
| 665 | "musl/src/locale/wcscoll.c", | 665 | "musl/src/locale/wcscoll.c", |
| 666 | "musl/src/locale/wcsxfrm.c", | 666 | "musl/src/locale/wcsxfrm.c", |
| 667 | "musl/src/math/acosf.c", | ||
| 668 | "musl/src/math/acosh.c", | 667 | "musl/src/math/acosh.c", |
| 669 | "musl/src/math/acoshf.c", | 668 | "musl/src/math/acoshf.c", |
| 670 | "musl/src/math/acoshl.c", | 669 | "musl/src/math/acoshl.c", |
test/libc.zig+1-1| ... | @@ -139,7 +139,7 @@ pub fn addCases(cases: *tests.LibcContext) void { | ... | @@ -139,7 +139,7 @@ pub fn addCases(cases: *tests.LibcContext) void { |
| 139 | cases.addLibcTestCase("regression/wcsstr-false-negative.c", true, .{}); | 139 | cases.addLibcTestCase("regression/wcsstr-false-negative.c", true, .{}); |
| 140 | 140 | ||
| 141 | cases.addLibcTestCase("math/acos.c", true, .{}); | 141 | cases.addLibcTestCase("math/acos.c", true, .{}); |
| 142 | // cases.addLibcTestCase("math/acosf.c", true, .{}); | 142 | cases.addLibcTestCase("math/acosf.c", true, .{}); |
| 143 | // cases.addLibcTestCase("math/acosh.c", true, .{}); | 143 | // cases.addLibcTestCase("math/acosh.c", true, .{}); |
| 144 | cases.addLibcTestCase("math/acoshf.c", true, .{}); | 144 | cases.addLibcTestCase("math/acoshf.c", true, .{}); |
| 145 | // cases.addLibcTestCase("math/acoshl.c", true, .{}); | 145 | // cases.addLibcTestCase("math/acoshl.c", true, .{}); |