mirror of https://gitee.com/Nocallback/glibc.git
Browse Source
* math/multc3.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/Makefile [$(subdir) = math] (libm-routines): Add multc3, divtc3. * sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Implies: New file. * sysdeps/sparc/sparc32/fpu/s_fabsl.c: Include math.h and math_ldbl_opt.h. (fabsl): Use long_double_symbol instead of weak_alias. * sysdeps/sparc/sparc32/fpu/s_fabs.c: Include math.h and math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (fabsl): Add compat_symbol. 2006-01-31 Martin Schwidefsky <schwidefsky@de.ibm.com> Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/s390/Implies: New file. * sysdeps/unix/sysv/linux/s390/fpu/Implies: New file. * sysdeps/unix/sysv/linux/s390/nldbl-abi.h: New file. * sysdeps/s390/fpu/bits/mathinline.h (signbitl, sqrtl): New inlines. * sysdeps/s390/bits/mathdef.h: New file. * sysdeps/s390/fpu/e_sqrtl.c: New file. * sysdeps/s390/s390-32/bits/wordsize.h (__LONG_DOUBLE_MATH_OPTIONAL, __NO_LONG_DOUBLE_MATH): Define. * sysdeps/s390/s390-64/bits/wordsize.h: Likewise. * sysdeps/s390/Implies: Add ieee754/ldbl-128. * sysdeps/s390/ldbl2mpn.c: File removed. * sysdeps/s390/fpu/libm-test-ulps: Updated. 2006-01-31 Roland McGrath <roland@redhat.com> * sysdeps/alpha/fpu/bits/mathdef.h: Moved to ... * sysdeps/alpha/bits/mathdef.h: ... here. * sysdeps/i386/fpu/bits/mathdef.h: Moved to ... * sysdeps/i386/bits/mathdef.h: ... here. * sysdeps/mips/fpu/bits/mathdef.h: Moved to ... * sysdeps/mips/bits/mathdef.h: ... here. * sysdeps/m68k/fpu/bits/mathdef.h: Moved to ... * sysdeps/m68k/bits/mathdef.h: ... here. * sysdeps/powerpc/fpu/bits/mathdef.h: Moved to ... * sysdeps/powerpc/bits/mathdef.h: ... here. * sysdeps/sparc/fpu/bits/mathdef.h: Moved to ... * sysdeps/sparc/bits/mathdef.h: ... here. * sysdeps/ia64/fpu/bits/mathdef.h: Moved to ... * sysdeps/ia64/bits/mathdef.h: ... here. * sysdeps/sh/sh4/fpu/bits/mathdef.h: Moved to ... * sysdeps/sh/sh4/bits/mathdef.h: ... here. * sysdeps/x86_64/fpu/bits/mathdef.h: Moved to ... * sysdeps/x86_64/bits/mathdef.h: ... here. 2006-01-31 Jakub Jelinek <jakub@redhat.com>cvs/glibc-2_5-branch
27 changed files with 834 additions and 102 deletions
@ -0,0 +1,75 @@ |
|||
/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
|||
This file is part of the GNU C Library. |
|||
Contributed by Richard Henderson <rth@redhat.com>, 2005. |
|||
|
|||
The GNU C Library is free software; you can redistribute it and/or |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
The GNU C Library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General Public |
|||
License along with the GNU C Library; if not, write to the Free |
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|||
02111-1307 USA. */ |
|||
|
|||
#include <stdbool.h> |
|||
#include <math.h> |
|||
#include <complex.h> |
|||
|
|||
attribute_hidden |
|||
long double _Complex |
|||
__divtc3 (long double a, long double b, long double c, long double d) |
|||
{ |
|||
long double denom, ratio, x, y; |
|||
|
|||
/* ??? We can get better behavior from logarithmic scaling instead of
|
|||
the division. But that would mean starting to link libgcc against |
|||
libm. We could implement something akin to ldexp/frexp as gcc builtins |
|||
fairly easily... */ |
|||
if (fabsl (c) < fabsl (d)) |
|||
{ |
|||
ratio = c / d; |
|||
denom = (c * ratio) + d; |
|||
x = ((a * ratio) + b) / denom; |
|||
y = ((b * ratio) - a) / denom; |
|||
} |
|||
else |
|||
{ |
|||
ratio = d / c; |
|||
denom = (d * ratio) + c; |
|||
x = ((b * ratio) + a) / denom; |
|||
y = (b - (a * ratio)) / denom; |
|||
} |
|||
|
|||
/* Recover infinities and zeros that computed as NaN+iNaN; the only cases
|
|||
are nonzero/zero, infinite/finite, and finite/infinite. */ |
|||
if (isnan (x) && isnan (y)) |
|||
{ |
|||
if (denom == 0.0 && (!isnan (a) || !isnan (b))) |
|||
{ |
|||
x = __copysignl (INFINITY, c) * a; |
|||
y = __copysignl (INFINITY, c) * b; |
|||
} |
|||
else if ((isinf (a) || isinf (b)) && isfinite (c) && isfinite (d)) |
|||
{ |
|||
a = __copysignl (isinf (a) ? 1 : 0, a); |
|||
b = __copysignl (isinf (b) ? 1 : 0, b); |
|||
x = INFINITY * (a * c + b * d); |
|||
y = INFINITY * (b * c - a * d); |
|||
} |
|||
else if ((isinf (c) || isinf (d)) && isfinite (a) && isfinite (b)) |
|||
{ |
|||
c = __copysignl (isinf (c) ? 1 : 0, c); |
|||
d = __copysignl (isinf (d) ? 1 : 0, d); |
|||
x = 0.0 * (a * c + b * d); |
|||
y = 0.0 * (b * c - a * d); |
|||
} |
|||
} |
|||
|
|||
return x + I * y; |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
|||
This file is part of the GNU C Library. |
|||
Contributed by Richard Henderson <rth@redhat.com>, 2005. |
|||
|
|||
The GNU C Library is free software; you can redistribute it and/or |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
The GNU C Library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General Public |
|||
License along with the GNU C Library; if not, write to the Free |
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|||
02111-1307 USA. */ |
|||
|
|||
#include <stdbool.h> |
|||
#include <math.h> |
|||
#include <complex.h> |
|||
|
|||
attribute_hidden |
|||
long double _Complex |
|||
__multc3 (long double a, long double b, long double c, long double d) |
|||
{ |
|||
long double ac, bd, ad, bc, x, y; |
|||
|
|||
ac = a * c; |
|||
bd = b * d; |
|||
ad = a * d; |
|||
bc = b * c; |
|||
|
|||
x = ac - bd; |
|||
y = ad + bc; |
|||
|
|||
if (isnan (x) && isnan (y)) |
|||
{ |
|||
/* Recover infinities that computed as NaN + iNaN. */ |
|||
bool recalc = 0; |
|||
if (isinf (a) || isinf (b)) |
|||
{ |
|||
/* z is infinite. "Box" the infinity and change NaNs in
|
|||
the other factor to 0. */ |
|||
a = __copysignl (isinf (a) ? 1 : 0, a); |
|||
b = __copysignl (isinf (b) ? 1 : 0, b); |
|||
if (isnan (c)) c = __copysignl (0, c); |
|||
if (isnan (d)) d = __copysignl (0, d); |
|||
recalc = 1; |
|||
} |
|||
if (isinf (c) || isinf (d)) |
|||
{ |
|||
/* w is infinite. "Box" the infinity and change NaNs in
|
|||
the other factor to 0. */ |
|||
c = __copysignl (isinf (c) ? 1 : 0, c); |
|||
d = __copysignl (isinf (d) ? 1 : 0, d); |
|||
if (isnan (a)) a = __copysignl (0, a); |
|||
if (isnan (b)) b = __copysignl (0, b); |
|||
recalc = 1; |
|||
} |
|||
if (!recalc |
|||
&& (isinf (ac) || isinf (bd) || isinf (ad) || isinf (bc))) |
|||
{ |
|||
/* Recover infinities from overflow by changing NaNs to 0. */ |
|||
if (isnan (a)) a = __copysignl (0, a); |
|||
if (isnan (b)) b = __copysignl (0, b); |
|||
if (isnan (c)) c = __copysignl (0, c); |
|||
if (isnan (d)) d = __copysignl (0, d); |
|||
recalc = 1; |
|||
} |
|||
if (recalc) |
|||
{ |
|||
x = INFINITY * (a * c - b * d); |
|||
y = INFINITY * (a * d + b * c); |
|||
} |
|||
} |
|||
|
|||
return x + I * y; |
|||
} |
|||
@ -1,2 +1,3 @@ |
|||
ieee754/ldbl-128 |
|||
ieee754/dbl-64 |
|||
ieee754/flt-32 |
|||
|
|||
@ -0,0 +1,38 @@ |
|||
/* Copyright (C) 1997, 1998, 1999, 2000, 2004, 2006
|
|||
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 |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
The GNU C Library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General Public |
|||
License along with the GNU C Library; if not, write to the Free |
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|||
02111-1307 USA. */ |
|||
|
|||
#if !defined _MATH_H && !defined _COMPLEX_H |
|||
# error "Never use <bits/mathdef.h> directly; include <math.h> instead" |
|||
#endif |
|||
|
|||
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF |
|||
# define _MATH_H_MATHDEF 1 |
|||
|
|||
/* Normally, there is no long double type and the `float' and `double'
|
|||
expressions are evaluated as `double'. */ |
|||
typedef double float_t; /* `float' expressions are evaluated as
|
|||
`double'. */ |
|||
typedef double double_t; /* `double' expressions are evaluated as
|
|||
`double'. */ |
|||
|
|||
/* The values returned by `ilogb' for 0 and NaN respectively. */ |
|||
# define FP_ILOGB0 (-2147483647) |
|||
# define FP_ILOGBNAN 2147483647 |
|||
|
|||
#endif /* ISO C99 */ |
|||
@ -0,0 +1,30 @@ |
|||
/* Square root. S/390 FPU version.
|
|||
Copyright (C) 2004, 2006 Free Software Foundation, Inc. |
|||
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). |
|||
This file is part of the GNU C Library. |
|||
|
|||
The GNU C Library is free software; you can redistribute it and/or |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
The GNU C Library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General Public |
|||
License along with the GNU C Library; if not, write to the Free |
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|||
02111-1307 USA. */ |
|||
|
|||
#include <math_private.h> |
|||
|
|||
long double |
|||
__ieee754_sqrtl (long double x) |
|||
{ |
|||
long double res; |
|||
|
|||
asm ( "sqxbr %0,%1" : "=f" (res) : "f" (x) ); |
|||
return res; |
|||
} |
|||
File diff suppressed because it is too large
@ -1,101 +0,0 @@ |
|||
/* Copyright (C) 1995, 1996, 1997 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 |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
The GNU C Library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General Public |
|||
License along with the GNU C Library; if not, write to the Free |
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|||
02111-1307 USA. */ |
|||
|
|||
#include "gmp.h" |
|||
#include "gmp-impl.h" |
|||
#include "longlong.h" |
|||
#include "ieee754.h" |
|||
#include <float.h> |
|||
#include <stdlib.h> |
|||
|
|||
/* Convert a `long double' in IEEE854 standard double-precision format to a
|
|||
multi-precision integer representing the significand scaled up by its |
|||
number of bits (64 for long double) and an integral power of two |
|||
(MPN frexpl). */ |
|||
|
|||
mp_size_t |
|||
__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, |
|||
int *expt, int *is_neg, |
|||
long double value) |
|||
{ |
|||
union ieee854_long_double u; |
|||
u.d = value; |
|||
|
|||
*is_neg = u.ieee.negative; |
|||
*expt = (int) u.ieee.exponent - IEEE854_LONG_DOUBLE_BIAS; |
|||
|
|||
#if BITS_PER_MP_LIMB == 32 |
|||
res_ptr[0] = u.ieee.mantissa1; /* Low-order 32 bits of fraction. */ |
|||
res_ptr[1] = u.ieee.mantissa0; /* High-order 32 bits. */ |
|||
#define N 2 |
|||
#elif BITS_PER_MP_LIMB == 64 |
|||
/* Hopefully the compiler will combine the two bitfield extracts
|
|||
and this composition into just the original quadword extract. */ |
|||
res_ptr[0] = ((unsigned long int) u.ieee.mantissa0 << 32) | u.ieee.mantissa1; |
|||
#define N 1 |
|||
#else |
|||
#error "mp_limb size " BITS_PER_MP_LIMB "not accounted for" |
|||
#endif |
|||
|
|||
if (u.ieee.exponent == 0) |
|||
{ |
|||
/* A biased exponent of zero is a special case.
|
|||
Either it is a zero or it is a denormal number. */ |
|||
if (res_ptr[0] == 0 && res_ptr[N - 1] == 0) /* Assumes N<=2. */ |
|||
/* It's zero. */ |
|||
*expt = 0; |
|||
else |
|||
{ |
|||
/* It is a denormal number, meaning it has no implicit leading
|
|||
one bit, and its exponent is in fact the format minimum. */ |
|||
int cnt; |
|||
|
|||
/* One problem with Intel's 80-bit format is that the explicit
|
|||
leading one in the normalized representation has to be zero |
|||
for denormalized number. If it is one, the number is according |
|||
to Intel's specification an invalid number. We make the |
|||
representation unique by explicitly clearing this bit. */ |
|||
res_ptr[N - 1] &= ~(1L << ((LDBL_MANT_DIG - 1) % BITS_PER_MP_LIMB)); |
|||
|
|||
if (res_ptr[N - 1] != 0) |
|||
{ |
|||
count_leading_zeros (cnt, res_ptr[N - 1]); |
|||
if (cnt != 0) |
|||
{ |
|||
#if N == 2 |
|||
res_ptr[N - 1] = res_ptr[N - 1] << cnt |
|||
| (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt)); |
|||
res_ptr[0] <<= cnt; |
|||
#else |
|||
res_ptr[N - 1] <<= cnt; |
|||
#endif |
|||
} |
|||
*expt = LDBL_MIN_EXP - 1 - cnt; |
|||
} |
|||
else |
|||
{ |
|||
count_leading_zeros (cnt, res_ptr[0]); |
|||
res_ptr[N - 1] = res_ptr[0] << cnt; |
|||
res_ptr[0] = 0; |
|||
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return N; |
|||
} |
|||
@ -1,5 +1,11 @@ |
|||
#include <math.h> |
|||
#include <math_ldbl_opt.h> |
|||
|
|||
double __fabs (double x) |
|||
{ |
|||
return __builtin_fabs (x); |
|||
} |
|||
weak_alias (__fabs, fabs) |
|||
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) |
|||
compat_symbol (libm, __fabs, fabsl, GLIBC_2_0); |
|||
#endif |
|||
|
|||
@ -1,5 +1,8 @@ |
|||
#include <math.h> |
|||
#include <math_ldbl_opt.h> |
|||
|
|||
long double __fabsl (long double x) |
|||
{ |
|||
return __builtin_fabsl (x); |
|||
} |
|||
weak_alias (__fabsl, fabsl) |
|||
long_double_symbol (libm, __fabsl, fabsl); |
|||
|
|||
@ -0,0 +1,3 @@ |
|||
# These supply the ABI compatibility for when long double was double. |
|||
ieee754/ldbl-64-128 |
|||
ieee754/ldbl-opt |
|||
@ -0,0 +1,2 @@ |
|||
# Override ldbl-opt with s390 specific routines. |
|||
s390/fpu |
|||
@ -0,0 +1,8 @@ |
|||
/* ABI version for long double switch.
|
|||
This is used by the Versions and math_ldbl_opt.h files in |
|||
sysdeps/ieee754/ldbl-opt/. It gives the ABI version where |
|||
long double == double was replaced with proper long double |
|||
for libm *l functions and libc functions using long double. */ |
|||
|
|||
#define NLDBL_VERSION GLIBC_2.4 |
|||
#define LONG_DOUBLE_COMPAT_VERSION GLIBC_2_4 |
|||
@ -0,0 +1,2 @@ |
|||
# We must list this here to move it ahead of the ldbl-opt code. |
|||
sparc/sparc32/fpu |
|||
Loading…
Reference in new issue