From patchwork Fri Jul 20 10:35:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 172198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 622442C0302 for ; Fri, 20 Jul 2012 20:36:22 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343385382; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Date:From:To:CC:Subject:Message-ID:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=KWl5ZIJ jUcXSs9yr7FeeRV8bAnM=; b=wqGFnIhbZwize4FEqYSkqPSZhbS2U/XWG9xG4fl LGbXZGquFVqhU4HYIW1ZmPtIxI8FOJpUbf9TfCdPn9xwTNq290LvTCsXppvOQ/l7 53EozLkpIJIjlWPUa8HtcVvr6TTsnUb5d5OXybD1MU+kce858cXI85JPxUSyM0hd 2tWo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Date:From:To:CC:Subject:Message-ID:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=QoV6veUxH0Ffp8eKeGXoFTW6bOxbBvSyzWTc23sSR+MHAMbtmKF6Umkr020kPI j0O7SI2WN3R3/iO7zIDlSPPkEX3qtcp+qEqb/IILZ4tY0NKC9Z30aaTyD7zSa2lt /2NM47g+4HGXRIgpqS7THq+THHH9kARBR7K3J3XIXVkFo=; Received: (qmail 13546 invoked by alias); 20 Jul 2012 10:36:17 -0000 Received: (qmail 13432 invoked by uid 22791); 20 Jul 2012 10:36:15 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, FROM_12LTRDOM, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jul 2012 10:36:02 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SsAYy-0005hf-VQ from Julian_Brown@mentor.com ; Fri, 20 Jul 2012 03:36:01 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 20 Jul 2012 03:36:05 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Fri, 20 Jul 2012 11:35:58 +0100 Date: Fri, 20 Jul 2012 11:35:52 +0100 From: Julian Brown To: CC: , Subject: [PATCH, ARM] Tweak gcc.c-torture/execute/20101011-1.c to test division-by-zero trapping on ARM Message-ID: <20120720113552.5b452950@octopus> MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, On several architectures, the test gcc.c-torture/execute/20101011-1.c tests the raising of a signal when a division by zero occurs, but at present the test is simply skipped on ARM. We can make the test slightly more useful by using the EABI-provided ability to define a division-by-zero handling function which raises SIGFPE -- thus mimicking the behaviour of other targets, and allowing us to run the test as intended. If the target has hardware integer division instructions, the test is still skipped. The new test passes for a bare-metal config. OK to apply? Thanks, Julian ChangeLog gcc/testsuite/ * gcc.c-torture/execute/20101011-1.c (__aeabi_idiv0): Define for ARM. (DO_TEST): Define to 1 for appropriate ARM targets. Index: gcc/testsuite/gcc.c-torture/execute/20101011-1.c =================================================================== --- gcc/testsuite/gcc.c-torture/execute/20101011-1.c (revision 189656) +++ gcc/testsuite/gcc.c-torture/execute/20101011-1.c (working copy) @@ -15,9 +15,6 @@ #elif defined (__TMS320C6X__) /* On TI C6X division by zero does not trap. */ # define DO_TEST 0 -#elif defined (__arm__) - /* We cannot rely on division by zero generating a trap. */ -# define DO_TEST 0 #elif defined (__mips__) && !defined(__linux__) /* MIPS divisions do trap by default, but libgloss targets do not intercept the trap and raise a SIGFPE. The same is probably @@ -36,6 +33,24 @@ /* Attempting to trap division-by-zero in this way isn't likely to work on bare-metal m68k systems. */ # define DO_TEST 0 +#elif defined (__arm__) && defined (__ARM_EABI__) +# ifdef __ARM_ARCH_EXT_IDIV__ + /* Hardware division instructions may not trap, and handle trapping + differently anyway. Skip the test if we have those instructions. */ +# define DO_TEST 0 +# else +# include + /* ARM division-by-zero behaviour is to call a helper function, which + can do several different things, depending on requirements. Emulate + the behaviour of other targets here by raising SIGFPE. */ +int __attribute__((used)) +__aeabi_idiv0 (int return_value) +{ + raise (SIGFPE); + return return_value; +} +# define DO_TEST 1 +# endif #else # define DO_TEST 1 #endif