rework langinfo code for ABI compat and for use by time code
[musl] / src / math / sinhl.c
1 #include "libm.h"
2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double sinhl(long double x)
5 {
6         return sinh(x);
7 }
8 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
9 long double sinhl(long double x)
10 {
11         union {
12                 long double f;
13                 struct{uint64_t m; uint16_t se; uint16_t pad;} i;
14         } u = {.f = x};
15         unsigned ex = u.i.se & 0x7fff;
16         long double h, t, absx;
17
18         h = 0.5;
19         if (u.i.se & 0x8000)
20                 h = -h;
21         /* |x| */
22         u.i.se = ex;
23         absx = u.f;
24
25         /* |x| < log(LDBL_MAX) */
26         if (ex < 0x3fff+13 || (ex == 0x3fff+13 && u.i.m>>32 < 0xb17217f7)) {
27                 t = expm1l(absx);
28                 if (ex < 0x3fff) {
29                         if (ex < 0x3fff-32)
30                                 return x;
31                         return h*(2*t - t*t/(1+t));
32                 }
33                 return h*(t + t/(t+1));
34         }
35
36         /* |x| > log(LDBL_MAX) or nan */
37         t = expl(0.5*absx);
38         return h*t*t;
39 }
40 #endif