From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17790 invoked by alias); 15 Jun 2003 16:36:18 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 17772 invoked from network); 15 Jun 2003 16:36:17 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 15 Jun 2003 16:36:17 -0000 Received: from Hermes.suse.de (Hermes.suse.de [213.95.15.136]) by Cantor.suse.de (Postfix) with ESMTP id E4276148B5 for ; Sun, 15 Jun 2003 18:36:16 +0200 (MEST) Received: from aj by arthur.inka.de with local (Exim 4.12) id 19RaUH-0005I0-00 for libc-hacker@sources.redhat.com; Sun, 15 Jun 2003 18:36:13 +0200 To: GNU libc hacker Subject: ilogb in tgmath broken From: Andreas Jaeger Date: Sun, 15 Jun 2003 16:36:00 -0000 Message-ID: User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Portable Code, linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2003-06/txt/msg00024.txt.bz2 --=-=-= Content-Transfer-Encoding: quoted-printable Content-length: 5128 Dinkumware pointed out that ilogb is broken: http://www.dinkumware.com/conform_c.html#glibc230_results I'm appending a patch and a testcase. Ok to commit? Andreas 2003-06-15 Andreas Jaeger * math/Makefile (CFLAGS-test-tgmath-ret.c): New. (tests): Add test-tgmath-ret. * math/test-tgmath-ret.c: New file. * math/tgmath.h (ilogb): Return always an int. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: math/tgmath.h --- math/tgmath.h 3 Mar 2003 19:39:31 -0000 1.20 +++ math/tgmath.h 15 Jun 2003 16:18:49 -0000 @@ -400,7 +400,7 @@ __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln) =20 /* Return the binary exponent of X, which must be nonzero. */ -#define ilogb(Val) __TGMATH_UNARY_REAL_ONLY (Val, ilogb) +#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, int, ilogb) =20 =20 /* Return positive difference between X and Y. */ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: math/Makefile --- math/Makefile 21 Feb 2003 05:37:51 -0000 1.120 +++ math/Makefile 15 Jun 2003 16:18:49 -0000 @@ -87,7 +87,7 @@ distribute +=3D $(filter-out $(generated), =20 # Rules for the test suite. tests =3D test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-t= est \ - test-misc test-fpucw tst-definitions test-tgmath + test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret # We do the `long double' tests only if this data type is available and # distinct from `double'. test-longdouble-yes =3D test-ldouble test-ildoubl @@ -126,6 +126,7 @@ CFLAGS-test-float.c =3D -fno-inline -ffloa CFLAGS-test-double.c =3D -fno-inline -ffloat-store CFLAGS-test-ldouble.c =3D -fno-inline -ffloat-store CFLAGS-test-tgmath.c =3D -fno-builtin +CFLAGS-test-tgmath-ret.c =3D -fno-builtin CPPFLAGS-test-ifloat.c =3D -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \ -DTEST_FAST_MATH CPPFLAGS-test-idouble.c =3D -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__= \ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: math/test-tgmath-ret.c --- math/test-tgmath-ret.c created +++ math/test-tgmath-ret.c 2003-06-15 17:47:36.000000000 +0200 1.1 @@ -0,0 +1,82 @@ +/* Test compilation of tgmath macros. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger , 2003. + + 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 +#include + +float fx; +double dx; +long double lx; +int errors =3D 0; + +void +our_error (const char *c) +{ + puts (c); + ++errors; +} + +/* First function where the return type is constant. */ + +#define CHECK_RET_CONST_TYPE(func, rettype, arg, name) \ + if (sizeof (func (arg)) !=3D sizeof (rettype)) \ + our_error ("Return size of " #func " is wrong with " #name " argument"= ); + +#define CHECK_RET_CONST_FLOAT(func, rettype) \ + CHECK_RET_CONST_TYPE (func, rettype, fx, float) +#define CHECK_RET_CONST_DOUBLE(func, rettype) \ + CHECK_RET_CONST_TYPE (func, rettype, dx, double) +#ifdef NO_LONG_DOUBLE +# define CHECK_RET_CONST_LDOUBLE(func, rettype) +#else +# define CHECK_RET_CONST_LDOUBLE(func, rettype) \ + CHECK_RET_CONST_TYPE (func, rettype, lx, long double) +#endif + +#define CHECK_RET_CONST(func, rettype) \ +void \ +check_return_ ##func (void) \ +{ \ + CHECK_RET_CONST_FLOAT (func, rettype) \ + CHECK_RET_CONST_DOUBLE (func, rettype) \ + CHECK_RET_CONST_LDOUBLE (func, rettype) \ +} + +CHECK_RET_CONST(ilogb, int) +CHECK_RET_CONST(lrint, long) +CHECK_RET_CONST(lround, long) +CHECK_RET_CONST(llrint, long long) +CHECK_RET_CONST(llround, long long) + +int +main (void) +{ + check_return_ilogb (); + check_return_lrint (); + check_return_lround (); + check_return_llrint (); + check_return_llround (); + + printf ("%Zd\n", sizeof(carg (lx))); + + return errors !=3D 0; +} --=20 Andreas Jaeger, SuSE Linux AG, aj@suse.de, http://www.suse.de/~aj GPG fingerprint =3D 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 --=-=-= Content-Type: application/pgp-signature Content-length: 197 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA+7KB8OJpWPMJyoSYRAuayAJ9x7TjI+4FvQy7awK1dJm3ZpvS8JACeI4tp qZbON+TUlUQqgQAmfQV2pgw= =q6pb -----END PGP SIGNATURE----- --=-=-=--