Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/C/asinh.c
+++ new/usr/src/lib/libm/common/C/asinh.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 -#pragma weak asinh = __asinh
30 +#pragma weak __asinh = asinh
31 31
32 32 /* INDENT OFF */
33 33 /*
34 34 * asinh(x)
35 35 * Method :
36 36 * Based on
37 37 * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
38 38 * we have
39 39 * asinh(x) := x if 1+x*x == 1,
40 40 * := sign(x)*(log(x)+ln2)) for large |x|, else
41 41 * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x| > 2, else
42 42 * := sign(x)*log1p(|x|+x^2/(1+sqrt(1+x^2)))
43 43 */
44 44 /* INDENT ON */
45 45
46 -#include "libm_synonyms.h" /* __asinh */
47 46 #include "libm_macros.h"
48 47 #include <math.h>
49 48
50 49 static const double xxx[] = {
51 50 /* one */ 1.00000000000000000000e+00, /* 3FF00000, 00000000 */
52 51 /* ln2 */ 6.93147180559945286227e-01, /* 3FE62E42, FEFA39EF */
53 52 /* huge */ 1.00000000000000000000e+300
54 53 };
55 54 #define one xxx[0]
56 55 #define ln2 xxx[1]
57 56 #define huge xxx[2]
58 57
59 58 double
60 59 asinh(double x) {
61 60 double t, w;
62 61 int hx, ix;
63 62
64 63 hx = ((int *) &x)[HIWORD];
65 64 ix = hx & 0x7fffffff;
66 65 if (ix >= 0x7ff00000)
67 66 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
68 67 return (ix >= 0x7ff80000 ? x : x + x);
69 68 /* assumes sparc-like QNaN */
70 69 #else
71 70 return (x + x); /* x is inf or NaN */
72 71 #endif
73 72 if (ix < 0x3e300000) { /* |x|<2**-28 */
74 73 if (huge + x > one)
75 74 return (x); /* return x inexact except 0 */
76 75 }
77 76 if (ix > 0x41b00000) { /* |x| > 2**28 */
78 77 w = log(fabs(x)) + ln2;
79 78 } else if (ix > 0x40000000) {
80 79 /* 2**28 > |x| > 2.0 */
81 80 t = fabs(x);
82 81 w = log(2.0 * t + one / (sqrt(x * x + one) + t));
83 82 } else {
84 83 /* 2.0 > |x| > 2**-28 */
85 84 t = x * x;
86 85 w = log1p(fabs(x) + t / (one + sqrt(one + t)));
87 86 }
88 87 return (hx > 0 ? w : -w);
89 88 }
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX