From patchwork Thu Dec 21 19:53:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 25066 Received: (qmail 84464 invoked by alias); 21 Dec 2017 19:53:46 -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 84452 invoked by uid 89); 21 Dec 2017 19:53:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=relied X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: Joseph Myers CC: "libc-alpha@sourceware.org" , nd Subject: Re: [PATCH] Improve math_errhandling Date: Thu, 21 Dec 2017 19:53:41 +0000 Message-ID: References: , In-Reply-To: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB2054; 6:qRPphtN8ZXZtPLV5VvngQ1Loo/AXKizVncx/X5lJZqr+Riuk4fXC7De1CQGI3AiPSGxSwEIWUQW3OvCk1jaKFqqUtJU6i/IqM0EDER/VfeOFENQciD9IZP6Xsd6JYha0E/GRzCT+VX6AiUldtRWpc/Zt6Fl9IqZps7Ipr7OVSRKH+A7l/st1hoQhCAM2XsBqL3XT8PqiA2YFSbYtO8kp/uT8wmBYV+dHcd8+W7uIS/jZHZB/1iq7t2BG/7wDmQh81BDvlhDDzpPMdrWjyu6WiVoFZ5OS2d+whIYU0E8UXffJE3w45/ne8vwTL1Ooh81ohxZnIUf3h8inctWpY/uQbUwtsjgujsz7rBWX4LDhp2E=; 5:XUS/6DkZtgi14mprz4Jt2lQeIRrF5hokLP73ZIa2HkqKRYuUTo2ZmwAmMd2slqZAqdkF7Oz8DaTc6cau3FR+ui+teAx+bpUMl4tjoSjzRQIjSnYYiDhju+AJ7MzlFSSy9iUELejcJLRZjTfHQTSPVDhcoP1i4tZ7BYFgs4LrSn4=; 24:HMolpm4U58NHiw/DXovVQHSU+UWrEOt0lC2CdYMPCNq62jcyWew9eBKKagowEUTdxvUSLzG2U5ehPtJilkNxpZ2Y5A4vZgmW1WFs5eahpRs=; 7:CldWQ3p+lZOXOOxCaI+tfSU7q2zMMt8F6ImRJnE+Kzdef3KgLpg8AugieP3E/QVnL83fiWmqkCQ6NdvZUPdUiACXFABx8mx9v+NZ++Gkf7i0/rf13rWluGlfCX02UUHcO19LcdiNEzdvJojNooalrCSAK2BYBrI8JAxymlsGn0aaZTb5+dneBhan09v+2h3mcmFzV5/SEDRowSSHXIrspGeDf0lccuL0GbVya4/T0PVQVllab1q+2quqps53fASE x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1d76f0ff-0690-4ad7-365e-08d548ac88f2 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(5600026)(4604075)(3008031)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:DB6PR0801MB2054; x-ms-traffictypediagnostic: DB6PR0801MB2054: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501030)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041268)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:DB6PR0801MB2054; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DB6PR0801MB2054; x-forefront-prvs: 0528942FD8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(39380400002)(54534003)(377424004)(189003)(199004)(24454002)(97736004)(6116002)(25786009)(66066001)(4326008)(3846002)(7696005)(76176011)(478600001)(2900100001)(86362001)(6506007)(229853002)(68736007)(575784001)(4001150100001)(102836004)(99286004)(105586002)(8676002)(5250100002)(81166006)(6246003)(59450400001)(8936002)(74316002)(81156014)(53936002)(305945005)(33656002)(55016002)(3660700001)(106356001)(2906002)(2950100002)(3280700002)(72206003)(5660300001)(6436002)(9686003)(14454004)(316002)(54906003)(6916009)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2054; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; 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) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d76f0ff-0690-4ad7-365e-08d548ac88f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Dec 2017 19:53:41.0692 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2054 Joseph Myers wrote: > > The header definitely needs to check for __FAST_MATH__.  There is a case > for defining math_errhandling to 0 in the __FAST_MATH__ case (a > nonconforming value, but -ffast-math is a nonconforming mode, and 0 > accurately reflects the situation that neither errno nor exceptions can be > relied upon in that case) rather than the existing state of being > undefined (also nonconforming).  Note that GCC versions before GCC 5 don't > define __NO_MATH_ERRNO__ at all. OK, setting to 0 for __FAST_MATH__ seems reasonable. Here is the revised patch: Currently math_errhandling is always set to MATH_ERRNO | MATH_ERREXCEPT even if -fno-math-errno is used. It is not defined at all when fast-math is used. Set it to 0 with fast-math - this is noncomforming but more useful than not define math_errhandling at all. Also take __NO_MATH_ERRNO__ into account and update comment. ChangeLog: 2017-12-21 Wilco Dijkstra * math/math.h (math_errhandling): Add __NO_MATH_ERRNO__ check. diff --git a/math/math.h b/math/math.h index 72d7dc59391af71c4db9634998463b4f947b9f09..9bf0c66e862d15277f8e4f31f3b35b9d4a3ad958 100644 --- a/math/math.h +++ b/math/math.h @@ -665,10 +665,16 @@ enum # define MATH_ERRNO 1 /* errno set by math functions. */ # define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ -/* By default all functions support both errno and exception handling. - In gcc's fast math mode and if inline functions are defined this - might not be true. */ -# ifndef __FAST_MATH__ +/* By default all math functions support both errno and exception handling + (except for soft floating point implementations which may only support + errno handling). If errno handling is disabled, exceptions are still + supported by GLIBC. Set math_errhandling to 0 with -ffast-math (this is + nonconforming but it is more useful than leaving it undefined). */ +# ifdef __FAST_MATH__ +# define math_errhandling 0 +# elif defined __NO_MATH_ERRNO__ +# define math_errhandling (MATH_ERREXCEPT) +# else # define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT) # endif