xref: /titanic_41/usr/src/lib/libm/i386/src/log10.s (revision 5b2ba9d3d1e04dde804c89e9879f7dfc9bcebf61)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
23 */
24/*
25 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
26 * Use is subject to license terms.
27 */
28
29	.file "log10.s"
30
31#include "libm.h"
32LIBM_ANSI_PRAGMA_WEAK(log10,function)
33#include "libm_synonyms.h"
34#include "libm_protos.h"
35
36	ENTRY(log10)
37	fldlg2				/ log10(2)
38	movl	8(%esp),%eax		/ eax <-- hi_32(x)
39	testl	$0x80000000,%eax
40	jnz	.maybe_0_or_less
41	testl	$0x7fffffff,%eax
42	jz	.maybe_0
43	fldl	4(%esp)			/ arg, log10(2)
44	fyl2x				/ log10(2)*log2(arg); log10(arg)
45	ret
46
47.maybe_0:
48	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
49	cmpl	$0,%ecx
50	je	.zero			/ no branch if x is +denormal
51.neg_nan_reentry:
52	fldl	4(%esp)			/ arg, log10(2)
53	fyl2x				/ log10(2)*log2(arg); log10(arg)
54	ret
55
56.zero_or_less:
57	/ x =< 0
58	testl	$0x7fffffff,%eax
59	jnz	.less_than_0
60	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
61	cmpl	$0,%ecx
62	jne	.less_than_0		/ branch if x is -denormal
63.zero:
64	/ x = +/-0
65	pushl	%ebp
66	movl	%esp,%ebp
67	PIC_SETUP(1)
68	pushl	$18
69	jmp	.merge
70
71.maybe_0_or_less:
72	cmpl	$0xfff00000,%eax	/ -INF below hi_32(x)?
73	ja	.neg_nan_reentry
74	jb	.zero_or_less
75	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
76	cmpl	$0,%ecx			/ is x NaN or -INF?
77	jne	.neg_nan_reentry	/ branch if x is NaN with signbit = 1
78	/ x = -INF
79.less_than_0:
80	pushl	%ebp
81	movl	%esp,%ebp
82	PIC_SETUP(2)
83	pushl	$19
84.merge:
85	fstp	%st(0)			/ stack empty
86	pushl	12(%ebp)
87	pushl	8(%ebp)
88	pushl	12(%ebp)
89	pushl	8(%ebp)
90	call	PIC_F(_SVID_libm_err)
91	addl	$20,%esp
92	PIC_WRAPUP
93	leave
94	ret
95	.align	4
96	SET_SIZE(log10)
97