View | Details | Raw Unified | Return to bug 887 | Differences between
and this patch

Collapse All | Expand All

(-)libc24-cvstip-20050310/sysdeps/powerpc/powerpc32/fpu/s_logb.c (+74 lines)
Line 0 Link Here
1
/* @(#)s_logb.c 5.1 93/09/24 */
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
 
13
 /* 
14
   Copyright (C) 2005 Free Software Foundation, Inc.
15
   This file is part of the GNU C Library.
16
17
   The GNU C Library is free software; you can redistribute it and/or
18
   modify it under the terms of the GNU Lesser General Public
19
   License as published by the Free Software Foundation; either
20
   version 2.1 of the License, or (at your option) any later version.
21
22
   The GNU C Library is distributed in the hope that it will be useful,
23
   but WITHOUT ANY WARRANTY; without even the implied warranty of
24
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
   Lesser General Public License for more details.
26
27
   You should have received a copy of the GNU Lesser General Public
28
   License along with the GNU C Library; if not, write to the Free
29
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30
   02111-1307 USA.  */
31
32
#if defined(LIBM_SCCS) && !defined(lint)
33
static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
34
#endif
35
36
/*
37
 * double logb(x)
38
 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
39
 * Use ilogb instead.
40
 */
41
42
#include "math.h"
43
#include "math_private.h"
44
#include <fenv.h>
45
46
#ifdef __STDC__
47
	double __logb(double x)
48
#else
49
	double __logb(x)
50
	double x;
51
#endif
52
{
53
	int32_t lx,ix;
54
	EXTRACT_WORDS(ix,lx,x);
55
	ix &= 0x7fffffff;			/* high |x| */
56
	if((ix|lx)==0) return -1.0/fabs(x);
57
	if(ix>=0x7ff00000) return x*x;
58
	if((ix>>=20)==0) 			/* IEEE 754 logb */
59
		return -1022.0;
60
	else
61
	{
62
		double result;
63
		int	round_mode = fegetround();
64
		fesetround(FE_TONEAREST);
65
		result = (double) (ix-1023);
66
		fesetround(round_mode);
67
		return result;
68
	}
69
}
70
weak_alias (__logb, logb)
71
#ifdef NO_LONG_DOUBLE
72
strong_alias (__logb, __logbl)
73
weak_alias (__logb, logbl)
74
#endif
(-)libc24-cvstip-20050310/sysdeps/powerpc/powerpc32/fpu/s_logbf.c (+67 lines)
Line 0 Link Here
1
/* s_logbf.c -- float version of s_logb.c.
2
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3
 */
4
5
/*
6
 * ====================================================
7
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8
 *
9
 * Developed at SunPro, a Sun Microsystems, Inc. business.
10
 * Permission to use, copy, modify, and distribute this
11
 * software is freely granted, provided that this notice 
12
 * is preserved.
13
 * ====================================================
14
 */
15
 
16
 /* 
17
   Copyright (C) 2005 Free Software Foundation, Inc.
18
   This file is part of the GNU C Library.
19
20
   The GNU C Library is free software; you can redistribute it and/or
21
   modify it under the terms of the GNU Lesser General Public
22
   License as published by the Free Software Foundation; either
23
   version 2.1 of the License, or (at your option) any later version.
24
25
   The GNU C Library is distributed in the hope that it will be useful,
26
   but WITHOUT ANY WARRANTY; without even the implied warranty of
27
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28
   Lesser General Public License for more details.
29
30
   You should have received a copy of the GNU Lesser General Public
31
   License along with the GNU C Library; if not, write to the Free
32
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
33
   02111-1307 USA.  */
34
35
#if defined(LIBM_SCCS) && !defined(lint)
36
static char rcsid[] = "$NetBSD: s_logbf.c,v 1.4 1995/05/10 20:47:51 jtc Exp $";
37
#endif
38
39
#include "math.h"
40
#include "math_private.h"
41
#include <fenv.h>
42
43
#ifdef __STDC__
44
	float __logbf(float x)
45
#else
46
	float __logbf(x)
47
	float x;
48
#endif
49
{
50
	int32_t ix;
51
	GET_FLOAT_WORD(ix,x);
52
	ix &= 0x7fffffff;			/* high |x| */
53
	if(ix==0) return (float)-1.0/fabsf(x);
54
	if(ix>=0x7f800000) return x*x;
55
	if((ix>>=23)==0) 			/* IEEE 754 logb */
56
		return -126.0; 
57
	else 
58
	{
59
		float result;
60
		int	round_mode = fegetround();
61
		fesetround(FE_TONEAREST);
62
		result = (float) (ix-127);
63
		fesetround(round_mode);
64
		return result;
65
	}
66
}
67
weak_alias (__logbf, logbf)

Return to bug 887