Print this page
5261 libm should stop using synonyms.h
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.
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 rintl = __rintl
30 +#pragma weak __rintl = rintl
31 31
32 32 /*
33 33 * rintl(long double x) return x rounded to integral according to
34 34 * the prevailing rounding direction
35 35 *
36 36 * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
37 37 * with the same sign as x's, including 0.0L.
38 38 */
39 39
40 40 #include "libm.h"
41 41 #include "longdouble.h"
42 42
43 43 extern enum fp_precision_type __swapRP(enum fp_precision_type);
44 44
45 45 static const double one = 1.0;
46 46 static const long double qzero = 0.0L;
47 47
48 48 long double
49 49 rintl(long double x) {
50 50 enum fp_precision_type rp;
51 51 long double t, w, two112;
52 52 int *pt = (int *) &two112;
53 53
54 54 if (!finitel(x))
55 55 return (x + x);
56 56
57 57 if (*(int *) &one != 0) { /* set two112 = 2^112 */
58 58 pt[0] = 0x406f0000;
59 59 pt[1] = pt[2] = pt[3] = 0;
60 60 } else {
61 61 pt[3] = 0x406f0000;
62 62 pt[0] = pt[1] = pt[2] = 0;
63 63 }
64 64
65 65 if (fabsl(x) >= two112)
66 66 return (x); /* already an integer */
67 67 t = copysignl(two112, x);
68 68 rp = __swapRP(fp_extended); /* make sure precision is long double */
69 69 w = x + t; /* x+sign(x)*2^112 rounded to integer */
70 70 (void) __swapRP(rp); /* restore precision mode */
71 71 if (w == t)
72 72 return (copysignl(qzero, x)); /* x rounded to zero */
73 73 else
74 74 return (w - t);
75 75 }
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX