4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #pragma weak __rintf = rintf
34 * aintf(x) return x chopped to integral value
35 * anintf(x) return sign(x)*(|x|+0.5) chopped to integral value
36 * irintf(x) return rint(x) in integer format
37 * nintf(x) return anint(x) in integer format
38 * rintf(x) return x rounded to integral according to the rounding direction
40 * NOTE: rintf(x), aintf(x) and anintf(x) return results with the same sign as
46 static const float xf
[] = {
48 /* TWO_23F */ 8.3886080000e6f
,
49 /* MTWO_23F */ -8.3886080000e6f
,
59 #define MTWO_23F xf[2]
73 k
= (hx
& ~0x80000000) >> 23;
75 y
= (float) ((int) x
);
77 * make sure y has the same sign of x when |x|<0.5
80 return (((k
- 127) & hx
) < 0 ? -y
: y
);
82 /* signal invalid if x is a SNaN */
83 return (x
* ONEF
); /* +0 -> *1 for Cheetah */
88 volatile float dummy __unused
;
92 ix
= hx
& ~0x80000000;
94 if (((k
- 127) ^ (k
- 150)) < 0) {
98 dummy
= HUGEF
+ x
; /* raise inexact */
99 *(int *) &x
= (hx
+ j
) & ~k
;
101 } else if (k
<= 126) {
103 *(int *) &x
= (0x3f800000 & ((125 - k
) >> 31)) |
107 /* signal invalid if x is a SNaN */
108 return (x
* ONEF
); /* +0 -> *1 for Cheetah */
117 k
= (hx
& ~0x80000000) >> 23;
118 v
= xf
[((k
- 150) >> 31) & (1 - (hx
>> 31))];
119 return ((int) ((float) (x
+ v
) - v
));
125 volatile float dummy __unused
;
128 k
= (hx
& ~0x80000000) >> 23;
129 if (((k
- 126) ^ (k
- 150)) < 0) {
130 ix
= (hx
& 0x00ffffff) | 0x800000;
133 if ((ix
& (j
+ j
- 1)) != 0)
136 return ((((ix
+ j
) >> (m
+ 1)) ^ hx
) - hx
);
147 k
= (hx
& ~0x80000000) >> 23;
148 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
151 v
= xf
[1 - (hx
>> 31)];
153 v
= xf
[((k
- 150) >> 31) & (1 - (hx
>> 31))];
156 if (k
< 127 && w
== v
)