26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #if defined(ELFOBJ)
31 #pragma weak lrintl = __lrintl
32 #endif
33
34 #include <sys/isa_defs.h> /* _ILP32 */
35 #include "libm.h"
36
37 #if defined(_ILP32)
38 #if defined(__sparc)
39
40 #include "fma.h"
41 #include "fenv_inlines.h"
42
43 long
44 lrintl(long double x) {
45 union {
46 unsigned i[4];
47 long double q;
48 } xx;
49 union {
50 unsigned i;
51 float f;
52 } tt;
53 unsigned hx, sx, frac, l;
54 unsigned int fsr;
55 int rm, j;
56 volatile float dummy;
57
58 xx.q = x;
59 sx = xx.i[0] & 0x80000000;
60 hx = xx.i[0] & ~0x80000000;
61
62 /* handle trivial cases */
63 if (hx > 0x401e0000) { /* |x| > 2^31 + ... or x is nan */
64 /* convert an out-of-range float */
65 tt.i = sx | 0x7f000000;
66 return ((long) tt.f);
67 } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0) /* x is zero */
68 return (0L);
69
70 /* get the rounding mode */
71 __fenv_getfsr32(&fsr);
72 rm = fsr >> 30;
73
74 /* flip the sense of directed roundings if x is negative */
|
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #if defined(ELFOBJ)
31 #pragma weak lrintl = __lrintl
32 #endif
33
34 #include <sys/isa_defs.h> /* _ILP32 */
35 #include "libm.h"
36
37 #if defined(_ILP32)
38 #if defined(__sparc)
39
40 #include "fma.h"
41 #include "fenv_inlines.h"
42
43 long
44 lrintl(long double x) {
45 union {
46 unsigned int i[4];
47 long double q;
48 } xx;
49 union {
50 unsigned int i;
51 float f;
52 } tt;
53 unsigned int hx, sx, frac, l, fsr;
54 int rm, j;
55 volatile float dummy;
56
57 xx.q = x;
58 sx = xx.i[0] & 0x80000000;
59 hx = xx.i[0] & ~0x80000000;
60
61 /* handle trivial cases */
62 if (hx > 0x401e0000) { /* |x| > 2^31 + ... or x is nan */
63 /* convert an out-of-range float */
64 tt.i = sx | 0x7f000000;
65 return ((long) tt.f);
66 } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0) /* x is zero */
67 return (0L);
68
69 /* get the rounding mode */
70 __fenv_getfsr32(&fsr);
71 rm = fsr >> 30;
72
73 /* flip the sense of directed roundings if x is negative */
|