From patchwork Tue Mar 25 18:21:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 278 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (caibbdcaabja.dreamhost.com [208.113.200.190]) by wilcox.dreamhost.com (Postfix) with ESMTP id 914923600C8 for ; Tue, 25 Mar 2014 11:21:04 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id 4869461F4B683; Tue, 25 Mar 2014 11:21:04 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id 2338A628BA43B for ; Tue, 25 Mar 2014 11:21:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=Jr6k68f75SZ5IUUsOubyFjp26q5aEu1X+r9ff5HWbZY OQQZMpET4qzt3BnBnwU9I0SZeLw1UYyB7ENWmR9yY3usD1NbShx14EOH1LY1hCiq ZDXmjMFVjxRiOmD4Db1XVClp9gUeIYzOx6/UrWKrllHTRSEJssRpVVxQ1drfuvfs = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=+T9iG11Tyuqe3MZ7FfwIpqvMxdk=; b=lyZ39k48byGCpxGx0 sWkvlsZy4siyOlgcnIcZIjxQB/o/lPL9dnHxIT0pbCDYdoP+fTk9j6tBC/gBikZ7 B7RgYV2SmTwIFRpKAHO6yp442+E6C9xZhxpsgMZYz8/enTxbDk/4bZRdp9cu6Gzw EuZ2hykAptZHSIs2+RQpHlXYu8= Received: (qmail 1702 invoked by alias); 25 Mar 2014 18:21:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1691 invoked by uid 89); 25 Mar 2014 18:21:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco" To: "'Joseph Myers'" Cc: References: <000101cf4392$529cd5d0$f7d68170$@com> In-Reply-To: Subject: RE: [PATCH] [ARM] Add fenv test support for targets which don't have FP traps Date: Tue, 25 Mar 2014 18:21:04 -0000 Message-ID: <000401cf4856$fc7a3b10$f56eb130$@com> MIME-Version: 1.0 X-MC-Unique: 114032518205609201 X-DH-Original-To: glibc@patchwork.siddhesh.in On Wed, 19 Mar 2014, Joseph Myers wrote: >> +/* Indicate whether the given exception trap(s) can be enabled >> + in feenableexcept. All traps are supported unless overridden. */ >> +#ifndef EXCEPTION_ENABLE_SUPPORTED >> +# define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) \ >> + (EXCEPTION_TESTS_float || EXCEPTION_TESTS_double) >> +#endif > > I think the comment needs to make the definition clearer (that a nonzero > value means the traps are definitely supported, but a zero value means > they might or might not be supported and this is determined at runtime > with enabling traps being allowed to fail). I've updated the comment to: +/* Indicate whether the given exception trap(s) can be enabled + in feenableexcept. If non-zero, the traps are always supported. + If zero, traps may or may not be supported depending on the + target (this can be determined by checking the return value + of feenableexcept). This enables skipping of tests which use + traps. By default traps are supported unless overridden. */ Wilco --- math/test-fenv.c | 25 +++++++++++++++---------- sysdeps/arm/math-tests.h | 3 +++ sysdeps/generic/math-tests.h | 11 +++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/math/test-fenv.c b/math/test-fenv.c index 73cd1a7..23e47d4 100644 --- a/math/test-fenv.c +++ b/math/test-fenv.c @@ -36,6 +36,7 @@ #include #include #include +#include /* Since not all architectures might define all exceptions, we define @@ -233,14 +234,9 @@ feenv_nomask_test (const char *flag_name, int fe_exc) #if defined FE_NOMASK_ENV int status; pid_t pid; - fenv_t saved; - fegetenv (&saved); - errno = 0; - fesetenv (FE_NOMASK_ENV); - status = errno; - fesetenv (&saved); - if (status == ENOSYS) + if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT) + && fesetenv (FE_NOMASK_ENV) != 0) { printf ("Test: not testing FE_NOMASK_ENV, it isn't implemented.\n"); return; @@ -349,7 +345,13 @@ feexcp_nomask_test (const char *flag_name, int fe_exc) int status; pid_t pid; - printf ("Test: after fedisableexcept (%s) processes will abort\n", + if (!EXCEPTION_ENABLE_SUPPORTED (fe_exc) && feenableexcept (fe_exc) == -1) + { + printf ("Test: not testing feenableexcept, it isn't implemented.\n"); + return; + } + + printf ("Test: after feenableexcept (%s) processes will abort\n", flag_name); printf (" when feraiseexcept (%s) is called.\n", flag_name); pid = fork (); @@ -470,7 +472,6 @@ feenable_test (const char *flag_name, int fe_exc) { int excepts; - printf ("Tests for feenableexcepts etc. with flag %s\n", flag_name); /* First disable all exceptions. */ @@ -488,8 +489,12 @@ feenable_test (const char *flag_name, int fe_exc) flag_name, excepts); ++count_errors; } - excepts = feenableexcept (fe_exc); + if (!EXCEPTION_ENABLE_SUPPORTED (fe_exc) && excepts == -1) + { + printf ("Test: not testing feenableexcept, it isn't implemented.\n"); + return; + } if (excepts == -1) { printf ("Test: feenableexcept (%s) failed\n", flag_name); diff --git a/sysdeps/arm/math-tests.h b/sysdeps/arm/math-tests.h index e65f135..ea5f8dc 100644 --- a/sysdeps/arm/math-tests.h +++ b/sysdeps/arm/math-tests.h @@ -29,4 +29,7 @@ # define EXCEPTION_TESTS_long_double 0 #endif +/* Not all VFP implementations support trapping exceptions. */ +#define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) ((EXCEPT) == 0) + #include_next diff --git a/sysdeps/generic/math-tests.h b/sysdeps/generic/math-tests.h index c86b067..3f2bd69 100644 --- a/sysdeps/generic/math-tests.h +++ b/sysdeps/generic/math-tests.h @@ -76,3 +76,14 @@ (sizeof (TYPE) == sizeof (float) ? EXCEPTION_TESTS_float \ : sizeof (TYPE) == sizeof (double) ? EXCEPTION_TESTS_double \ : EXCEPTION_TESTS_long_double) + +/* Indicate whether the given exception trap(s) can be enabled + in feenableexcept. If non-zero, the traps are always supported. + If zero, traps may or may not be supported depending on the + target (this can be determined by checking the return value + of feenableexcept). This enables skipping of tests which use + traps. By default traps are supported unless overridden. */ +#ifndef EXCEPTION_ENABLE_SUPPORTED +# define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) \ + (EXCEPTION_TESTS_float || EXCEPTION_TESTS_double) +#endif