1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 *
5 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6 */
7
8#include <machine/asm.h>
9
10RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
11
12#ifdef __ELF__
13	.section .rodata
14#else
15	.text
16#endif
17	.align ALIGNARG(4)
18	/* The fyl2xp1 can only be used for values in
19		-1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
20	   0.29 is a safe value.
21	*/
22limit:	.tfloat 0.29
23	/* Please note:	 we use a double value here.  Since 1.0 has
24	   an exact representation this does not effect the accuracy
25	   but it helps to optimize the code.  */
26one:	.double 1.0
27
28/*
29 * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
30 * otherwise fyl2x with the needed extra computation.
31 */
32	.text
33ENTRY(__log1pl)
34	fldln2
35
36	fldt	4(%esp)
37
38#ifdef PIC
39	call	1f
401:	popl	%edx
41	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
42#endif
43
44	fxam
45	fnstsw
46	fld	%st
47	sahf
48	jc	3f		// in case x is NaN or �Inf
494:
50	fabs
51#ifdef PIC
52	fldt	limit@GOTOFF(%edx)
53#else
54	fldt	limit
55#endif
56	fcompp
57	fnstsw
58	sahf
59	jnc	2f
60
61#ifdef PIC
62	faddl	one@GOTOFF(%edx)
63#else
64	faddl	one
65#endif
66	fyl2x
67	ret
68
692:	fyl2xp1
70	ret
71
723:	jp	4b		// in case x is �Inf
73	fstp	%st(1)
74	fstp	%st(1)
75	ret
76
77END (__log1pl)
78weak_alias (__log1pl, log1pl)
79