From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9624 invoked by alias); 31 Jan 2006 16:56:13 -0000 Received: (qmail 9607 invoked by uid 22791); 31 Jan 2006 16:56:12 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 31 Jan 2006 16:56:11 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k0VGu6k1012087; Tue, 31 Jan 2006 17:56:06 +0100 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k0VGu6FU012085; Tue, 31 Jan 2006 17:56:06 +0100 Date: Tue, 31 Jan 2006 16:56:00 -0000 From: Jakub Jelinek To: Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix sparc32 build with GCC 4.0+ Message-ID: <20060131165606.GT4625@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00104.txt.bz2 Hi! This patch fixes a few sparc32 build things: 1) works around the chicken-and-egg problem where -mlong-double-128 libgcc requires -mlong-double-128 glibc (for _Q_*) and -mlong-double-128 glibc requires -mlong-double-128 libgcc (for __multc3/__divtc3). 2) prepends sparc/sparc32/fpu before ldbl-64-128 and ldbl-opt, so that the generic wrappers don't override e.g. s_fabs{,l} and adjusts them. 2006-01-31 Jakub Jelinek * sysdeps/unix/sysv/linux/sparc/sparc32/Implies: Moved to ... * sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Implies: ... here. New file. * sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Makefile: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/fpu/divtc3.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/fpu/multc3.c: 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. --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Implies.jj 2006-01-31 16:06:04.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Implies 2006-01-31 16:06:00.000000000 +0100 @@ -0,0 +1,5 @@ +# Override ldbl-opt with sparc specific routines. +sparc/sparc32/fpu +# These supply the ABI compatibility for when long double was double. +ieee754/ldbl-64-128 +ieee754/ldbl-opt --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/divtc3.c.jj 2006-01-31 16:08:19.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/divtc3.c 2006-01-31 16:15:34.000000000 +0100 @@ -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 , 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 +#include +#include + +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; +} --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/multc3.c.jj 2006-01-31 16:08:32.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/multc3.c 2006-01-31 16:15:44.000000000 +0100 @@ -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 , 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 +#include +#include + +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; +} --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Makefile.jj 2006-01-31 16:09:48.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/fpu/Makefile 2006-01-31 16:12:58.000000000 +0100 @@ -0,0 +1,9 @@ +ifeq ($(subdir),math) +# These 2 routines are normally in libgcc{.a,_s.so.1}. +# However, sparc32 -mlong-double-128 libgcc relies on +# glibc providing _Q_* routines and without these files +# glibc relies on __multc3/__divtc3 only provided +# by libgcc if configured with -mlong-double-128. +# Provide these routines here as well. +libm-routines += multc3 divtc3 +endif # math --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/Implies.jj 2006-01-14 13:09:03.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/Implies 2006-01-31 16:06:10.000000000 +0100 @@ -1,3 +0,0 @@ -# These supply the ABI compatibility for when long double was double. -ieee754/ldbl-64-128 -ieee754/ldbl-opt --- libc/sysdeps/sparc/sparc32/fpu/s_fabsl.c.jj 2006-01-14 13:09:02.000000000 +0100 +++ libc/sysdeps/sparc/sparc32/fpu/s_fabsl.c 2006-01-31 17:10:10.000000000 +0100 @@ -1,5 +1,8 @@ +#include +#include + long double __fabsl (long double x) { return __builtin_fabsl (x); } -weak_alias (__fabsl, fabsl) +long_double_symbol (libm, __fabsl, fabsl); --- libc/sysdeps/sparc/sparc32/fpu/s_fabs.c.jj 2006-01-14 13:09:02.000000000 +0100 +++ libc/sysdeps/sparc/sparc32/fpu/s_fabs.c 2006-01-31 17:10:57.000000000 +0100 @@ -1,5 +1,11 @@ +#include +#include + 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 Jakub