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/Q/log10l.c
+++ new/usr/src/lib/libm/common/Q/log10l.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 log10l = __log10l
32 -#endif
30 +#pragma weak __log10l = log10l
33 31
34 32 /*
35 33 * log10l(X)
36 34 *
37 35 * Method :
38 36 * Let log10_2hi = leading 98(SPARC)/49(x86) bits of log10(2) and
39 37 * log10_2lo = log10(2) - log10_2hi,
40 38 * ivln10 = 1/log(10) rounded.
41 39 * Then
42 40 * n = ilogb(x),
43 41 * if (n<0) n = n+1;
44 42 * x = scalbn(x,-n);
45 43 * LOG10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
46 44 *
47 45 * Note1:
48 46 * For fear of destroying log10(10**n)=n, the rounding mode is
49 47 * set to Round-to-Nearest.
50 48 *
51 49 * Special cases:
52 50 * log10(x) is NaN with signal if x < 0;
53 51 * log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
54 52 * log10(NaN) is that NaN with no signal;
55 53 * log10(10**N) = N for N=0,1,...,22.
56 54 *
57 55 * Constants:
58 56 * The hexadecimal values are the intended ones for the following constants.
59 57 * The decimal values may be used, provided that the compiler will convert
60 58 * from decimal to binary accurately enough to produce the hexadecimal values
61 59 * shown.
62 60 */
63 61
64 62 #include "libm.h"
65 63 #include "longdouble.h"
66 64
67 65 #if defined(__x86)
68 66 #define __swapRD __swap87RD
69 67 #endif
70 68 extern enum fp_direction_type __swapRD(enum fp_direction_type);
71 69
72 70 static const long double
73 71 zero = 0.0L,
74 72 ivln10 = 4.342944819032518276511289189166050822944e-0001L,
75 73 one = 1.0L,
76 74 #if defined(__x86)
77 75 log10_2hi = 3.010299956639803653501985536422580480576e-01L,
78 76 log10_2lo = 8.298635403410822349787106337291183585413e-16L;
79 77 #elif defined(__sparc)
80 78 log10_2hi = 3.010299956639811952137388947242098603469e-01L,
81 79 log10_2lo = 2.831664213089468167896664371953210945664e-31L;
82 80 #else
83 81 #error Unknown Architecture!
84 82 #endif
85 83
86 84 long double
87 85 log10l(long double x) {
88 86 long double y, z;
89 87 enum fp_direction_type rd;
90 88 int n;
91 89
92 90 if (!finitel(x))
93 91 return (x + fabsl(x)); /* x is +-INF or NaN */
94 92 else if (x > zero) {
95 93 n = ilogbl(x);
96 94 if (n < 0)
97 95 n += 1;
98 96 rd = __swapRD(fp_nearest);
99 97 y = n;
100 98 x = scalbnl(x, -n);
101 99 z = y * log10_2lo + ivln10 * logl(x);
102 100 z += y * log10_2hi;
103 101 if (rd != fp_nearest)
104 102 (void) __swapRD(rd);
105 103 return (z);
106 104 } else if (x == zero) /* -INF */
107 105 return (-one / zero);
108 106 else /* x <0, return NaN */
109 107 return (zero / zero);
110 108 }
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX