Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
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/truncl.c
+++ new/usr/src/lib/libm/common/m9x/truncl.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 -#pragma weak truncl = __truncl
32 -#endif
30 +#pragma weak __truncl = truncl
33 31
34 32 #include "libm.h"
35 33
36 34 #if defined(__sparc)
37 35 long double
38 36 truncl(long double x) {
39 37 union {
40 38 unsigned i[4];
41 39 long double q;
42 40 } xx;
43 41 unsigned hx, sx;
44 42 int j;
45 43
46 44 xx.q = x;
47 45 sx = xx.i[0] & 0x80000000;
48 46 hx = xx.i[0] & ~0x80000000;
49 47
50 48 /* handle trivial cases */
51 49 if (hx >= 0x406f0000) /* |x| >= 2^112 + ... or x is nan */
52 50 return (hx >= 0x7fff0000 ? x + x : x);
53 51
54 52 /* handle |x| < 1 */
55 53 if (hx < 0x3fff0000)
56 54 return (sx ? -0.0L : 0.0L);
57 55
58 56 j = 0x406f - (hx >> 16); /* 1 <= j <= 112 */
59 57 xx.i[0] = hx;
60 58 if (j >= 96) { /* 96 <= j <= 112 */
61 59 xx.i[0] &= ~((1 << (j - 96)) - 1);
62 60 xx.i[1] = xx.i[2] = xx.i[3] = 0;
63 61 } else if (j >= 64) { /* 64 <= j <= 95 */
64 62 xx.i[1] &= ~((1 << (j - 64)) - 1);
65 63 xx.i[2] = xx.i[3] = 0;
66 64 } else if (j >= 32) { /* 32 <= j <= 63 */
67 65 xx.i[2] &= ~((1 << (j - 32)) - 1);
68 66 xx.i[3] = 0;
69 67 } else /* 1 <= j <= 31 */
70 68 xx.i[3] &= ~((1 << j) - 1);
71 69
72 70 /* negate result if need be */
73 71 if (sx)
74 72 xx.i[0] |= 0x80000000;
75 73 return (xx.q);
76 74 }
77 75 #elif defined(__x86)
78 76 long double
79 77 truncl(long double x) {
80 78 union {
81 79 unsigned i[3];
82 80 long double e;
83 81 } xx;
84 82 int ex, sx, i;
85 83
86 84 xx.e = x;
87 85 ex = xx.i[2] & 0x7fff;
88 86 sx = xx.i[2] & 0x8000;
89 87 if (ex < 0x403e) { /* |x| < 2^63 */
90 88 if (ex < 0x3fff) /* |x| < 1 */
91 89 return (sx ? -0.0L : 0.0L);
92 90
93 91 /* chop x at the integer bit */
94 92 if (ex < 0x401e) {
95 93 i = 1 << (0x401d - ex);
96 94 xx.i[1] &= ~(i | (i - 1));
97 95 xx.i[0] = 0;
98 96 } else {
99 97 i = 1 << (0x403d - ex);
100 98 xx.i[0] &= ~(i | (i - 1));
101 99 }
102 100 return (xx.e);
103 101 } else if (ex < 0x7fff) /* x is integral */
104 102 return (x);
105 103 else /* inf or nan */
106 104 return (x + x);
107 105 }
108 106 #else
109 107 #error Unknown architecture
110 108 #endif /* defined(__sparc) || defined(__x86) */
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX