Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/round.s
+++ new/usr/src/lib/libm/i386/src/round.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 "round.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(round,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(round)
41 40 movl %esp,%ecx
42 41 subl $8,%esp
43 42 fstcw -8(%ecx)
44 43 fldl 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 addl $8,%esp
76 75 fstp %st(0)
77 76 ret
78 77 2:
79 78 / x = n+0.5, recompute round(x) as x+sign(x)*0.5
80 79 fldl 4(%ecx) / x, 0.5, [x]
81 80 movl 8(%ecx),%eax / high part of x
82 81 andl $0x80000000,%eax
83 82 jnz 3f
84 83 faddp
85 84 addl $8,%esp
86 85 fstp %st(1)
87 86 ret
88 87 3:
89 88 / here, x is negative, so return x-0.5
90 89 fsubp %st,%st(1) / x-0.5,[x]
91 90 addl $8,%esp
92 91 fstp %st(1)
93 92 ret
94 93 .align 4
95 94 SET_SIZE(round)
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX