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