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/complex/cexpf.c
+++ new/usr/src/lib/libm/common/complex/cexpf.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 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 23 */
24 24 /*
25 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 -#pragma weak cexpf = __cexpf
29 +#pragma weak __cexpf = cexpf
30 30
31 31 #include "libm.h"
32 32 #include "complex_wrapper.h"
33 33
34 34 #if defined(__i386) && !defined(__amd64)
35 35 extern int __swapRP(int);
36 36 #endif
37 37
38 38 static const float zero = 0.0F;
39 39
40 40 fcomplex
41 41 cexpf(fcomplex z) {
42 42 fcomplex ans;
43 43 float x, y, c, s;
44 44 double t;
45 45 int n, ix, iy, hx, hy;
46 46
47 47 x = F_RE(z);
48 48 y = F_IM(z);
49 49 hx = THE_WORD(x);
50 50 hy = THE_WORD(y);
51 51 ix = hx & 0x7fffffff;
52 52 iy = hy & 0x7fffffff;
53 53 if (iy == 0) { /* y = 0 */
54 54 F_RE(ans) = expf(x);
55 55 F_IM(ans) = y;
56 56 } else if (ix == 0x7f800000) { /* x is +-inf */
57 57 if (hx < 0) {
58 58 if (iy >= 0x7f800000) {
59 59 F_RE(ans) = zero;
60 60 F_IM(ans) = zero;
61 61 } else {
62 62 sincosf(y, &s, &c);
63 63 F_RE(ans) = zero * c;
64 64 F_IM(ans) = zero * s;
65 65 }
66 66 } else {
67 67 if (iy >= 0x7f800000) {
68 68 F_RE(ans) = x;
69 69 F_IM(ans) = y - y;
70 70 } else {
71 71 sincosf(y, &s, &c);
72 72 F_RE(ans) = x * c;
73 73 F_IM(ans) = x * s;
74 74 }
75 75 }
76 76 } else {
77 77 sincosf(y, &s, &c);
78 78 if (ix >= 0x42B171AA) { /* |x| > 88.722... ~ log(2**128) */
79 79 #if defined(__i386) && !defined(__amd64)
80 80 int rp = __swapRP(fp_extended);
81 81 #endif
82 82 t = __k_cexp(x, &n);
83 83 F_RE(ans) = (float)scalbn(t * (double)c, n);
84 84 F_IM(ans) = (float)scalbn(t * (double)s, n);
85 85 #if defined(__i386) && !defined(__amd64)
86 86 if (rp != fp_extended)
87 87 (void) __swapRP(rp);
88 88 #endif
89 89 } else {
90 90 t = expf(x);
91 91 F_RE(ans) = t * c;
92 92 F_IM(ans) = t * s;
93 93 }
94 94 }
95 95 return (ans);
96 96 }
↓ open down ↓ |
57 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX