Skip to content

Commit

Permalink
* sysdeps/powerpc/fpu/fenv_libc.h: Add libm_hidden_proto for
Browse files Browse the repository at this point in the history
	__fe_nomask_env.
	* sysdeps/powerpc/fpu/fe_nomask.c: Add libm_hidden_def.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c: Likewise.

	* sysdeps/powerpc/bits/fenv.h: Make safe for C++.

	* sysdeps/unix/sysv/linux/powerpc/bits/mathinline.h: New file.
	* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Rename
	function from fegetexcept and make old name weak alias.
	* include/fenv.h: Declare __fegetexcept.
	* sysdeps/powerpc/fpu/fedisblxcpt.c: Use __fegetexcept instead of
	fegetexcept.
	* sysdeps/powerpc/fpu/feenablxcpt.c: Likewise.
	* sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Avoid call
	to fetestexcept.
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Use __frexpl
	instead of frexpl to avoid local PLT.
	* math/s_significandl.c (__significandl): Use __ilogbl instead of
	ilogbl to avoid local PLT.
	* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Use __ldexpl
	instead of ldexpl to avoid local PLT.
	* sysdeps/ieee754/ldbl-128ibm/e_expl.c (__ieee754_expl): Use
	__roundl not roundl to avoid local PLT.
	* sysdeps/ieee754/ldbl-128/e_j0l.c: Use function names which avoid
	local PLTs.  Use __sincosl instead of separate sinl and cosl
	calls.
	* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.
  • Loading branch information
Ulrich Drepper committed Apr 12, 2008
1 parent 2dc4a2f commit 246ec41
Show file tree
Hide file tree
Showing 19 changed files with 388 additions and 74 deletions.
30 changes: 30 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
2008-04-11 Ulrich Drepper <drepper@redhat.com>

* sysdeps/powerpc/fpu/fenv_libc.h: Add libm_hidden_proto for
__fe_nomask_env.
* sysdeps/powerpc/fpu/fe_nomask.c: Add libm_hidden_def.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c: Likewise.

* sysdeps/powerpc/bits/fenv.h: Make safe for C++.

* sysdeps/unix/sysv/linux/powerpc/bits/mathinline.h: New file.
* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Rename
function from fegetexcept and make old name weak alias.
* include/fenv.h: Declare __fegetexcept.
* sysdeps/powerpc/fpu/fedisblxcpt.c: Use __fegetexcept instead of
fegetexcept.
* sysdeps/powerpc/fpu/feenablxcpt.c: Likewise.
* sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Avoid call
to fetestexcept.
* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Use __frexpl
instead of frexpl to avoid local PLT.
* math/s_significandl.c (__significandl): Use __ilogbl instead of
ilogbl to avoid local PLT.
* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Use __ldexpl
instead of ldexpl to avoid local PLT.
* sysdeps/ieee754/ldbl-128ibm/e_expl.c (__ieee754_expl): Use
__roundl not roundl to avoid local PLT.
* sysdeps/ieee754/ldbl-128/e_j0l.c: Use function names which avoid
local PLTs. Use __sincosl instead of separate sinl and cosl
calls.
* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.

* sysdeps/unix/sysv/linux/configure.in: Bump minimal kernel
version for ppc64 to 2.4.21 since without it makecontext will fail.

Expand Down
1 change: 1 addition & 0 deletions include/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* Now define the internal interfaces. */

extern int __feclearexcept (int __excepts);
extern int __fegetexcept (void);
extern int __fegetexceptflag (fexcept_t *__flagp, int __excepts);
extern int __feraiseexcept (int __excepts);
extern int __fesetexceptflag (__const fexcept_t *__flagp, int __excepts);
Expand Down
2 changes: 1 addition & 1 deletion math/s_significandl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ static char rcsid[] = "$NetBSD: $";
long double x;
#endif
{
return __ieee754_scalbl(x,(long double) -ilogbl(x));
return __ieee754_scalbl(x,(long double) -__ilogbl(x));
}
weak_alias (__significandl, significandl)
16 changes: 7 additions & 9 deletions sysdeps/ieee754/ldbl-128/e_j0l.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,16 +768,15 @@ __ieee754_j0l (long double x)
= 1/sqrt(2) * (sin(x) - cos(x))
sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
cf. Fdlibm. */
c = cosl (xx);
s = sinl (xx);
__sincosl (xx, &s, &c);
ss = s - c;
cc = s + c;
z = -cosl (xx + xx);
z = -__cosl (xx + xx);
if ((s * c) < 0)
cc = z / ss;
else
ss = z / cc;
z = ONEOSQPI * (p * cc - q * ss) / sqrtl (xx);
z = ONEOSQPI * (p * cc - q * ss) / __ieee754_sqrtl (xx);
return z;
}

Expand Down Expand Up @@ -836,7 +835,7 @@ long double
/* 0 <= x <= 2 */
z = xx * xx;
p = neval (z, Y0_2N, NY0_2N) / deval (z, Y0_2D, NY0_2D);
p = TWOOPI * logl(x) * __ieee754_j0l(x) + p;
p = TWOOPI * __ieee754_logl (x) * __ieee754_j0l (x) + p;
return p;
}

Expand Down Expand Up @@ -908,15 +907,14 @@ long double
= 1/sqrt(2) * (sin(x) - cos(x))
sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
cf. Fdlibm. */
c = cosl (x);
s = sinl (x);
__sincosl (x, &s, &c);
ss = s - c;
cc = s + c;
z = -cosl (x + x);
z = -__cosl (x + x);
if ((s * c) < 0)
cc = z / ss;
else
ss = z / cc;
z = ONEOSQPI * (p * ss + q * cc) / sqrtl (x);
z = ONEOSQPI * (p * ss + q * cc) / __ieee754_sqrtl (x);
return z;
}
16 changes: 7 additions & 9 deletions sysdeps/ieee754/ldbl-128/e_j1l.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,15 @@ __ieee754_j1l (long double x)
sin(X) = sin(x) cos(3 pi/4) - cos(x) sin(3 pi/4)
= -1/sqrt(2) * (sin(x) + cos(x))
cf. Fdlibm. */
c = cosl (xx);
s = sinl (xx);
__sincosl (xx, &s, &c);
ss = -s - c;
cc = s - c;
z = cosl (xx + xx);
z = __cosl (xx + xx);
if ((s * c) > 0)
cc = z / ss;
else
ss = z / cc;
z = ONEOSQPI * (p * cc - q * ss) / sqrtl (xx);
z = ONEOSQPI * (p * cc - q * ss) / __ieee754_sqrtl (xx);
if (x < 0)
z = -z;
return z;
Expand Down Expand Up @@ -844,7 +843,7 @@ __ieee754_y1l (long double x)
z = xx * xx;
p = xx * neval (z, Y0_2N, NY0_2N) / deval (z, Y0_2D, NY0_2D);
p = -TWOOPI / xx + p;
p = TWOOPI * logl(x) * __ieee754_j1l (x) + p;
p = TWOOPI * __ieee754_logl (x) * __ieee754_j1l (x) + p;
return p;
}

Expand Down Expand Up @@ -915,15 +914,14 @@ __ieee754_y1l (long double x)
sin(X) = sin(x) cos(3 pi/4) - cos(x) sin(3 pi/4)
= -1/sqrt(2) * (sin(x) + cos(x))
cf. Fdlibm. */
c = cosl (xx);
s = sinl (xx);
__sincosl (xx, &s, &c);
ss = -s - c;
cc = s - c;
z = cosl (xx + xx);
z = __cosl (xx + xx);
if ((s * c) > 0)
cc = z / ss;
else
ss = z / cc;
z = ONEOSQPI * (p * ss + q * cc) / sqrtl (xx);
z = ONEOSQPI * (p * ss + q * cc) / __ieee754_sqrtl (xx);
return z;
}
8 changes: 4 additions & 4 deletions sysdeps/ieee754/ldbl-128ibm/e_expl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Quad-precision floating point e^x.
Copyright (C) 1999,2004,2006 Free Software Foundation, Inc.
Copyright (C) 1999,2004,2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
Partly based on double-precision code
Expand Down Expand Up @@ -148,15 +148,15 @@ __ieee754_expl (long double x)
fesetround (FE_TONEAREST);
#endif

n = roundl(x*M_1_LN2);
n = __roundl (x*M_1_LN2);
x = x-n*M_LN2_0;
xl = n*M_LN2_1;

tval1 = roundl(x*TWO8);
tval1 = __roundl (x*TWO8);
x -= __expl_table[T_EXPL_ARG1+2*tval1];
xl -= __expl_table[T_EXPL_ARG1+2*tval1+1];

tval2 = roundl(x*TWO15);
tval2 = __roundl (x*TWO15);
x -= __expl_table[T_EXPL_ARG2+2*tval2];
xl -= __expl_table[T_EXPL_ARG2+2*tval2+1];

Expand Down
2 changes: 1 addition & 1 deletion sysdeps/ieee754/ldbl-128ibm/s_expm1l.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ __expm1l (long double x)
exp(x) - 1 = 2^k (qx + 1) - 1
= 2^k qx + 2^k - 1. */

px = ldexpl (1.0L, k);
px = __ldexpl (1.0L, k);
x = px * qx + (px - 1.0);
return x;
}
Expand Down
8 changes: 1 addition & 7 deletions sysdeps/ieee754/ldbl-128ibm/s_log1pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ static const long double maxlog = 1.1356523406294143949491931077970764891253E4L;
static const long double big = 2e300L;
static const long double zero = 0.0L;

#if 1
/* Make sure these are prototyped. */
long double frexpl (long double, int *);
long double ldexpl (long double, int);
#endif


long double
__log1pl (long double xm1)
Expand Down Expand Up @@ -161,7 +155,7 @@ __log1pl (long double xm1)
/* Separate mantissa from exponent. */

/* Use frexp used so that denormal numbers will be handled properly. */
x = frexpl (x, &e);
x = __frexpl (x, &e);

/* Logarithm using log(x) = z + z^3 P(z^2)/Q(z^2),
where z = 2(x-1)/x+1). */
Expand Down
7 changes: 6 additions & 1 deletion sysdeps/powerpc/bits/fenv.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1997, 1998, 1999, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -136,6 +136,8 @@ extern const fenv_t __fe_enabled_env;
extern const fenv_t __fe_nonieee_env;
# define FE_NONIEEE_ENV (&__fe_nonieee_env)

__BEGIN_DECLS

/* Floating-point environment with all exceptions enabled. Note that
just evaluating this value does not change the processor exception mode.
Passing this mask to fesetenv will result in a prctl syscall to change
Expand All @@ -152,4 +154,7 @@ extern const fenv_t *__fe_nomask_env (void);
this allows the fastest possible floating point execution.*/
extern const fenv_t *__fe_mask_env (void);
# define FE_MASK_ENV FE_DFL_ENV

__END_DECLS

#endif
5 changes: 3 additions & 2 deletions sysdeps/powerpc/fpu/fe_nomask.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Procedure definition for FE_NOMASK_ENV.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand All @@ -17,7 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <fenv.h>
#include <fenv_libc.h>
#include <errno.h>

/* This is a generic stub. An OS specific override is required to set
Expand All @@ -30,4 +30,5 @@ __fe_nomask_env(void)
__set_errno (ENOSYS);
return FE_ENABLED_ENV;
}
libm_hidden_def (__fe_nomask_env)
stub_warning (__fe_nomask_env)
6 changes: 3 additions & 3 deletions sysdeps/powerpc/fpu/fedisblxcpt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Disable floating-point exceptions.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@geoffk.org>, 2000.
Expand All @@ -26,7 +26,7 @@ fedisableexcept (int excepts)
fenv_union_t fe;
int result, new;

result = fegetexcept ();
result = __fegetexcept ();

if ((excepts & FE_ALL_INVALID) == FE_ALL_INVALID)
excepts = (excepts | FE_INVALID) & ~ FE_ALL_INVALID;
Expand All @@ -44,7 +44,7 @@ fedisableexcept (int excepts)
fe.l[1] &= ~(1 << (31 - FPSCR_VE));
fesetenv_register (fe.fenv);

new = fegetexcept ();
new = __fegetexcept ();
if (new == 0 && result != 0)
(void)__fe_mask_env ();

Expand Down
6 changes: 3 additions & 3 deletions sysdeps/powerpc/fpu/feenablxcpt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Enable floating-point exceptions.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@geoffk.org>, 2000.
Expand All @@ -26,7 +26,7 @@ feenableexcept (int excepts)
fenv_union_t fe;
int result, new;

result = fegetexcept ();
result = __fegetexcept ();

if ((excepts & FE_ALL_INVALID) == FE_ALL_INVALID)
excepts = (excepts | FE_INVALID) & ~ FE_ALL_INVALID;
Expand All @@ -44,7 +44,7 @@ feenableexcept (int excepts)
fe.l[1] |= (1 << (31 - FPSCR_VE));
fesetenv_register (fe.fenv);

new = fegetexcept ();
new = __fegetexcept ();
if (new != 0 && result == 0)
(void)__fe_nomask_env ();

Expand Down
7 changes: 4 additions & 3 deletions sysdeps/powerpc/fpu/fegetexcept.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Get floating-point exceptions.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@geoffk.org>, 2000.
Expand All @@ -21,13 +21,13 @@
#include <fenv_libc.h>

int
fegetexcept (void)
__fegetexcept (void)
{
fenv_union_t fe;
int result = 0;

fe.fenv = fegetenv_register ();

if (fe.l[1] & (1 << (31 - FPSCR_XE)))
result |= FE_INEXACT;
if (fe.l[1] & (1 << (31 - FPSCR_ZE)))
Expand All @@ -41,3 +41,4 @@ fegetexcept (void)

return result;
}
weak_alias (__fegetexcept, fegetexcept)
6 changes: 4 additions & 2 deletions sysdeps/powerpc/fpu/fenv_libc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Internal libc stuff for floating point environment routines.
Copyright (C) 1997, 2006 Free Software Foundation, Inc.
Copyright (C) 1997, 2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand All @@ -22,6 +22,8 @@

#include <fenv.h>

libm_hidden_proto (__fe_nomask_env)

/* The sticky bits in the FPSCR indicating exceptions have occurred. */
#define FPSCR_STICKY_BITS ((FE_ALL_EXCEPT | FE_ALL_INVALID) & ~FE_INVALID)

Expand Down Expand Up @@ -137,5 +139,5 @@ enum {
({ float f; asm volatile ("fmuls %0,%1,%2" \
: "=f"(f) \
: "f" (x), "f"((float)1.0)); f; })

#endif /* fenv_libc.h */
11 changes: 7 additions & 4 deletions sysdeps/powerpc/fpu/fraiseexcpt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Raise given exceptions.
Copyright (C) 1997,99,2000,01,02 Free Software Foundation, Inc.
Copyright (C) 1997,1999-2002, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -45,12 +45,15 @@ __feraiseexcept (int excepts)
triggering any appropriate exceptions. */
fesetenv_register (u.fenv);

if ((excepts & FE_INVALID)
if ((excepts & FE_INVALID))
{
/* For some reason, some PowerPC chips (the 601, in particular)
don't have FE_INVALID_SOFTWARE implemented. Detect this
case and raise FE_INVALID_SNAN instead. */
&& !fetestexcept (FE_INVALID))
set_fpscr_bit (FPSCR_VXSNAN);
u.fenv = fegetenv_register ();
if ((u.l[1] & FE_INVALID) == 0)
set_fpscr_bit (FPSCR_VXSNAN);
}

/* Success. */
return 0;
Expand Down
Loading

0 comments on commit 246ec41

Please sign in to comment.