Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
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"
37 -#undef fabs
38 32
39 33 ENTRY(aintl)
40 34 movl %esp,%eax
41 35 subl $8,%esp
42 36 fstcw -8(%eax)
43 37 fldt 4(%eax)
44 38 movw -8(%eax),%cx
45 39 orw $0x0c00,%cx
46 40 movw %cx,-4(%eax)
47 41 fldcw -4(%eax) / set RD = to_zero
48 42 frndint
49 43 fstcw -4(%eax)
50 44 movw -4(%eax),%dx
51 45 andw $0xf3ff,%dx
52 46 movw -8(%eax),%cx
53 47 andw $0x0c00,%cx
54 48 orw %dx,%cx
55 49 movw %cx,-8(%eax)
56 50 fldcw -8(%eax) / restore RD
57 51 addl $8,%esp
58 52 ret
59 53 .align 4
60 54 SET_SIZE(aintl)
61 55
62 56 ENTRY(irintl)
63 57 movl %esp,%ecx
64 58 subl $8,%esp
65 59 fldt 4(%ecx) / load x
66 60 fistpl -8(%ecx) / [x]
67 61 fwait
68 62 movl -8(%ecx),%eax
69 63 addl $8,%esp
70 64 ret
71 65 .align 4
72 66 SET_SIZE(irintl)
73 67
74 68 .data
75 69 .align 4
76 70 half: .float 0.5
77 71
78 72 ENTRY(anintl)
79 73 .Lanintl:
80 74 movl %esp,%ecx
81 75 subl $8,%esp
82 76 fstcw -8(%ecx)
83 77 fldt 4(%ecx)
84 78 movw -8(%ecx),%dx
85 79 andw $0xf3ff,%dx
86 80 movw %dx,-4(%ecx)
87 81 fldcw -4(%ecx) / set RD = to_nearest
88 82 fld %st(0)
89 83 frndint / [x],x
90 84 fstcw -4(%ecx)
91 85 movw -4(%ecx),%dx
92 86 andw $0xf3ff,%dx
93 87 movw -8(%ecx),%ax
94 88 andw $0x0c00,%ax
95 89 orw %dx,%ax
96 90 movw %ax,-8(%ecx)
97 91 fldcw -8(%ecx) / restore RD
98 92 fucom / check if x is already an integer
99 93 fstsw %ax
100 94 sahf
101 95 jp .L0
102 96 je .L0
103 97 fxch / x,[x]
104 98 fsub %st(1),%st / x-[x],[x]
105 99 fabs / |x-[x]|,[x]
106 100 PIC_SETUP(1)
107 101 fcoms PIC_L(half)
108 102 PIC_WRAPUP
109 103 fnstsw %ax
110 104 sahf
111 105 jae .halfway / if |x-[x]| = 0.5 goto halfway,
112 106 / most cases will not take branch.
113 107 .L0:
114 108 addl $8,%esp
115 109 fstp %st(0)
116 110 ret
117 111 .halfway:
118 112 / x = n+0.5, recompute anint(x) as x+sign(x)*0.5
119 113 fldt 4(%ecx) / x, 0.5, [x]
120 114 movw 12(%ecx),%ax / sign+exp part of x
121 115 andw $0x8000,%ax / look at sign bit
122 116 jnz .x_neg
123 117 faddp
124 118 addl $8,%esp
125 119 fstp %st(1)
126 120 ret
127 121 .x_neg:
128 122 / here, x is negative, so return x-0.5
129 123 fsubp %st,%st(1) / x-0.5,[x]
130 124 addl $8,%esp
131 125 fstp %st(1)
132 126 ret
133 127 .align 4
134 128 SET_SIZE(anintl)
135 129
136 130 ENTRY(nintl)
137 131 pushl %ebp
138 132 movl %esp,%ebp
139 133 subl $8,%esp
140 134 pushl 16(%ebp)
141 135 pushl 12(%ebp)
142 136 pushl 8(%ebp)
143 137 call .Lanintl /// LOCAL
144 138 fistpl -8(%ebp)
145 139 fwait
146 140 movl -8(%ebp),%eax
147 141 leave
148 142 ret
149 143 .align 4
150 144 SET_SIZE(nintl)
↓ open down ↓ |
103 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX