Print this page
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/m9x/frexp.c
+++ new/usr/src/lib/libm/common/m9x/frexp.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#if defined(ELFOBJ)
31 30 #pragma weak frexp = __frexp
32 -#endif
33 31
34 32 /*
35 33 * frexp(x, exp) returns the normalized significand of x and sets
36 34 * *exp so that x = r*2^(*exp) where r is the return value. If x
37 35 * is finite and nonzero, 1/2 <= |r| < 1.
38 36 *
39 37 * If x is zero, infinite or NaN, frexp returns x and sets *exp = 0.
40 38 * (The relevant standards do not specify *exp when x is infinite or
41 39 * NaN, but this code sets it anyway.)
42 40 *
43 41 * If x is a signaling NaN, this code returns x without attempting
44 42 * to raise the invalid operation exception. If x is subnormal,
45 43 * this code treats it as nonzero regardless of nonstandard mode.
46 44 */
47 45
48 46 #include "libm.h"
49 47
50 48 double
51 49 __frexp(double x, int *exp) {
52 50 union {
53 51 unsigned i[2];
54 52 double d;
55 53 } xx, yy;
56 54 double t;
57 55 unsigned hx;
58 56 int e;
59 57
60 58 xx.d = x;
61 59 hx = xx.i[HIWORD] & ~0x80000000;
62 60
63 61 if (hx >= 0x7ff00000) { /* x is infinite or NaN */
64 62 *exp = 0;
65 63 return (x);
66 64 }
67 65
68 66 e = 0;
69 67 if (hx < 0x00100000) { /* x is subnormal or zero */
70 68 if ((hx | xx.i[LOWORD]) == 0) {
71 69 *exp = 0;
72 70 return (x);
73 71 }
74 72
75 73 /*
76 74 * normalize x by regarding it as an integer
77 75 *
78 76 * Here we use 32-bit integer arithmetic to avoid trapping
79 77 * or emulating 64-bit arithmetic. If 64-bit arithmetic is
80 78 * available (e.g., in SPARC V9), do this instead:
81 79 *
82 80 * long lx = ((long) hx << 32) | xx.i[LOWORD];
83 81 * xx.d = (xx.i[HIWORD] < 0)? -lx : lx;
84 82 *
85 83 * If subnormal arithmetic doesn't trap, just multiply x by
86 84 * a power of two.
87 85 */
88 86 yy.i[HIWORD] = 0x43300000 | hx;
89 87 yy.i[LOWORD] = xx.i[LOWORD];
90 88 t = yy.d;
91 89 yy.i[HIWORD] = 0x43300000;
92 90 yy.i[LOWORD] = 0;
93 91 t -= yy.d; /* t = |x| scaled */
94 92 xx.d = ((int)xx.i[HIWORD] < 0)? -t : t;
95 93 hx = xx.i[HIWORD] & ~0x80000000;
96 94 e = -1074;
97 95 }
98 96
99 97 /* now xx.d is normal */
100 98 xx.i[HIWORD] = (xx.i[HIWORD] & ~0x7ff00000) | 0x3fe00000;
101 99 *exp = e + (hx >> 20) - 0x3fe;
102 100 return (xx.d);
103 101 }
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX