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