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>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/C/acosh.c
+++ new/usr/src/lib/libm/common/C/acosh.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 acosh = __acosh
30 +#pragma weak __acosh = acosh
31 31
32 32 /* INDENT OFF */
33 33 /*
34 34 * acosh(x)
35 35 * Method :
36 36 * Based on
37 37 * acosh(x) = log [ x + sqrt(x*x-1) ]
38 38 * we have
39 39 * acosh(x) := log(x)+ln2, if x is large; else
40 40 * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x > 2; else
41 41 * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t = x-1.
42 42 *
43 43 * Special cases:
44 44 * acosh(x) is NaN with signal if x < 1.
45 45 * acosh(NaN) is NaN without signal.
46 46 */
47 47 /* INDENT ON */
48 48
49 -#include "libm_synonyms.h" /* __acosh, __log, __log1p */
50 49 #include "libm_protos.h" /* _SVID_libm_error */
51 50 #include "libm_macros.h"
52 51 #include <math.h>
53 52
54 53 static const double
55 54 one = 1.0,
56 55 ln2 = 6.93147180559945286227e-01; /* 3FE62E42, FEFA39EF */
57 56
58 57 double
59 58 acosh(double x) {
60 59 double t;
61 60 int hx;
62 61
63 62 hx = ((int *) &x)[HIWORD];
64 63 if (hx < 0x3ff00000) { /* x < 1 */
65 64 if (isnan(x))
66 65 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
67 66 return (hx >= 0xfff80000 ? x : (x - x) / (x - x));
68 67 /* assumes sparc-like QNaN */
69 68 #else
70 69 return (x - x) / (x - x);
71 70 #endif
72 71 else
73 72 return (_SVID_libm_err(x, x, 29));
74 73 } else if (hx >= 0x41b00000) {
75 74 /* x > 2**28 */
76 75 if (hx >= 0x7ff00000) { /* x is inf of NaN */
77 76 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
78 77 return (hx >= 0x7ff80000 ? x : x + x);
79 78 /* assumes sparc-like QNaN */
80 79 #else
81 80 return (x + x);
82 81 #endif
83 82 } else /* acosh(huge)=log(2x) */
84 83 return (log(x) + ln2);
85 84 } else if (((hx - 0x3ff00000) | ((int *) &x)[LOWORD]) == 0) {
86 85 return (0.0); /* acosh(1) = 0 */
87 86 } else if (hx > 0x40000000) {
88 87 /* 2**28 > x > 2 */
89 88 t = x * x;
90 89 return (log(2.0 * x - one / (x + sqrt(t - one))));
91 90 } else {
92 91 /* 1 < x < 2 */
93 92 t = x - one;
94 93 return (log1p(t + sqrt(2.0 * t + t * t)));
95 94 }
96 95 }
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX