Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/lroundl.s
+++ new/usr/src/lib/libm/i386/src/lroundl.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 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
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 "lroundl.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(lroundl,function)
33 -#include "libm_synonyms.h"
34 33 #undef fabs
35 34
36 35 .section .rodata
37 36 .align 4
38 37 .Lhalf: .float 0.5
39 38
40 39 ENTRY(lroundl)
41 40 movl %esp,%ecx
42 41 subl $8,%esp
43 42 fstcw -8(%ecx)
44 43 fldt 4(%ecx)
45 44 movw -8(%ecx),%dx
46 45 andw $0xf3ff,%dx
47 46 movw %dx,-4(%ecx)
48 47 fldcw -4(%ecx) / set RD = to_nearest
49 48 fld %st(0)
50 49 frndint / [x],x
51 50 fstcw -4(%ecx)
52 51 movw -4(%ecx),%dx
53 52 andw $0xf3ff,%dx
54 53 movw -8(%ecx),%ax
55 54 andw $0x0c00,%ax
56 55 orw %dx,%ax
57 56 movw %ax,-8(%ecx)
58 57 fldcw -8(%ecx) / restore RD
59 58 fucom / check if x is already an integer
60 59 fstsw %ax
61 60 sahf
62 61 jp 0f
63 62 je 0f
64 63 fxch / x,[x]
65 64 fsub %st(1),%st / x-[x],[x]
66 65 fabs / |x-[x]|,[x]
67 66 PIC_SETUP(1)
68 67 fcoms PIC_L(.Lhalf)
69 68 PIC_WRAPUP
70 69 fnstsw %ax
71 70 sahf
72 71 jae 2f / if |x-[x]| = 0.5 goto halfway,
73 72 / most cases will not take branch.
74 73 0:
75 74 fstp %st(0)
76 75 1:
77 76 fistpl -8(%ecx)
78 77 fwait
79 78 movl -8(%ecx),%eax
80 79 addl $8,%esp
81 80 ret
82 81 2:
83 82 / x = n+0.5, recompute lroundl(x) as x+sign(x)*0.5
84 83 fldt 4(%ecx) / x, 0.5, [x]
85 84 movw 12(%ecx),%ax / sign+exp part of x
86 85 andw $0x8000,%ax / look at sign bit
87 86 jnz 3f
88 87 faddp
89 88 fstp %st(1)
90 89 jmp 1b
91 90 3:
92 91 / here, x is negative, so return x-0.5
93 92 fsubp %st,%st(1) / x-0.5,[x]
94 93 fstp %st(1)
95 94 jmp 1b
96 95 .align 4
97 96 SET_SIZE(lroundl)
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX