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/hypot.s
+++ new/usr/src/lib/libm/i386/src/hypot.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 "hypot.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(hypot,function)
33 -#include "libm_synonyms.h"
34 33 #include "libm_protos.h"
35 34
36 -#undef fabs
37 -
38 35 .data
39 36 .align 4
40 37 inf:
41 38 .long 0x7f800000
42 39
43 40 ENTRY(hypot)
44 41 movl 8(%esp),%eax / eax <-- hi_32(x)
45 42 andl $0x7fffffff,%eax / eax <-- hi_32(|x|)
46 43 jz .x_maybe_0 / if x = +/-0, return |y|
47 44 subl $0x7ff00000,%eax / eax <-- hi_32(|x|) - hi_32(INF)
48 45 jz .x_maybe_inf
49 46 .check_y:
50 47 movl 16(%esp),%eax / eax <-- hi_32(y)
51 48 andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
52 49 jz .y_maybe_0 / if y = +/-0, return |x|
53 50 subl $0x7ff00000,%eax / eax <-- hi_32(|y|) - hi_32(INF)
54 51 jz .y_maybe_inf
55 52 .do_hypot:
56 53 fldl 12(%esp) / ,y
57 54 fmul %st(0),%st / ,y*y
58 55 fldl 4(%esp) / x,y*y
59 56 fmul %st(0),%st / x*x,y*y
60 57 faddp %st,%st(1) / x*x+y*y
61 58 fsqrt / sqrt(x*x+y*y)
62 59 subl $8,%esp
63 60 fstpl (%esp) / round to double
64 61 fldl (%esp) / sqrt(x*x+y*y) rounded to double
65 62 PIC_SETUP(1)
66 63 flds PIC_L(inf) / inf , sqrt(x*x+y*y)
67 64 PIC_WRAPUP
68 65 addl $8,%esp
69 66 fucomp
70 67 fstsw %ax / store status in %ax
71 68 sahf / 80387 flags in %ah to 80386 flags
72 69 jz .maybe_ovflw
73 70 ret
74 71
75 72 .maybe_ovflw:
76 73 jnp .ovflw
77 74 ret
78 75
79 76 .ovflw:
80 77 / overflow occurred
81 78 fstp %st(0) / stack empty
82 79 pushl %ebp
83 80 movl %esp,%ebp
84 81 PIC_SETUP(2)
85 82 pushl $4
86 83 pushl 20(%ebp) / high y
87 84 pushl 16(%ebp) / low y
88 85 pushl 12(%ebp) / high x
89 86 pushl 8(%ebp) / low x
90 87 call PIC_F(_SVID_libm_err)
91 88 addl $20,%esp
92 89 PIC_WRAPUP
93 90 leave
94 91 ret
95 92
96 93 .x_maybe_0:
97 94 movl 4(%esp),%ecx / ecx <-- lo_32(x)
98 95 orl %ecx,%eax / is x = +/-0?
99 96 jnz .check_y / branch if x is denormal
100 97 / x = +/-0, so return |y|
101 98 fldl 12(%esp)
102 99 fabs
103 100 ret
104 101
105 102 .x_maybe_inf:
106 103 movl 4(%esp),%ecx / ecx <-- lo_32(x)
107 104 orl %ecx,%eax / is x = +/-INF?
108 105 jnz .check_y / branch if x is NaN
109 106 / push&pop y in case y is a SNaN
110 107 fldl 12(%esp)
111 108 fstp %st(0)
112 109 / x = +/-INF, so return |x|
113 110 fldl 4(%esp)
114 111 fabs
115 112 ret
116 113
117 114 .y_maybe_0:
118 115 movl 12(%esp),%ecx / ecx <-- lo_32(y)
119 116 orl %ecx,%eax / is y = +/-0?
120 117 jnz .do_hypot / branch if y is denormal
121 118 / y = +/-0, so return |x|
122 119 fldl 4(%esp)
123 120 fabs
124 121 ret
125 122
126 123 .y_maybe_inf:
127 124 movl 12(%esp),%ecx / ecx <-- lo_32(y)
128 125 orl %ecx,%eax / is y = +/-INF?
129 126 jnz .do_hypot / branch if y is NaN
130 127 / push&pop x in case x is a SNaN
131 128 fldl 4(%esp)
132 129 fstp %st(0)
133 130 / y = +/-INF, so return |y|
134 131 fldl 12(%esp)
135 132 fabs
136 133 ret
137 134 .align 4
138 135 SET_SIZE(hypot)
↓ open down ↓ |
91 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX