From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6919 invoked from network); 4 Jan 2022 21:12:18 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 4 Jan 2022 21:12:18 -0000 Received: (qmail 18353 invoked by uid 550); 4 Jan 2022 21:12:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 18318 invoked from network); 4 Jan 2022 21:12:14 -0000 Date: Tue, 4 Jan 2022 22:12:02 +0100 From: Szabolcs Nagy To: Paul Zimmermann Cc: Rich Felker , musl@lists.openwall.com, sibid@uvic.ca, christoph.lauter@christoph-lauter.org, Jean-Michel.Muller@ENS-LYON.FR Message-ID: <20220104211202.GB1320090@port70.net> Mail-Followup-To: Paul Zimmermann , Rich Felker , musl@lists.openwall.com, sibid@uvic.ca, christoph.lauter@christoph-lauter.org, Jean-Michel.Muller@ENS-LYON.FR References: <20220104022905.GB7074@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [musl] correctly rounded mathematical functions * Paul Zimmermann [2022-01-04 15:19:48 +0100]: > > Is there a standalone version of the code where it can be read in full > > not as a patch to glibc? Is the code being developed in such a way > > that it's not potentially a derivative work of the glibc versions? > > yes there are several standalone versions of the code (entries marked "full" > on https://homepages.loria.fr/PZimmermann/CORE-MATH/). i only looked at cr_asinf: float cr_asinf (float x) { /* deal here with NaN, +Inf and -Inf */ yeah that can be tricky and different across math libs. (errno vs no errno, wrapper to handle special cases vs no wrapper etc) to minimize branches you may want to merge it with the |x|>1 check below. double absx = fabsf (x), y; if (absx > 1) return sqrt (-1.0); /* NaN */ ... this reminds me that musl does not use compiler builtins at build time, which means fabsf, sqrt are extern calls, which means this will not be a leaf function (note: sqrt is not a tail call here because of the implicit conversion, i think it should be sqrtf). i prefer to tail call a function with descriptive name when handling errors, but it does not always work out well: e.g. underflow can be tricky if you want to ensure that an exact subnormal result does not raise it (e.g. powf(2, -140)), but inexact does.