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/amd64/src/rndintl.s
+++ new/usr/src/lib/libm/amd64/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 2005 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 -
38 -#undef fabs
39 32
40 33 ENTRY(aintl)
41 34 movq %rsp,%rax
42 35 subq $16,%rsp
43 36 fstcw -8(%rax)
44 37 fldt 8(%rax)
45 38 movw -8(%rax),%cx
46 39 orw $0x0c00,%cx
47 40 movw %cx,-4(%rax)
48 41 fldcw -4(%rax) / set RD = to_zero
49 42 frndint
50 43 fstcw -4(%rax)
51 44 movw -4(%rax),%dx
52 45 andw $0xf3ff,%dx
53 46 movw -8(%rax),%cx
54 47 andw $0x0c00,%cx
55 48 orw %dx,%cx
56 49 movw %cx,-8(%rax)
57 50 fldcw -8(%rax) / restore RD
58 51 addq $16,%rsp
59 52 ret
60 53 .align 16
61 54 SET_SIZE(aintl)
62 55
63 56 ENTRY(irintl)
64 57 movq %rsp,%rcx
65 58 subq $16,%rsp
66 59 fldt 8(%rcx) / load x
67 60 fistpl -8(%rcx) / [x]
68 61 fwait
69 62 movslq -8(%rcx),%rax
70 63 addq $16,%rsp
71 64 ret
72 65 .align 16
73 66 SET_SIZE(irintl)
74 67
75 68 .data
76 69 .align 16
77 70 half: .float 0.5
78 71
79 72 ENTRY(anintl)
80 73 .Lanintl:
81 74 movq %rsp,%rcx
82 75 subq $16,%rsp
83 76 fstcw -8(%rcx)
84 77 fldt 8(%rcx)
85 78 movw -8(%rcx),%dx
86 79 andw $0xf3ff,%dx
87 80 movw %dx,-4(%rcx)
88 81 fldcw -4(%rcx) / set RD = to_nearest
89 82 fld %st(0)
90 83 frndint / [x],x
91 84 fstcw -4(%rcx)
92 85 movw -4(%rcx),%dx
93 86 andw $0xf3ff,%dx
94 87 movw -8(%rcx),%ax
95 88 andw $0x0c00,%ax
96 89 orw %dx,%ax
97 90 movw %ax,-8(%rcx)
98 91 fldcw -8(%rcx) / restore RD
99 92 fucomi %st(1),%st / check if x is already an integer
100 93 jp .L0
101 94 je .L0
102 95 fxch / x,[x]
103 96 fsub %st(1),%st / x-[x],[x]
104 97 fabs / |x-[x]|,[x]
105 98 PIC_SETUP(1)
106 99 flds PIC_L(half)
107 100 fcomip %st(1),%st / compare 0.5 with |x-[x]|
108 101 PIC_WRAPUP
109 102 je .halfway / if 0.5 = |x-[x]| goto halfway,
110 103 / most cases will not take branch.
111 104 .L0:
112 105 addq $16,%rsp
113 106 fstp %st(0)
114 107 ret
115 108 .halfway:
116 109 / x = n+0.5, recompute anint(x) as x+sign(x)*0.5
117 110 fldt 8(%rcx) / x, 0.5, [x]
118 111 movw 16(%rcx),%ax / sign+exp part of x
119 112 andw $0x8000,%ax / look at sign bit
120 113 jnz .x_neg
121 114 faddp
122 115 addq $16,%rsp
123 116 fstp %st(1)
124 117 ret
125 118 .x_neg:
126 119 / here, x is negative, so return x-0.5
127 120 fsubp %st,%st(1) / x-0.5,[x]
128 121 addq $16,%rsp
129 122 fstp %st(1)
130 123 ret
131 124 .align 16
132 125 SET_SIZE(anintl)
133 126
134 127 ENTRY(nintl)
135 128 pushq %rbp
136 129 movq %rsp,%rbp
137 130 subq $16,%rsp
138 131 pushq 24(%rbp)
139 132 pushq 16(%rbp)
140 133 call .Lanintl /// LOCAL
141 134 fistpl -8(%rbp)
142 135 fwait
143 136 movslq -8(%rbp),%rax
144 137 leave
145 138 ret
146 139 .align 16
147 140 SET_SIZE(nintl)
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX