authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-03 02:54:36-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-06-03 02:54:36-04:00
log597dd328e3a66a6245320121843933e9436183c5
treeb90f3810701460f1ef067d8efae0b3c24bdda265
parent2543e2d97c323fb4ec04e134005267252a2c96ed
parent7bc3f294ce517d9c9947718e4d8995ce349bdd04
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #24034 from papparapa/remove-musl-trigonometric-function

libc: replace musl's and MinGW's trigonometric functions with compiler_rt's

19 files changed, 2 insertions(+), 802 deletions(-)

lib/libc/mingw/math/arm/sincos.S+1-3
......@@ -8,11 +8,9 @@
88 .file "sincos.S"
99 .text
1010 .align 2
11 .globl __MINGW_USYMBOL(sincos)
11 /* zig patch: remove sincos symbol because sincos in compiler_rt is used instead */
1212 .globl __MINGW_USYMBOL(sincosl)
13 .def __MINGW_USYMBOL(sincos); .scl 2; .type 32; .endef
1413 .def __MINGW_USYMBOL(sincosl); .scl 2; .type 32; .endef
15__MINGW_USYMBOL(sincos):
1614__MINGW_USYMBOL(sincosl):
1715 push {r4, r5, r11, lr}
1816 add r11, sp, #8
lib/libc/mingw/math/arm/sincosf.S deleted-29
......@@ -1,29 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <_mingw_mac.h>
7
8 .file "sincosf.S"
9 .text
10 .align 2
11 .globl __MINGW_USYMBOL(sincosf)
12 .def __MINGW_USYMBOL(sincosf); .scl 2; .type 32; .endef
13__MINGW_USYMBOL(sincosf):
14 push {r4, r5, r11, lr}
15 add r11, sp, #8
16 vpush {d8}
17
18 mov r4, r0
19 mov r5, r1
20 vmov.f32 s16, s0
21 bl sinf
22 vstr s0, [r4]
23
24 vmov.f32 s0, s16
25 bl cosf
26 vstr s0, [r5]
27
28 vpop {d8}
29 pop {r4, r5, r11, pc}
lib/libc/mingw/math/arm64/sincos.S+1-3
......@@ -8,11 +8,9 @@
88 .file "sincos.S"
99 .text
1010 .align 2
11 .globl __MINGW_USYMBOL(sincos)
11 /* zig patch: remove sincos symbol because sincos in compiler_rt is used instead */
1212 .globl __MINGW_USYMBOL(sincosl)
13 .def __MINGW_USYMBOL(sincos); .scl 2; .type 32; .endef
1413 .def __MINGW_USYMBOL(sincosl); .scl 2; .type 32; .endef
15__MINGW_USYMBOL(sincos):
1614__MINGW_USYMBOL(sincosl):
1715 str d8, [sp, #-32]!
1816 str x30, [sp, #8]
lib/libc/mingw/math/arm64/sincosf.S deleted-31
......@@ -1,31 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <_mingw_mac.h>
7
8 .file "sincosf.S"
9 .text
10 .align 2
11 .globl __MINGW_USYMBOL(sincosf)
12 .def __MINGW_USYMBOL(sincosf); .scl 2; .type 32; .endef
13__MINGW_USYMBOL(sincosf):
14 str d8, [sp, #-32]!
15 str x30, [sp, #8]
16 stp x19, x20, [sp, #16]
17
18 mov x19, x0
19 mov x20, x1
20 fmov s8, s0
21 bl sinf
22 str s0, [x19]
23
24 fmov s0, s8
25 bl cosf
26 str s0, [x20]
27
28 ldp x19, x20, [sp, #16]
29 ldr x30, [sp, #8]
30 ldr d8, [sp], #32
31 ret
lib/libc/mingw/math/x86/cosf.c deleted-11
......@@ -1,11 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <math.h>
7
8float cosf(float _X)
9{
10 return ((float)cos((double)_X));
11}
lib/libc/mingw/math/x86/cossin.c deleted-52
......@@ -1,52 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7void sincos (double __x, double *p_sin, double *p_cos);
8void sincosf (float __x, float *p_sin, float *p_cos);
9
10void sincos (double __x, double *p_sin, double *p_cos)
11{
12 long double c, s;
13
14 __asm__ __volatile__ ("fsincos\n\t"
15 "fnstsw %%ax\n\t"
16 "testl $0x400, %%eax\n\t"
17 "jz 1f\n\t"
18 "fldpi\n\t"
19 "fadd %%st(0)\n\t"
20 "fxch %%st(1)\n\t"
21 "2: fprem1\n\t"
22 "fnstsw %%ax\n\t"
23 "testl $0x400, %%eax\n\t"
24 "jnz 2b\n\t"
25 "fstp %%st(1)\n\t"
26 "fsincos\n\t"
27 "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
28 *p_sin = (double) s;
29 *p_cos = (double) c;
30}
31
32void sincosf (float __x, float *p_sin, float *p_cos)
33{
34 long double c, s;
35
36 __asm__ __volatile__ ("fsincos\n\t"
37 "fnstsw %%ax\n\t"
38 "testl $0x400, %%eax\n\t"
39 "jz 1f\n\t"
40 "fldpi\n\t"
41 "fadd %%st(0)\n\t"
42 "fxch %%st(1)\n\t"
43 "2: fprem1\n\t"
44 "fnstsw %%ax\n\t"
45 "testl $0x400, %%eax\n\t"
46 "jnz 2b\n\t"
47 "fstp %%st(1)\n\t"
48 "fsincos\n\t"
49 "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
50 *p_sin = (float) s;
51 *p_cos = (float) c;
52}
lib/libc/mingw/math/x86/sinf.c deleted-11
......@@ -1,11 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <math.h>
7
8float sinf(float _X)
9{
10 return ((float) sin ((double) _X));
11}
lib/libc/mingw/math/x86/tanf.c deleted-11
......@@ -1,11 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <math.h>
7
8float tanf(float _X)
9{
10 return ((float)tan((double)_X));
11}
lib/libc/musl/src/math/cos.c deleted-77
......@@ -1,77 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12/* cos(x)
13 * Return cosine function of x.
14 *
15 * kernel function:
16 * __sin ... sine function on [-pi/4,pi/4]
17 * __cos ... cosine function on [-pi/4,pi/4]
18 * __rem_pio2 ... argument reduction routine
19 *
20 * Method.
21 * Let S,C and T denote the sin, cos and tan respectively on
22 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
23 * in [-pi/4 , +pi/4], and let n = k mod 4.
24 * We have
25 *
26 * n sin(x) cos(x) tan(x)
27 * ----------------------------------------------------------
28 * 0 S C T
29 * 1 C -S -1/T
30 * 2 -S -C T
31 * 3 -C S -1/T
32 * ----------------------------------------------------------
33 *
34 * Special cases:
35 * Let trig be any of sin, cos, or tan.
36 * trig(+-INF) is NaN, with signals;
37 * trig(NaN) is that NaN;
38 *
39 * Accuracy:
40 * TRIG(x) returns trig(x) nearly rounded
41 */
42
43#include "libm.h"
44
45double cos(double x)
46{
47 double y[2];
48 uint32_t ix;
49 unsigned n;
50
51 GET_HIGH_WORD(ix, x);
52 ix &= 0x7fffffff;
53
54 /* |x| ~< pi/4 */
55 if (ix <= 0x3fe921fb) {
56 if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */
57 /* raise inexact if x!=0 */
58 FORCE_EVAL(x + 0x1p120f);
59 return 1.0;
60 }
61 return __cos(x, 0);
62 }
63
64 /* cos(Inf or NaN) is NaN */
65 if (ix >= 0x7ff00000)
66 return x-x;
67
68 /* argument reduction */
69 n = __rem_pio2(x, y);
70 switch (n&3) {
71 case 0: return __cos(y[0], y[1]);
72 case 1: return -__sin(y[0], y[1], 1);
73 case 2: return -__cos(y[0], y[1]);
74 default:
75 return __sin(y[0], y[1], 1);
76 }
77}
lib/libc/musl/src/math/cosf.c deleted-78
......@@ -1,78 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_cosf.c */
2/*
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * Optimized by Bruce D. Evans.
5 */
6/*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 *
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
15 */
16
17#include "libm.h"
18
19/* Small multiples of pi/2 rounded to double precision. */
20static const double
21c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
22c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
23c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
24c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
25
26float cosf(float x)
27{
28 double y;
29 uint32_t ix;
30 unsigned n, sign;
31
32 GET_FLOAT_WORD(ix, x);
33 sign = ix >> 31;
34 ix &= 0x7fffffff;
35
36 if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
37 if (ix < 0x39800000) { /* |x| < 2**-12 */
38 /* raise inexact if x != 0 */
39 FORCE_EVAL(x + 0x1p120f);
40 return 1.0f;
41 }
42 return __cosdf(x);
43 }
44 if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
45 if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
46 return -__cosdf(sign ? x+c2pio2 : x-c2pio2);
47 else {
48 if (sign)
49 return __sindf(x + c1pio2);
50 else
51 return __sindf(c1pio2 - x);
52 }
53 }
54 if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
55 if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
56 return __cosdf(sign ? x+c4pio2 : x-c4pio2);
57 else {
58 if (sign)
59 return __sindf(-x - c3pio2);
60 else
61 return __sindf(x - c3pio2);
62 }
63 }
64
65 /* cos(Inf or NaN) is NaN */
66 if (ix >= 0x7f800000)
67 return x-x;
68
69 /* general argument reduction needed */
70 n = __rem_pio2f(x,&y);
71 switch (n&3) {
72 case 0: return __cosdf(y);
73 case 1: return __sindf(-y);
74 case 2: return -__cosdf(y);
75 default:
76 return __sindf(y);
77 }
78}
lib/libc/musl/src/math/sin.c deleted-78
......@@ -1,78 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12/* sin(x)
13 * Return sine function of x.
14 *
15 * kernel function:
16 * __sin ... sine function on [-pi/4,pi/4]
17 * __cos ... cose function on [-pi/4,pi/4]
18 * __rem_pio2 ... argument reduction routine
19 *
20 * Method.
21 * Let S,C and T denote the sin, cos and tan respectively on
22 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
23 * in [-pi/4 , +pi/4], and let n = k mod 4.
24 * We have
25 *
26 * n sin(x) cos(x) tan(x)
27 * ----------------------------------------------------------
28 * 0 S C T
29 * 1 C -S -1/T
30 * 2 -S -C T
31 * 3 -C S -1/T
32 * ----------------------------------------------------------
33 *
34 * Special cases:
35 * Let trig be any of sin, cos, or tan.
36 * trig(+-INF) is NaN, with signals;
37 * trig(NaN) is that NaN;
38 *
39 * Accuracy:
40 * TRIG(x) returns trig(x) nearly rounded
41 */
42
43#include "libm.h"
44
45double sin(double x)
46{
47 double y[2];
48 uint32_t ix;
49 unsigned n;
50
51 /* High word of x. */
52 GET_HIGH_WORD(ix, x);
53 ix &= 0x7fffffff;
54
55 /* |x| ~< pi/4 */
56 if (ix <= 0x3fe921fb) {
57 if (ix < 0x3e500000) { /* |x| < 2**-26 */
58 /* raise inexact if x != 0 and underflow if subnormal*/
59 FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
60 return x;
61 }
62 return __sin(x, 0.0, 0);
63 }
64
65 /* sin(Inf or NaN) is NaN */
66 if (ix >= 0x7ff00000)
67 return x - x;
68
69 /* argument reduction needed */
70 n = __rem_pio2(x, y);
71 switch (n&3) {
72 case 0: return __sin(y[0], y[1], 1);
73 case 1: return __cos(y[0], y[1]);
74 case 2: return -__sin(y[0], y[1], 1);
75 default:
76 return -__cos(y[0], y[1]);
77 }
78}
lib/libc/musl/src/math/sincos.c deleted-69
......@@ -1,69 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13#define _GNU_SOURCE
14#include "libm.h"
15
16void sincos(double x, double *sin, double *cos)
17{
18 double y[2], s, c;
19 uint32_t ix;
20 unsigned n;
21
22 GET_HIGH_WORD(ix, x);
23 ix &= 0x7fffffff;
24
25 /* |x| ~< pi/4 */
26 if (ix <= 0x3fe921fb) {
27 /* if |x| < 2**-27 * sqrt(2) */
28 if (ix < 0x3e46a09e) {
29 /* raise inexact if x!=0 and underflow if subnormal */
30 FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
31 *sin = x;
32 *cos = 1.0;
33 return;
34 }
35 *sin = __sin(x, 0.0, 0);
36 *cos = __cos(x, 0.0);
37 return;
38 }
39
40 /* sincos(Inf or NaN) is NaN */
41 if (ix >= 0x7ff00000) {
42 *sin = *cos = x - x;
43 return;
44 }
45
46 /* argument reduction needed */
47 n = __rem_pio2(x, y);
48 s = __sin(y[0], y[1], 1);
49 c = __cos(y[0], y[1]);
50 switch (n&3) {
51 case 0:
52 *sin = s;
53 *cos = c;
54 break;
55 case 1:
56 *sin = c;
57 *cos = -s;
58 break;
59 case 2:
60 *sin = -s;
61 *cos = -c;
62 break;
63 case 3:
64 default:
65 *sin = -c;
66 *cos = s;
67 break;
68 }
69}
lib/libc/musl/src/math/sincosf.c deleted-117
......@@ -1,117 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
2/*
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * Optimized by Bruce D. Evans.
5 */
6/*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 *
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
15 */
16
17#define _GNU_SOURCE
18#include "libm.h"
19
20/* Small multiples of pi/2 rounded to double precision. */
21static const double
22s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
23s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
24s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
25s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
26
27void sincosf(float x, float *sin, float *cos)
28{
29 double y;
30 float_t s, c;
31 uint32_t ix;
32 unsigned n, sign;
33
34 GET_FLOAT_WORD(ix, x);
35 sign = ix >> 31;
36 ix &= 0x7fffffff;
37
38 /* |x| ~<= pi/4 */
39 if (ix <= 0x3f490fda) {
40 /* |x| < 2**-12 */
41 if (ix < 0x39800000) {
42 /* raise inexact if x!=0 and underflow if subnormal */
43 FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
44 *sin = x;
45 *cos = 1.0f;
46 return;
47 }
48 *sin = __sindf(x);
49 *cos = __cosdf(x);
50 return;
51 }
52
53 /* |x| ~<= 5*pi/4 */
54 if (ix <= 0x407b53d1) {
55 if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
56 if (sign) {
57 *sin = -__cosdf(x + s1pio2);
58 *cos = __sindf(x + s1pio2);
59 } else {
60 *sin = __cosdf(s1pio2 - x);
61 *cos = __sindf(s1pio2 - x);
62 }
63 return;
64 }
65 /* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */
66 *sin = -__sindf(sign ? x + s2pio2 : x - s2pio2);
67 *cos = -__cosdf(sign ? x + s2pio2 : x - s2pio2);
68 return;
69 }
70
71 /* |x| ~<= 9*pi/4 */
72 if (ix <= 0x40e231d5) {
73 if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
74 if (sign) {
75 *sin = __cosdf(x + s3pio2);
76 *cos = -__sindf(x + s3pio2);
77 } else {
78 *sin = -__cosdf(x - s3pio2);
79 *cos = __sindf(x - s3pio2);
80 }
81 return;
82 }
83 *sin = __sindf(sign ? x + s4pio2 : x - s4pio2);
84 *cos = __cosdf(sign ? x + s4pio2 : x - s4pio2);
85 return;
86 }
87
88 /* sin(Inf or NaN) is NaN */
89 if (ix >= 0x7f800000) {
90 *sin = *cos = x - x;
91 return;
92 }
93
94 /* general argument reduction needed */
95 n = __rem_pio2f(x, &y);
96 s = __sindf(y);
97 c = __cosdf(y);
98 switch (n&3) {
99 case 0:
100 *sin = s;
101 *cos = c;
102 break;
103 case 1:
104 *sin = c;
105 *cos = -s;
106 break;
107 case 2:
108 *sin = -s;
109 *cos = -c;
110 break;
111 case 3:
112 default:
113 *sin = -c;
114 *cos = s;
115 break;
116 }
117}
lib/libc/musl/src/math/sinf.c deleted-76
......@@ -1,76 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
2/*
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * Optimized by Bruce D. Evans.
5 */
6/*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 *
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
15 */
16
17#include "libm.h"
18
19/* Small multiples of pi/2 rounded to double precision. */
20static const double
21s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
22s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
23s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
24s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
25
26float sinf(float x)
27{
28 double y;
29 uint32_t ix;
30 int n, sign;
31
32 GET_FLOAT_WORD(ix, x);
33 sign = ix >> 31;
34 ix &= 0x7fffffff;
35
36 if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
37 if (ix < 0x39800000) { /* |x| < 2**-12 */
38 /* raise inexact if x!=0 and underflow if subnormal */
39 FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
40 return x;
41 }
42 return __sindf(x);
43 }
44 if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
45 if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
46 if (sign)
47 return -__cosdf(x + s1pio2);
48 else
49 return __cosdf(x - s1pio2);
50 }
51 return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2));
52 }
53 if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
54 if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
55 if (sign)
56 return __cosdf(x + s3pio2);
57 else
58 return -__cosdf(x - s3pio2);
59 }
60 return __sindf(sign ? x + s4pio2 : x - s4pio2);
61 }
62
63 /* sin(Inf or NaN) is NaN */
64 if (ix >= 0x7f800000)
65 return x - x;
66
67 /* general argument reduction needed */
68 n = __rem_pio2f(x, &y);
69 switch (n&3) {
70 case 0: return __sindf(y);
71 case 1: return __cosdf(y);
72 case 2: return __sindf(-y);
73 default:
74 return -__cosdf(y);
75 }
76}
lib/libc/musl/src/math/tan.c deleted-70
......@@ -1,70 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12/* tan(x)
13 * Return tangent function of x.
14 *
15 * kernel function:
16 * __tan ... tangent function on [-pi/4,pi/4]
17 * __rem_pio2 ... argument reduction routine
18 *
19 * Method.
20 * Let S,C and T denote the sin, cos and tan respectively on
21 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
22 * in [-pi/4 , +pi/4], and let n = k mod 4.
23 * We have
24 *
25 * n sin(x) cos(x) tan(x)
26 * ----------------------------------------------------------
27 * 0 S C T
28 * 1 C -S -1/T
29 * 2 -S -C T
30 * 3 -C S -1/T
31 * ----------------------------------------------------------
32 *
33 * Special cases:
34 * Let trig be any of sin, cos, or tan.
35 * trig(+-INF) is NaN, with signals;
36 * trig(NaN) is that NaN;
37 *
38 * Accuracy:
39 * TRIG(x) returns trig(x) nearly rounded
40 */
41
42#include "libm.h"
43
44double tan(double x)
45{
46 double y[2];
47 uint32_t ix;
48 unsigned n;
49
50 GET_HIGH_WORD(ix, x);
51 ix &= 0x7fffffff;
52
53 /* |x| ~< pi/4 */
54 if (ix <= 0x3fe921fb) {
55 if (ix < 0x3e400000) { /* |x| < 2**-27 */
56 /* raise inexact if x!=0 and underflow if subnormal */
57 FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
58 return x;
59 }
60 return __tan(x, 0.0, 0);
61 }
62
63 /* tan(Inf or NaN) is NaN */
64 if (ix >= 0x7ff00000)
65 return x - x;
66
67 /* argument reduction */
68 n = __rem_pio2(x, y);
69 return __tan(y[0], y[1], n&1);
70}
lib/libc/musl/src/math/tanf.c deleted-64
......@@ -1,64 +0,0 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_tanf.c */
2/*
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * Optimized by Bruce D. Evans.
5 */
6/*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 *
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
15 */
16
17#include "libm.h"
18
19/* Small multiples of pi/2 rounded to double precision. */
20static const double
21t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
22t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
23t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
24t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
25
26float tanf(float x)
27{
28 double y;
29 uint32_t ix;
30 unsigned n, sign;
31
32 GET_FLOAT_WORD(ix, x);
33 sign = ix >> 31;
34 ix &= 0x7fffffff;
35
36 if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
37 if (ix < 0x39800000) { /* |x| < 2**-12 */
38 /* raise inexact if x!=0 and underflow if subnormal */
39 FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
40 return x;
41 }
42 return __tandf(x, 0);
43 }
44 if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
45 if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */
46 return __tandf((sign ? x+t1pio2 : x-t1pio2), 1);
47 else
48 return __tandf((sign ? x+t2pio2 : x-t2pio2), 0);
49 }
50 if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
51 if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */
52 return __tandf((sign ? x+t3pio2 : x-t3pio2), 1);
53 else
54 return __tandf((sign ? x+t4pio2 : x-t4pio2), 0);
55 }
56
57 /* tan(Inf or NaN) is NaN */
58 if (ix >= 0x7f800000)
59 return x - x;
60
61 /* argument reduction */
62 n = __rem_pio2f(x, &y);
63 return __tandf(y, n&1);
64}
src/libs/mingw.zig-6
......@@ -916,7 +916,6 @@ const mingw32_x86_src = [_][]const u8{
916916 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
917917 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
918918 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
919 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossin.c",
920919 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
921920 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S",
922921 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c",
......@@ -965,11 +964,8 @@ const mingw32_x86_32_src = [_][]const u8{
965964 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",
966965 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",
967966 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S",
968 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosf.c",
969967 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorf.S",
970968 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",
971 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinf.c",
972 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanf.c",
973969};
974970
975971const mingw32_arm_src = [_][]const u8{
......@@ -983,7 +979,6 @@ const mingw32_arm32_src = [_][]const u8{
983979 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c",
984980 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c",
985981 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S",
986 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincosf.S",
987982};
988983
989984const mingw32_arm64_src = [_][]const u8{
......@@ -992,7 +987,6 @@ const mingw32_arm64_src = [_][]const u8{
992987 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c",
993988 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c",
994989 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S",
995 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincosf.S",
996990};
997991
998992const mingw32_winpthreads_src = [_][]const u8{
src/libs/musl.zig-8
......@@ -886,9 +886,7 @@ const src_files = [_][]const u8{
886886 "musl/src/math/copysignf.c",
887887 "musl/src/math/copysignl.c",
888888 "musl/src/math/__cos.c",
889 "musl/src/math/cos.c",
890889 "musl/src/math/__cosdf.c",
891 "musl/src/math/cosf.c",
892890 "musl/src/math/cosh.c",
893891 "musl/src/math/coshf.c",
894892 "musl/src/math/coshl.c",
......@@ -1194,12 +1192,8 @@ const src_files = [_][]const u8{
11941192 "musl/src/math/significand.c",
11951193 "musl/src/math/significandf.c",
11961194 "musl/src/math/__sin.c",
1197 "musl/src/math/sin.c",
1198 "musl/src/math/sincos.c",
1199 "musl/src/math/sincosf.c",
12001195 "musl/src/math/sincosl.c",
12011196 "musl/src/math/__sindf.c",
1202 "musl/src/math/sinf.c",
12031197 "musl/src/math/sinh.c",
12041198 "musl/src/math/sinhf.c",
12051199 "musl/src/math/sinhl.c",
......@@ -1210,9 +1204,7 @@ const src_files = [_][]const u8{
12101204 "musl/src/math/sqrtf.c",
12111205 "musl/src/math/sqrtl.c",
12121206 "musl/src/math/__tan.c",
1213 "musl/src/math/tan.c",
12141207 "musl/src/math/__tandf.c",
1215 "musl/src/math/tanf.c",
12161208 "musl/src/math/tanh.c",
12171209 "musl/src/math/tanhf.c",
12181210 "musl/src/math/tanhl.c",
src/libs/wasi_libc.zig-8
......@@ -728,9 +728,7 @@ const libc_top_half_src_files = [_][]const u8{
728728 "musl/src/math/ceill.c",
729729 "musl/src/math/copysignl.c",
730730 "musl/src/math/__cos.c",
731 "musl/src/math/cos.c",
732731 "musl/src/math/__cosdf.c",
733 "musl/src/math/cosf.c",
734732 "musl/src/math/coshl.c",
735733 "musl/src/math/__cosl.c",
736734 "musl/src/math/cosl.c",
......@@ -871,21 +869,15 @@ const libc_top_half_src_files = [_][]const u8{
871869 "musl/src/math/significand.c",
872870 "musl/src/math/significandf.c",
873871 "musl/src/math/__sin.c",
874 "musl/src/math/sin.c",
875 "musl/src/math/sincos.c",
876 "musl/src/math/sincosf.c",
877872 "musl/src/math/sincosl.c",
878873 "musl/src/math/__sindf.c",
879 "musl/src/math/sinf.c",
880874 "musl/src/math/sinhl.c",
881875 "musl/src/math/__sinl.c",
882876 "musl/src/math/sinl.c",
883877 "musl/src/math/sqrt_data.c",
884878 "musl/src/math/sqrtl.c",
885879 "musl/src/math/__tan.c",
886 "musl/src/math/tan.c",
887880 "musl/src/math/__tandf.c",
888 "musl/src/math/tanf.c",
889881 "musl/src/math/tanh.c",
890882 "musl/src/math/tanhf.c",
891883 "musl/src/math/tanhl.c",