Print this page
patch mul-ste
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/amd64/fp/_base_il.c
+++ new/usr/src/lib/libc/amd64/fp/_base_il.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 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #pragma ident "%Z%%M% %I% %E% SMI"
28 28
29 29 #include "lint.h"
30 30 #include "base_conversion.h"
31 31 #include <sys/isa_defs.h>
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
32 32
33 33 #define CSR_DEFAULT 0x1f80
34 34
35 35 /* The following should be coded as inline expansion templates. */
36 36
37 37 /*
38 38 * Multiplies two normal or subnormal doubles, returns result and exceptions.
39 39 */
40 40 double
41 41 __mul_set(double x, double y, int *pe) {
42 - extern void _putmxcsr(), _getmxcsr();
43 - int csr;
42 + int csr = CSR_DEFAULT;
44 43 double z;
45 44
46 - _putmxcsr(CSR_DEFAULT);
47 - z = x * y;
48 - _getmxcsr(&csr);
45 + __asm__ __volatile__(
46 + "ldmxcsr %4\n"
47 + "mulsd %2,%3\n"
48 + "stmxcsr %0\n"
49 + : "=m" (csr), "=C" (z)
50 + : "C" (x), "C" (y), "m" (csr));
51 +
49 52 if ((csr & 0x3f) == 0) {
50 53 *pe = 0;
51 54 } else {
52 55 /* Result may not be exact. */
53 56 *pe = 1;
54 57 }
55 58 return (z);
56 59 }
57 60
58 61 /*
59 62 * Divides two normal or subnormal doubles x/y, returns result and exceptions.
60 63 */
61 64 double
62 65 __div_set(double x, double y, int *pe) {
63 66 extern void _putmxcsr(), _getmxcsr();
64 67 int csr;
65 68 double z;
66 69
67 70 _putmxcsr(CSR_DEFAULT);
68 71 z = x / y;
69 72 _getmxcsr(&csr);
70 73 if ((csr & 0x3f) == 0) {
71 74 *pe = 0;
72 75 } else {
73 76 *pe = 1;
74 77 }
75 78 return (z);
76 79 }
77 80
78 81 double
79 82 __dabs(double *d)
80 83 {
81 84 /* should use hardware fabs instruction */
82 85 return ((*d < 0.0) ? -*d : *d);
83 86 }
84 87
85 88 /*
86 89 * Returns IEEE mode/status and
87 90 * sets up standard environment for base conversion.
88 91 */
89 92 void
90 93 __get_ieee_flags(__ieee_flags_type *b) {
91 94 extern void _getmxcsr(), _putmxcsr();
92 95
93 96 _getmxcsr(&b->status);
94 97
95 98 /* round-to-nearest, all exceptions masked, gradual underflow */
96 99 _putmxcsr(CSR_DEFAULT);
97 100 }
98 101
99 102 /*
100 103 * Restores previous IEEE mode/status
101 104 */
102 105 void
103 106 __set_ieee_flags(__ieee_flags_type *b) {
104 107 extern void _putmxcsr();
105 108
106 109 _putmxcsr(b->status);
107 110 }
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX