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 frexpl = __frexpl
37 __frexpl(long double x
, int *exp
) {
46 hx
= xx
.i
[0] & ~0x80000000;
48 if (hx
>= 0x7fff0000) { /* x is infinite or NaN */
54 if (hx
< 0x00010000) { /* x is subnormal or zero */
55 if ((hx
| xx
.i
[1] | xx
.i
[2] | xx
.i
[3]) == 0) {
61 s
= xx
.i
[0] & 0x80000000;
62 while ((hx
| (xx
.i
[1] & 0xffff0000)) == 0) {
69 while (hx
< 0x10000) {
70 hx
= (hx
<< 1) | (xx
.i
[1] >> 31);
71 xx
.i
[1] = (xx
.i
[1] << 1) | (xx
.i
[2] >> 31);
72 xx
.i
[2] = (xx
.i
[2] << 1) | (xx
.i
[3] >> 31);
79 /* now xx.q is normal */
80 xx
.i
[0] = (xx
.i
[0] & ~0x7fff0000) | 0x3ffe0000;
81 *exp
= e
+ (hx
>> 16) - 0x3ffe;
88 __frexpl(long double x
, int *exp
) {
97 hx
= xx
.i
[2] & 0x7fff;
99 if (hx
>= 0x7fff) { /* x is infinite or NaN */
105 if (hx
< 0x0001) { /* x is subnormal or zero */
106 if ((xx
.i
[0] | xx
.i
[1]) == 0) {
112 xx
.e
*= 18446744073709551616.0L; /* 2^64 */
113 hx
= xx
.i
[2] & 0x7fff;
117 /* now xx.e is normal */
118 xx
.i
[2] = (xx
.i
[2] & 0x8000) | 0x3ffe;
119 *exp
= e
+ hx
- 0x3ffe;
124 #error Unknown architecture