Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/Q/rintl.c
+++ new/usr/src/lib/libm/common/Q/rintl.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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 #pragma weak __rintl = rintl
31 32
32 33 /*
33 34 * rintl(long double x) return x rounded to integral according to
34 35 * the prevailing rounding direction
35 36 *
36 37 * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
37 38 * with the same sign as x's, including 0.0L.
38 39 */
39 40
40 41 #include "libm.h"
41 42 #include "longdouble.h"
42 43
43 44 extern enum fp_precision_type __swapRP(enum fp_precision_type);
44 45
45 46 static const double one = 1.0;
46 47 static const long double qzero = 0.0L;
47 -
48 48 long double
49 -rintl(long double x) {
49 +rintl(long double x)
50 +{
50 51 enum fp_precision_type rp;
51 52 long double t, w, two112;
52 - int *pt = (int *) &two112;
53 + int *pt = (int *)&two112;
53 54
54 55 if (!finitel(x))
55 56 return (x + x);
56 57
57 - if (*(int *) &one != 0) { /* set two112 = 2^112 */
58 + if (*(int *)&one != 0) { /* set two112 = 2^112 */
58 59 pt[0] = 0x406f0000;
59 60 pt[1] = pt[2] = pt[3] = 0;
60 61 } else {
61 62 pt[3] = 0x406f0000;
62 63 pt[0] = pt[1] = pt[2] = 0;
63 64 }
64 65
65 66 if (fabsl(x) >= two112)
66 - return (x); /* already an integer */
67 + return (x); /* already an integer */
68 +
67 69 t = copysignl(two112, x);
68 - rp = __swapRP(fp_extended); /* make sure precision is long double */
69 - w = x + t; /* x+sign(x)*2^112 rounded to integer */
70 - (void) __swapRP(rp); /* restore precision mode */
70 + rp = __swapRP(fp_extended); /* make sure precision is long double */
71 + w = x + t; /* x+sign(x)*2^112 rounded to integer */
72 + (void) __swapRP(rp); /* restore precision mode */
73 +
71 74 if (w == t)
72 75 return (copysignl(qzero, x)); /* x rounded to zero */
73 76 else
74 77 return (w - t);
75 78 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX