From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62258 invoked by alias); 16 Nov 2016 16:53:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 62225 invoked by uid 89); 16 Nov 2016 16:53:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=(unknown) X-Spam-User: qpsmtpd, 4 recipients X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0086.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Nov 2016 16:53:18 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; Received: from [10.2.206.73] (217.140.96.140) by VI1PR0802MB2160.eurprd08.prod.outlook.com (10.172.12.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16; Wed, 16 Nov 2016 16:53:14 +0000 Message-ID: <582C8EF6.2000809@arm.com> Date: Wed, 16 Nov 2016 16:53:00 -0000 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: FX CC: , "gcc-patches@gcc.gnu.org" , FranC'ois-Xavier Coudert , Jerry DeLisle , GCC-Fortran-ML Subject: [PATCH v2][PR libgfortran/78314] Fix ieee_support_halting References: <582B3331.30402@arm.com> <92DFB085-F0FF-4B30-B6BB-B10E598B6030@gmail.com> <582B39DB.80302@arm.com> <24AAE5F7-890A-4154-8BED-478E3C994A11@gmail.com> In-Reply-To: <24AAE5F7-890A-4154-8BED-478E3C994A11@gmail.com> Content-Type: multipart/mixed; boundary="------------090505050807000407000302" X-ClientProxiedBy: AM4PR0902CA0004.eurprd09.prod.outlook.com (10.171.89.14) To VI1PR0802MB2160.eurprd08.prod.outlook.com (10.172.12.17) X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;2:A/phpe0XacHvOvakLNbN/dRmm5ZwfpGnQFV9HbHd1j5TMo9tFUewPqGmphTrxM/rsCDvs6f1C614xyQhn0FIoSJCEsrXINsd2ZxNdkaKyr9d3lOG0RUyA6JYPoy3hAUEFkbaHWykrxn5CwVB4Lk4SzEVP3qClL4CP3h5Q5dVGec=;3:576PKVDoXNJpSjFEaQ4z4W0cHsE1icsStdmiq5/g6P3szeiSDmtQG+yk1ZQuAF09t/+yCA+faGhFg3gpAI4VtLYAO2NeqSI6sha97Y91REC+v41o24gwEbKgnxCNUv4SKMZImawYaXoJU/tn7IMrvkwaA7NUDQf+HpvenRygzfk= X-MS-Office365-Filtering-Correlation-Id: c244c154-df27-43e5-0d04-08d40e410eb7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0802MB2160; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;25:N5B9NTTJqOiKHULFEwrCD/KgRPFtWi6kv+knP5bbOyFzgUIkCgA1TbTXynoK6NIF4h+xlWaCVLSqWopI8YlglVjxT/wLxqKZTblMY5OmRwk97e0swV5t2RjeqPht7D72sjyNztHuXyNQL7ogYeqQsSKgQsM8QGILbTVgWpaeph5/2d+fI6BCgbR/TMNPZwjfrNc4EVXRUXyrPV9Z+X/akXpfNW0ikz0sLVjh1uOQT49peOP4zpCHgstHv+gDsEIQjsKo6a4iDyhafi6naMQS5n6Vl/GNZNw/1XReF0TrW+Soj6xlAMll6eISlmrwFKQGNppCcBCJJ9siscayZfk5yFaCStqxKv4HICk51NsSnGRJkz61aJHaZYnCf4BqfDcQyZiIWiwl9RqtlKwMMpz5gd9oysBa1udSEkRadM3+hFzenzyX7Cz3zcUtMSN6LqjAdhpfqNQjGUQF/flVA1L0VzV2xKuroZPz4pNSdznlCmvbwnDNr6e02OssIZUQLNI3Wv23ehNEIdgTmtqtNNqJhTDffajAxLFdW+3MMXNKsmR6mgA93zwpPnc60a0pgbz5v/9veI/zqqipL+QFXgLDv4476id+kko+hc/0p1PAn9FJdw8pflhg38fQJWCVf+HbV7tlPM1G0R0mJ+/nskh69coQUnnPIyKqTVHnEZDAErsSbv1VLq/2G7XRiGI1+7Y+ghprzMRG9YBdFC3JQ/KyfmYlQLRR+XNvCdKIKaYbdQNGCQ4csG8opb/KLpnjXPnpJu5SKqzGkhg7msnlif+ilo3YnetjR3qsb44W7PlawAdchxJ76nOeV0Idhjd7DyPPX0J+8sIfbvESSV6yD0QQMeesUIYzGBo5bJcVPc9rATc= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;31:g6Bh1yBFjPYpFteSziMR8TfqjQaKLWxM3AP9h7XvT6jii5VhHUmNva1ouxghIpoBU0ElbbcDHvu3RZ+HodLCdsu7Ofi4dwOG86WcNre7ny3+EVzLaNeQku6jdcSVgcV/I5O+DKaRS3DHyLkirJPoviX6gaeN9T6lZLmqjaqGH58LonL26WSoQFV234ghYBlFAJmMfu2Lw6Tdl+REWrDMKsTZTLMZ42tugNu3u60T4vX3II0iuYLQfjtWgdIC8j4yGmuREmOvX+0sopoLw9a1CbdKPeZfrNtqCRrrWpSi6Ng=;20:cwhRmBnOWaVO4h2QCsp8S2f3NHhFNGLkCcn9Q/PkBmPp3EgjLiZWdY95y0B+b/qeRnIisNQBPlUXYwmmrQCgJTTFQUvzMaJw+3zocb8ysNtgHFuD+pNAspYG/jRFIeiGUrhhsbkjgoyCnBk49WMeFyV+XtefH1FfqbC9C8ltamw= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(20558992708506); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(102415395)(6040281)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041223);SRVR:VI1PR0802MB2160;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0802MB2160; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;4:DImTldF0m0ihK/lHLqoxkJ70JveNMt9L8LDlFAZDq4gI1+l89yVfo0GI8JTBqIrltUwCluzJI+bUSooIs+zmbmtP+YqHTN+brOYYVkzvH2jsdG4MHzYL4s2mYARkzb6seiDxA4s/zJ0EYTHKkVnOKfz0hfDuy5Jir2fTolbMQQm5wxEkvxbAspcWwR208Kq7ya9Ivjxu4lAWegU/+MjV9+PBOxL/JI98p2fMcnmTGLOu1DTvJOMBuuKuKp7AJFY09aT9Vgkxlswpy57aF2L+6cfVzCFTMJsKxaAy77x1ZzZqU/DI64H3BZoCyLr4jcvkthUwvdKqTnZ+2ZUPagkDWFqDGfqsS7pLVbf5PmZhaQdCRkcDBIf7gKriGZZrjoQXnbQqLncUa6BecGyuIhOifX9aJ36MoVYwmxsCutvd7xIzLVu+Kl7b06eo0VYBfrWzbfVE6Z/IOECRCoGun+MYMz5Dg528rSjcn/jlhIyyWnIzk9QiN1BgfFfJ+cDX3PrmSTpzNHaf1y6JaONOlxvCwWqQKVl91eYnM72zHhVVKJM= X-Forefront-PRVS: 01283822F8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(377424004)(199003)(4326007)(2906002)(4001350100001)(68736007)(305945005)(106356001)(33656002)(97736004)(81156014)(87266999)(65816999)(5890100001)(4610100001)(36756003)(8676002)(66066001)(81166006)(65806001)(110136003)(5660300001)(7846002)(1411001)(64126003)(2950100002)(6916009)(76176999)(512874002)(21490400002)(4001150100001)(6666003)(65956001)(105586002)(568964002)(270700001)(6116002)(5000100001)(50986999)(54356999)(7736002)(77096005)(93886004)(59896002)(2476003)(42186005)(83506001)(3846002)(189998001)(101416001)(92566002)(86362001)(80316001)(84326002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0802MB2160;H:[10.2.206.73];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0802MB2160;23:SK06PBexgexb5oFRgcBVZYnLfxpAfo58LAW4gxq?= =?us-ascii?Q?wRDMaBTn4ND2jDe0kL6DjXiQrp34kcmlHs5SQQ+PHGhm5KTspmlUJRlAFYyE?= =?us-ascii?Q?hnr/qbq32zYwnwfhz7rJ++gLSkxOIMGm7Mdom0+RRLvitvFKa4XSIM+qiR4b?= =?us-ascii?Q?yJfQhRqmxQe6p33LYDoJ7kIqEsZOUxFPzxI3F3rUCmYWttqLmZuFzlezl4fg?= =?us-ascii?Q?hpLo2NsIVw3DAmgKiYqtDe0Q6ZWGYGroCDBEjC6VUUHuqc70NAuGbgLt7sQ7?= =?us-ascii?Q?MH+3D+kEvdz9tmgFl7URv2WgzhLubD0pdt+SWeuVnLLeFrocpYlfBdzDcHL3?= =?us-ascii?Q?42M7T/L9CY7bwL6GwHVoaZSadDl03/P9kkBIhnT/TA5xkQjzMBqGpGahFygX?= =?us-ascii?Q?h1ncqLM9JIkK1/PGlJ5PBNFN0oeDsAACVA0/kI0hAReZnjmlm1Gy+KxO61DQ?= =?us-ascii?Q?KTyM4P4jhEsiK1/vtYjTz8XVwEc3mo+9m1UR0sSH7suhJgdyqrwdMPTWGUXU?= =?us-ascii?Q?vmUaBNmwc9w55POqZwW+dmLwrmwo5BdeQamFNWlIJctmaAa/lbu+9zArGxFz?= =?us-ascii?Q?kgaqW7F6IMRXFU41GSaQBT3cQimWI2exdklDRzUi212A9MtvWswMj6eWXhkJ?= =?us-ascii?Q?glv9664Di/ygwdZP8MBwfeDKXoLCO3KPdnnZm0Q7eumFf1WyvnJ47hRO/d5R?= =?us-ascii?Q?yu3+K4KRtwGP+i+ZRzXlqUYiWdhH9AMxspt5y00JZ1RlDQLb2aKjms7zo8JY?= =?us-ascii?Q?SDoKN1MMQME2vu9g+99lXQAJGuZNOmqxGw1zQ3VGc7SyQh68/12n0RiQrOck?= =?us-ascii?Q?56OdxaD3wy9cQUYpt6AaVbbsH7MCM7sXjUu/uAq1oyNwIHcAq6bD8uCuMaIu?= =?us-ascii?Q?/p8YkuVbtY467188+WysplgjnToxXAHE1jjve506h2uwCRRItWru3tEyKGo2?= =?us-ascii?Q?ldwxg8Tl9IyAkkTMOES/FRp563R5KGcDwhh0aojlqBAeIUUQ+K/DzfzNl78c?= =?us-ascii?Q?Vwl3NLqrGTA50gRBKtTiLvlPh4AeWBmbl0oHI9Lh+Nm3b3sChBhJKUYQjSDe?= =?us-ascii?Q?+Ej2lIQSW91t79hUAmZb9/N76SI3flVhoMSBp4vjwVJhXPlOOBflC6l2n7GC?= =?us-ascii?Q?JQkHu+JRfSDFxu+abisjXyCpS6eHML5KHAvfOvdRCu76AVlseaZCJTKG2nXs?= =?us-ascii?Q?WiGASC6hAY2+pUdv9J2ABiH+Ne7/eUFwln/+sX7GhynQJwUzNyRrEErBiHeG?= =?us-ascii?Q?815k8pmvF490QCpZVlrq2zYVSDFHF+5S+9X5g+bWMfN7AAqmAUtkxU/HfCbY?= =?us-ascii?Q?UUNyf8o0SAkwjJaqqFYHIHrAz1ri025JJbRC1inWsDQwHpWOdW4uACXhk9+e?= =?us-ascii?Q?0OQ1oljACmMtLoJmuxwlRZs/YNPILg0kd+GEOfZpc67l59OSE6mUPp+yNo1n?= =?us-ascii?Q?rJHazollhJoAxS9P6Zkx0ET/mKOJoaUh2uO/ZPX+4/RdTLq15iM1q?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;6:1GmoRXf0bVf97KBx6UEppnD5M0cOaI72qOVhiy4Foiosn2XdHWlajv4xf/IWipVHknPXxXyfZuJy+uBDPS6EdUlAuMLQFtXuyGIhIEWlEIn2iJkxcTz6VOiKwzrBuEZ2xXY065VfOaiPIg6xn54R5WXydE5kyehuo4ZpQnTHkO8U2sh5jotncgMHKE5WFxT9GtwOIJV1dcWWVGEqErfMVCfYCZURGXmGHqJ4gL1NUdslUX5mbpIrpJuoyjK0HgFtVrbOLZo3bxecSRV6l69IZzUJ5cDr6UoPG3wyfpA5hJRVMHyN6p5+dYhKB0xM5Yz8g2KLW0j42zGW2QDxzCfIdg==;5:Q1luQX/zmS7JyWEnEsvu/O83EWb6gXrkqhf+cykLw3QQHgzQrR7of2WbFPbon1tkeasH9zJkRlBVneiNacpB+xZ1ehjQnNi/bo0hrskPI87Yo0h6vt0h++SzdH3m3CQ/phtmtErAfENVdn8Tl/9eMwzbOo3UotiFu3mfCamfdqE=;24:RsAb2xA/AxYbvwvflt3QIKl+tm7jfvNC/WeIKrWHfvPLxMVqE2pbCcR13FtEW9YMXvtnaB3egSXjHxjd6m4DLPkQvqxlkHUNT0ppv3cUbfw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2160;7:A8k+MInqfZJTlANsMgWa29466X+fE9sSki2EN3BDcOZB5Kp4Rti9jSA/9BHwUaKpUeZbC8bQvbg2Zlb3+1jXFCp/zj5FhRe1Zm3GxqDM4jHPFrod4K32Nucr/EY7DfGbIf92XCZGBl+22v3q9Gpw0x04iuFrJsRcGJPROL7tLTXzJQpyAQjdxzzksdJetJJ6LXO6MtWwfCVSn2s3BFJFjq97ETocVTYpfGecc7rtBM1gV+9z8zlMem4hssjdNPzsuhUxrdwkKM8hiLAvtgoszG8i4S06F4l7iSjaN6R/D4y0qfL00T1fgvSlKlo49SSi5mJxxEKby8O1wT2rJfmAktaZu9IujcM1PALBhGoaxcU= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 16:53:14.5654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2160 X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg01663.txt.bz2 --------------090505050807000407000302 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 670 ieee_support_halting only checked the availability of status flags, not trapping support. On some targets the later can only be checked at runtime: feenableexcept reports if enabling traps failed. So check trapping support by enabling/disabling it. Updated the test that enabled trapping to check if it is supported. Tested on aarch64-linux-gnu and x86_64-linux-gnu. gcc/testsuite/ 2016-11-16 Szabolcs Nagy PR libgfortran/78314 * gfortran.dg/ieee/ieee_6.f90: Use ieee_support_halting. libgfortran/ 2016-11-16 Szabolcs Nagy PR libgfortran/78314 * config/fpu-glibc.h (support_fpu_trap): Use feenableexcept. --------------090505050807000407000302 Content-Type: text/x-patch; name="fptrap3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fptrap3.diff" Content-length: 2596 diff --git a/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 b/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 index 8fb4f6f..43aa3bf 100644 --- a/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 +++ b/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 @@ -9,7 +9,7 @@ implicit none type(ieee_status_type) :: s1, s2 - logical :: flags(5), halt(5) + logical :: flags(5), halt(5), haltworks type(ieee_round_type) :: mode real :: x @@ -18,6 +18,7 @@ call ieee_set_flag(ieee_all, .false.) call ieee_set_rounding_mode(ieee_down) call ieee_set_halting_mode(ieee_all, .false.) + haltworks = ieee_support_halting(ieee_overflow) call ieee_get_status(s1) call ieee_set_status(s1) @@ -46,7 +47,7 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort call ieee_set_status(s2) @@ -58,7 +59,7 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort call ieee_set_status(s1) @@ -79,6 +80,6 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort end diff --git a/libgfortran/config/fpu-glibc.h b/libgfortran/config/fpu-glibc.h index 6e505da..8b29a76 100644 --- a/libgfortran/config/fpu-glibc.h +++ b/libgfortran/config/fpu-glibc.h @@ -121,7 +121,41 @@ get_fpu_trap_exceptions (void) int support_fpu_trap (int flag) { - return support_fpu_flag (flag); + int exceptions = 0; + int old; + + if (!support_fpu_flag (flag)) + return 0; + +#ifdef FE_INVALID + if (flag & GFC_FPE_INVALID) exceptions |= FE_INVALID; +#endif + +#ifdef FE_DIVBYZERO + if (flag & GFC_FPE_ZERO) exceptions |= FE_DIVBYZERO; +#endif + +#ifdef FE_OVERFLOW + if (flag & GFC_FPE_OVERFLOW) exceptions |= FE_OVERFLOW; +#endif + +#ifdef FE_UNDERFLOW + if (flag & GFC_FPE_UNDERFLOW) exceptions |= FE_UNDERFLOW; +#endif + +#ifdef FE_DENORMAL + if (flag & GFC_FPE_DENORMAL) exceptions |= FE_DENORMAL; +#endif + +#ifdef FE_INEXACT + if (flag & GFC_FPE_INEXACT) exceptions |= FE_INEXACT; +#endif + + old = feenableexcept (exceptions); + if (old == -1) + return 0; + fedisableexcept (exceptions & ~old); + return 1; } --------------090505050807000407000302--