From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 721 invoked by alias); 4 Jun 2013 19:26:43 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 687 invoked by uid 89); 4 Jun 2013 19:26:42 -0000 X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 04 Jun 2013 19:26:41 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UjwsR-0005VN-VY from joseph_myers@mentor.com ; Tue, 04 Jun 2013 12:26:40 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 4 Jun 2013 12:26:39 -0700 Received: from digraph.polyomino.org.uk (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Tue, 4 Jun 2013 20:26:37 +0100 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.76) (envelope-from ) id 1UjwsO-0002qg-03; Tue, 04 Jun 2013 19:26:36 +0000 Date: Tue, 04 Jun 2013 19:26:00 -0000 From: "Joseph S. Myers" To: CC: Subject: Add rounding mode information to math-tests.h and use it in libm-test.inc Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2013-06/txt/msg00002.txt.bz2 The lists of known testsuite failures for ARM and MIPS include various tests failing in circumstances when rounding modes or exceptions support is not available at runtime. In line with the principle of trying to have zero failures as the expected testsuite state, this patch adds macros to math-tests.h to say when testing of a rounding mode should be disabled despite fesetround succeeding, and makes libm-test.inc use them, with definitions being added for ARM; similar macros will also be needed to indicate when support for exceptions is available, and the macros will need using in other tests. These macros will also be usable for MIPS, to describe the situation there where MIPS64 long double (IEEE quad) is implemented in libgcc using soft-fp without support for exceptions or rounding modes, even when float and double use hardware floating point. (fesetround passing but not properly affecting all types is of course a bug, but one only fixable in libgcc - by using IFUNC there in the ARM case to make __aeabi_* use VFP when available at runtime, by using soft-fp instead of fp-bit in the MIPS case. Disabling the tests here is similar to the existing handling of sNaN tests; if the GCC issues are fixed, the math-tests.h definitions can be made conditional on the GCC version. Macros indicating when exception support is expected to be missing will still be relevant even with fixed libgcc.) Tested on an affected ARM configuration that the non-default rounding-mode tests from libm-test.inc are no longer run with this patch applied. 2013-06-04 Joseph Myers * sysdeps/generic/math-tests.h (ROUNDING_TESTS_float): New macro. (ROUNDING_TESTS_double): Likewise. (ROUNDING_TESTS_long_double): Likewise. (ROUNDING_TESTS): Likewise. * math/libm-test.inc: Include . (IF_ROUND_INIT_FE_DOWNWARD): Use ROUNDING_TESTS. (IF_ROUND_INIT_FE_TONEAREST): Likewise. (IF_ROUND_INIT_FE_TOWARDZERO): Likewise. (IF_ROUND_INIT_FE_UPWARD): Likewise. ports/ChangeLog.arm 2013-06-04 Joseph Myers * sysdeps/arm/math-tests.h: New file. diff --git a/math/libm-test.inc b/math/libm-test.inc index 6870d96..ed050cb 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -125,6 +125,7 @@ #include #include #include +#include /* Structure for ulp data for a test, a function, or the real or imaginary part of a function. */ @@ -1085,16 +1086,20 @@ struct test_fFF_11_data #define IF_ROUND_INIT_ /* Empty. */ #define IF_ROUND_INIT_FE_DOWNWARD \ int save_round_mode = fegetround (); \ - if (fesetround (FE_DOWNWARD) == 0) + if (ROUNDING_TESTS (FLOAT, FE_DOWNWARD) \ + && fesetround (FE_DOWNWARD) == 0) #define IF_ROUND_INIT_FE_TONEAREST \ int save_round_mode = fegetround (); \ - if (fesetround (FE_TONEAREST) == 0) + if (ROUNDING_TESTS (FLOAT, FE_TONEAREST) \ + && fesetround (FE_TONEAREST) == 0) #define IF_ROUND_INIT_FE_TOWARDZERO \ int save_round_mode = fegetround (); \ - if (fesetround (FE_TOWARDZERO) == 0) + if (ROUNDING_TESTS (FLOAT, FE_TOWARDZERO) \ + && fesetround (FE_TOWARDZERO) == 0) #define IF_ROUND_INIT_FE_UPWARD \ int save_round_mode = fegetround (); \ - if (fesetround (FE_UPWARD) == 0) + if (ROUNDING_TESTS (FLOAT, FE_UPWARD) \ + && fesetround (FE_UPWARD) == 0) #define ROUND_RESTORE_ /* Empty. */ #define ROUND_RESTORE_FE_DOWNWARD \ fesetround (save_round_mode) diff --git a/ports/sysdeps/arm/math-tests.h b/ports/sysdeps/arm/math-tests.h new file mode 100644 index 0000000..6b8e089 --- /dev/null +++ b/ports/sysdeps/arm/math-tests.h @@ -0,0 +1,28 @@ +/* Configuration for math tests. ARM version. + Copyright (C) 2013 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, see + . */ + +/* On systems with VFP support, but where glibc is built for + soft-float, the libgcc functions used in libc and libm do not + support rounding modes, although fesetround succeeds. */ +#ifdef __SOFTFP__ +# define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) +# define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) +# define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) +#endif + +#include_next diff --git a/sysdeps/generic/math-tests.h b/sysdeps/generic/math-tests.h index da8747a..b1e9fd7 100644 --- a/sysdeps/generic/math-tests.h +++ b/sysdeps/generic/math-tests.h @@ -40,3 +40,21 @@ #ifndef SNAN_TESTS_TYPE_CAST # define SNAN_TESTS_TYPE_CAST 1 #endif + +/* Indicate whether to run tests involving a given rounding mode for a + given floating-point type, given that fesetround succeeds for that + mode. All are run if fesetround succeeds unless overridden. */ +#ifndef ROUNDING_TESTS_float +# define ROUNDING_TESTS_float(MODE) 1 +#endif +#ifndef ROUNDING_TESTS_double +# define ROUNDING_TESTS_double(MODE) 1 +#endif +#ifndef ROUNDING_TESTS_long_double +# define ROUNDING_TESTS_long_double(MODE) 1 +#endif + +#define ROUNDING_TESTS(TYPE, MODE) \ + (sizeof (TYPE) == sizeof (float) ? ROUNDING_TESTS_float (MODE) \ + : sizeof (TYPE) == sizeof (double) ? ROUNDING_TESTS_double (MODE) \ + : ROUNDING_TESTS_long_double (MODE)) -- Joseph S. Myers joseph@codesourcery.com