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/ilogb.s
+++ new/usr/src/lib/libm/i386/src/ilogb.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 "ilogb.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(ilogb,function)
33 -#include "libm_synonyms.h"
34 33 #include "xpg6.h"
35 34
36 35 .data
37 36 .align 8
38 37 two52: .long 0x0,0x43300000 / 2**52
39 38
40 39 ENTRY(ilogb)
41 40 movl 8(%esp),%eax / eax <-- hi_32(x)
42 41 andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
43 42 testl $0x7ff00000,%eax / is bexp(x) 0?
44 43 jz .bexp_0 / jump if x is 0 or subnormal
45 44 / biased exponent is non-zero
46 45 cmpl $0x7ff00000,%eax / is bexp(x) 0x7ff?
47 46 jae .bexp_all_1 / jump if x is NaN or Inf
48 47 shrl $20,%eax / eax <-- bexp(x)
49 48 subl $1023,%eax / unbias exponent by 1023
50 49 ret
51 50
52 51 .bexp_all_1:
53 52 movl $0x7fffffff,%eax / x is NaN or inf, so return 0x7fffffff
54 53 jmp 0f
55 54
56 55 .bexp_0:
57 56 orl 4(%esp),%eax / test whether x is 0
58 57 jnz .ilogb_subnorm
59 58 movl $0x80000001,%eax / x is +/-0, so return 0x80000001
60 59 0:
61 60 PIC_SETUP(0)
62 61 PIC_G_LOAD(movzwl,__xpg6,ecx)
63 62 PIC_WRAPUP
64 63 andl $_C99SUSv3_ilogb_0InfNaN_raises_invalid,%ecx
65 64 cmpl $0,%ecx
66 65 je 1f
67 66 fldz
68 67 fdivp %st,%st(0) / raise invalid as per SUSv3
69 68 1:
70 69 ret
71 70
72 71 .ilogb_subnorm: / subnormal input
73 72 fldl 4(%esp) / push x
74 73 PIC_SETUP(1)
75 74 fmull PIC_L(two52) / x*2**52
76 75 PIC_WRAPUP
77 76 subl $8,%esp / set up storage area
78 77 fstpl (%esp) / store x*2**52 in storage are
79 78 movl $0x7ff00000,%eax
80 79 andl 4(%esp),%eax
81 80 shrl $20,%eax / extract exponent of x*2**52
82 81 subl $1075,%eax / unbias it by 1075 (= 1023 + 52)
83 82 addl $8,%esp
84 83 ret
85 84 .align 4
86 85 SET_SIZE(ilogb)
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX