Skip to content

Commit f8fb5a4

Browse files
committed
Added long double math function for Aarch64
1 parent e94d0dc commit f8fb5a4

33 files changed

Lines changed: 103 additions & 96 deletions

winsup/cygwin/math/acosl.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
55
*/
66

7-
#if defined(__aarch64__)
7+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
88
#include <math.h>
99
#endif
1010

@@ -25,8 +25,7 @@ long double acosl (long double x)
2525
"fxch %%st(1)\n\t"
2626
"fpatan"
2727
: "=t" (res) : "0" (x) : "st(1)");
28-
#elif defined(__aarch64__)
29-
// TODO
28+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
3029
res = atanl (sqrtl(1 - x*x) / x);
3130
#endif
3231
return res;

winsup/cygwin/math/asinl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111

1212
/* asin = atan (x / sqrt(1 - x^2)) */
13+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
14+
#include<math.h>
15+
#endif
1316
long double asinl (long double x);
1417

1518
long double asinl (long double x)
@@ -25,9 +28,8 @@ long double asinl (long double x)
2528
"fsqrt\n\t" /* sqrt (1 - x^2) */
2629
"fpatan"
2730
: "=t" (res) : "0" (x) : "st(1)");
28-
#elif defined(__aarch64__)
29-
// TODO
30-
res = 0.0;
31+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
32+
res = (long double)asin((double)x);
3133
#endif
3234
return res;
3335
}

winsup/cygwin/math/atan2l.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* This file is part of the mingw-w64 runtime package.
44
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
55
*/
6+
7+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
8+
#include <math.h>
9+
#endif
10+
611
long double atan2l (long double y, long double x);
712

813
long double
@@ -11,9 +16,8 @@ atan2l (long double y, long double x)
1116
long double res = 0.0L;
1217
#if defined(__x86_64__)
1318
asm volatile ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
14-
#elif defined(__aarch64__)
15-
// TODO
16-
res = 0.0;
19+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
20+
res = (long double)atan2((double)y, (double)x);
1721
#endif
1822
return res;
1923
}

winsup/cygwin/math/atanl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
* This file is part of the mingw-w64 runtime package.
44
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
55
*/
6+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
7+
#include <math.h>
8+
#endif
9+
610
long double atanl (long double x);
711

812
long double
@@ -14,9 +18,8 @@ atanl (long double x)
1418
"fld1\n\t"
1519
"fpatan"
1620
: "=t" (res) : "0" (x));
17-
#elif defined(__aarch64__)
18-
// TODO
19-
res = 0.0;
21+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
22+
res = (long double)atan((double)x);
2023
#endif
2124
return res;
2225
}

winsup/cygwin/math/cephes_mconf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern double __QNAN;
6666
#endif
6767

6868
/*long double*/
69-
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__)
69+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
7070
#define MAXNUML 1.7976931348623158E308
7171
#define MAXLOGL 7.09782712893383996843E2
7272
#define MINLOGL -7.08396418532264106224E2
@@ -84,7 +84,7 @@ extern double __QNAN;
8484
#define PIL 3.1415926535897932384626L
8585
#define PIO2L 1.5707963267948966192313L
8686
#define PIO4L 7.8539816339744830961566E-1L
87-
#endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) */
87+
#endif /* __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ */
8888

8989
#define isfinitel isfinite
9090
#define isinfl isinf

winsup/cygwin/math/cosl_internal.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ __MINGW_USYMBOL(__cosl_internal):
5151
fstp %st(1)
5252
fcos
5353
ret
54-
#else
55-
// TODO
54+
#elif defined(__aarch64__)
55+
b cos
5656
#endif
5757

winsup/cygwin/math/cossin.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
55
*/
66

7+
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
8+
#include <math.h>
9+
#endif
10+
711
void sincos (double __x, double *p_sin, double *p_cos);
812
void sincosl (long double __x, long double *p_sin, long double *p_cos);
913
void sincosf (float __x, float *p_sin, float *p_cos);
@@ -27,10 +31,9 @@ void sincos (double __x, double *p_sin, double *p_cos)
2731
"fstp %%st(1)\n\t"
2832
"fsincos\n\t"
2933
"1:" : "=t" (c), "=u" (s) : "0" (__x));
30-
#elif defined(__aarch64__)
31-
// TODO
32-
c = 0.0;
33-
s = 0.0;
34+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
35+
s = sin(__x);
36+
c = cos(__x);
3437
#endif
3538
*p_sin = (double) s;
3639
*p_cos = (double) c;
@@ -55,10 +58,9 @@ void sincosf (float __x, float *p_sin, float *p_cos)
5558
"fstp %%st(1)\n\t"
5659
"fsincos\n\t"
5760
"1:" : "=t" (c), "=u" (s) : "0" (__x));
58-
#elif defined(__aarch64__)
59-
// TODO
60-
c = 0.0;
61-
s = 0.0;
61+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
62+
s = sinf(__x);
63+
c = cosf(__x);
6264
#endif
6365
*p_sin = (float) s;
6466
*p_cos = (float) c;
@@ -83,10 +85,9 @@ void sincosl (long double __x, long double *p_sin, long double *p_cos)
8385
"fstp %%st(1)\n\t"
8486
"fsincos\n\t"
8587
"1:" : "=t" (c), "=u" (s) : "0" (__x));
86-
#elif defined(__aarch64__)
87-
// TODO
88-
c = 0.0;
89-
s = 0.0;
88+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
89+
s = sin((double)__x);
90+
c = cos((double)__x);
9091
#endif
9192
*p_sin = s;
9293
*p_cos = c;

winsup/cygwin/math/exp.def.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ __expl_internal (long double x)
102102
"fstp %%st(1)\n\t" /* 1 */
103103
"fstp %%st(1)\n\t" /* 0 */
104104
: "=t" (res) : "0" (x), "m" (c0), "m" (c1) : "ax", "dx");
105-
#elif defined(__aarch64__)
106-
// TODO
107-
res = 0.0 * c0 * c1;
105+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
106+
(void)c0;
107+
(void)c1;
108+
res = exp((double)x);
108109
#endif
109110
return res;
110111
}

winsup/cygwin/math/exp2l.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ __MINGW_USYMBOL(exp2l):
8989
fstp %st
9090
fldz /* Set result to 0. */
9191
2: ret
92-
#else
93-
// TODO
92+
#elif defined(__aarch64__)
93+
b exp2
9494
#endif

winsup/cygwin/math/expm1.def.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ __FLT_ABI(expm1) (__FLT_TYPE x)
6767
x /= __FLT_LOGE2;
6868
#if defined(_x86_64__)
6969
__asm__ __volatile__ ("f2xm1" : "=t" (x) : "0" (x));
70-
#elif defined(__aarch64__)
71-
// TODO
72-
x = 0.0;
70+
#elif __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
71+
x = exp2(x) - 1.0;
7372
#endif
7473
return x;
7574
}

0 commit comments

Comments
 (0)