fix uninitialized variable in new __res_msend dns function
[musl] / src / math / modfl.c
1 #include "libm.h"
2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double modfl(long double x, long double *iptr)
5 {
6         double d;
7         long double r;
8
9         r = modf(x, &d);
10         *iptr = d;
11         return r;
12 }
13 #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
14 #if LDBL_MANT_DIG == 64
15 #define TOINT 0x1p63
16 #elif LDBL_MANT_DIG == 113
17 #define TOINT 0x1p112
18 #endif
19 long double modfl(long double x, long double *iptr)
20 {
21         union ldshape u = {x};
22         int e = (u.i.se & 0x7fff) - 0x3fff;
23         int s = u.i.se >> 15;
24         long double absx;
25         long double y;
26
27         /* no fractional part */
28         if (e >= LDBL_MANT_DIG-1) {
29                 *iptr = x;
30                 if (isnan(x))
31                         return x;
32                 return s ? -0.0 : 0.0;
33         }
34
35         /* no integral part*/
36         if (e < 0) {
37                 *iptr = s ? -0.0 : 0.0;
38                 return x;
39         }
40
41         /* raises spurious inexact */
42         absx = s ? -x : x;
43         y = absx + TOINT - TOINT - absx;
44         if (y == 0) {
45                 *iptr = x;
46                 return s ? -0.0 : 0.0;
47         }
48         if (y > 0)
49                 y -= 1;
50         if (s)
51                 y = -y;
52         *iptr = x + y;
53         return -y;
54 }
55 #endif