Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/rndintl.s
+++ new/usr/src/lib/libm/i386/src/rndintl.s
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 /*
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 23 */
24 24 /*
25 25 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 29 .file "rndintl.s"
30 30
31 31 #include "libm.h"
32 -LIBM_ANSI_PRAGMA_WEAK(aintl,function)
33 -LIBM_ANSI_PRAGMA_WEAK(irintl,function)
34 -LIBM_ANSI_PRAGMA_WEAK(anintl,function)
35 -LIBM_ANSI_PRAGMA_WEAK(nintl,function)
36 -#include "libm_synonyms.h"
32 +
37 33 #undef fabs
38 34
39 35 ENTRY(aintl)
40 36 movl %esp,%eax
41 37 subl $8,%esp
42 38 fstcw -8(%eax)
43 39 fldt 4(%eax)
44 40 movw -8(%eax),%cx
45 41 orw $0x0c00,%cx
46 42 movw %cx,-4(%eax)
47 43 fldcw -4(%eax) / set RD = to_zero
48 44 frndint
49 45 fstcw -4(%eax)
50 46 movw -4(%eax),%dx
51 47 andw $0xf3ff,%dx
52 48 movw -8(%eax),%cx
53 49 andw $0x0c00,%cx
54 50 orw %dx,%cx
55 51 movw %cx,-8(%eax)
56 52 fldcw -8(%eax) / restore RD
57 53 addl $8,%esp
58 54 ret
59 55 .align 4
60 56 SET_SIZE(aintl)
61 57
62 58 ENTRY(irintl)
63 59 movl %esp,%ecx
64 60 subl $8,%esp
65 61 fldt 4(%ecx) / load x
66 62 fistpl -8(%ecx) / [x]
67 63 fwait
68 64 movl -8(%ecx),%eax
69 65 addl $8,%esp
70 66 ret
71 67 .align 4
72 68 SET_SIZE(irintl)
73 69
74 70 .data
75 71 .align 4
76 72 half: .float 0.5
77 73
78 74 ENTRY(anintl)
79 75 .Lanintl:
80 76 movl %esp,%ecx
81 77 subl $8,%esp
82 78 fstcw -8(%ecx)
83 79 fldt 4(%ecx)
84 80 movw -8(%ecx),%dx
85 81 andw $0xf3ff,%dx
86 82 movw %dx,-4(%ecx)
87 83 fldcw -4(%ecx) / set RD = to_nearest
88 84 fld %st(0)
89 85 frndint / [x],x
90 86 fstcw -4(%ecx)
91 87 movw -4(%ecx),%dx
92 88 andw $0xf3ff,%dx
93 89 movw -8(%ecx),%ax
94 90 andw $0x0c00,%ax
95 91 orw %dx,%ax
96 92 movw %ax,-8(%ecx)
97 93 fldcw -8(%ecx) / restore RD
98 94 fucom / check if x is already an integer
99 95 fstsw %ax
100 96 sahf
101 97 jp .L0
102 98 je .L0
103 99 fxch / x,[x]
104 100 fsub %st(1),%st / x-[x],[x]
105 101 fabs / |x-[x]|,[x]
106 102 PIC_SETUP(1)
107 103 fcoms PIC_L(half)
108 104 PIC_WRAPUP
109 105 fnstsw %ax
110 106 sahf
111 107 jae .halfway / if |x-[x]| = 0.5 goto halfway,
112 108 / most cases will not take branch.
113 109 .L0:
114 110 addl $8,%esp
115 111 fstp %st(0)
116 112 ret
117 113 .halfway:
118 114 / x = n+0.5, recompute anint(x) as x+sign(x)*0.5
119 115 fldt 4(%ecx) / x, 0.5, [x]
120 116 movw 12(%ecx),%ax / sign+exp part of x
121 117 andw $0x8000,%ax / look at sign bit
122 118 jnz .x_neg
123 119 faddp
124 120 addl $8,%esp
125 121 fstp %st(1)
126 122 ret
127 123 .x_neg:
128 124 / here, x is negative, so return x-0.5
129 125 fsubp %st,%st(1) / x-0.5,[x]
130 126 addl $8,%esp
131 127 fstp %st(1)
132 128 ret
133 129 .align 4
134 130 SET_SIZE(anintl)
135 131
136 132 ENTRY(nintl)
137 133 pushl %ebp
138 134 movl %esp,%ebp
139 135 subl $8,%esp
140 136 pushl 16(%ebp)
141 137 pushl 12(%ebp)
142 138 pushl 8(%ebp)
143 139 call .Lanintl /// LOCAL
144 140 fistpl -8(%ebp)
145 141 fwait
146 142 movl -8(%ebp),%eax
147 143 leave
148 144 ret
149 145 .align 4
150 146 SET_SIZE(nintl)
↓ open down ↓ |
104 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX