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/nextafterl.c
+++ new/usr/src/lib/libm/common/Q/nextafterl.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 nextafterl = __nextafterl
32 -#endif
30 +#pragma weak __nextafterl = nextafterl
33 31
34 32 #include "libm.h"
35 33 #include <float.h> /* LDBL_MAX, LDBL_MIN */
36 34
37 35 #if defined(__sparc)
38 36 #define n0 0
39 37 #define n1 1
40 38 #define n2 2
41 39 #define n3 3
42 40 #define X86PDNRM1(x)
43 41 #define INC(px) { \
44 42 if (++px[n3] == 0) \
45 43 if (++px[n2] == 0) \
46 44 if (++px[n1] == 0) \
47 45 ++px[n0]; \
48 46 }
49 47 #define DEC(px) { \
50 48 if (--px[n3] == 0xffffffff) \
51 49 if (--px[n2] == 0xffffffff) \
52 50 if (--px[n1] == 0xffffffff) \
53 51 --px[n0]; \
54 52 }
55 53 #elif defined(__x86)
56 54 #define n0 2
57 55 #define n1 1
58 56 #define n2 0
59 57 #define n3 0
60 58 /*
61 59 * if pseudo-denormal, replace by the equivalent normal
62 60 */
63 61 #define X86PDNRM1(x) if (XBIASED_EXP(x) == 0 && (((int *) &x)[1] & \
64 62 0x80000000) != 0) \
65 63 ((int *) &x)[2] |= 1
66 64 #define INC(px) { \
67 65 if (++px[n2] == 0) \
68 66 if ((++px[n1] & ~0x80000000) == 0) \
69 67 px[n1] = 0x80000000, ++px[n0]; \
70 68 }
71 69 #define DEC(px) { \
72 70 if (--px[n2] == 0xffffffff) \
73 71 if (--px[n1] == 0x7fffffff) \
74 72 if ((--px[n0] & 0x7fff) != 0) \
75 73 px[n1] |= 0x80000000; \
76 74 }
77 75 #endif
78 76
79 77 long double
80 78 nextafterl(long double x, long double y) {
81 79 int *px = (int *) &x;
82 80 int *py = (int *) &y;
83 81
84 82 if (x == y)
85 83 return (y); /* C99 requirement */
86 84 if (x != x || y != y)
87 85 return (x * y);
88 86
89 87 if (ISZEROL(x)) { /* x == 0.0 */
90 88 px[n0] = py[n0] & XSGNMSK;
91 89 px[n1] = px[n2] = 0;
92 90 px[n3] = 1;
93 91 } else {
94 92 X86PDNRM1(x);
95 93 if ((px[n0] & XSGNMSK) == 0) { /* x > 0.0 */
96 94 if (x > y) /* x > y */
97 95 DEC(px)
98 96 else
99 97 INC(px)
100 98 } else {
101 99 if (x < y) /* x < y */
102 100 DEC(px)
103 101 else
104 102 INC(px)
105 103 }
106 104 }
107 105 #ifndef lint
108 106 {
109 107 volatile long double dummy;
110 108 int k = XBIASED_EXP(x);
111 109
112 110 if (k == 0)
113 111 dummy = LDBL_MIN * copysignl(LDBL_MIN, x);
114 112 else if (k == 0x7fff)
115 113 dummy = LDBL_MAX * copysignl(LDBL_MAX, x);
116 114 }
117 115 #endif
118 116 return (x);
119 117 }
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX