39
40 #if defined(__sparc)
41
42 #include "fma.h"
43 #include "fenv_inlines.h"
44
45 long long
46 llrintl(long double x) {
47 union {
48 unsigned i[4];
49 long double q;
50 } xx;
51 union {
52 unsigned i[2];
53 long long l;
54 } zz;
55 union {
56 unsigned i;
57 float f;
58 } tt;
59 unsigned int hx, sx, frac;
60 unsigned int fsr;
61 int rm, j;
62 volatile float dummy;
63
64 xx.q = x;
65 sx = xx.i[0] & 0x80000000;
66 hx = xx.i[0] & ~0x80000000;
67
68 /* handle trivial cases */
69 if (hx > 0x403e0000) { /* |x| > 2^63 + ... or x is nan */
70 /* convert an out-of-range float */
71 tt.i = sx | 0x7f000000;
72 return ((long long) tt.f);
73 } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0) /* x is zero */
74 return (0LL);
75
76 /* get the rounding mode */
77 __fenv_getfsr32(&fsr);
78 rm = fsr >> 30;
79
80 /* flip the sense of directed roundings if x is negative */
|
39
40 #if defined(__sparc)
41
42 #include "fma.h"
43 #include "fenv_inlines.h"
44
45 long long
46 llrintl(long double x) {
47 union {
48 unsigned i[4];
49 long double q;
50 } xx;
51 union {
52 unsigned i[2];
53 long long l;
54 } zz;
55 union {
56 unsigned i;
57 float f;
58 } tt;
59 unsigned int hx, sx, frac, fsr;
60 int rm, j;
61 volatile float dummy;
62
63 xx.q = x;
64 sx = xx.i[0] & 0x80000000;
65 hx = xx.i[0] & ~0x80000000;
66
67 /* handle trivial cases */
68 if (hx > 0x403e0000) { /* |x| > 2^63 + ... or x is nan */
69 /* convert an out-of-range float */
70 tt.i = sx | 0x7f000000;
71 return ((long long) tt.f);
72 } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0) /* x is zero */
73 return (0LL);
74
75 /* get the rounding mode */
76 __fenv_getfsr32(&fsr);
77 rm = fsr >> 30;
78
79 /* flip the sense of directed roundings if x is negative */
|