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 2807 invoked from network); 12 Aug 2021 00:59:38 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 12 Aug 2021 00:59:38 -0000 Received: (qmail 21960 invoked by uid 550); 12 Aug 2021 00:59:36 -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 21934 invoked from network); 12 Aug 2021 00:59:36 -0000 Date: Wed, 11 Aug 2021 20:59:23 -0400 From: Rich Felker To: Stefan Kanthak Cc: Szabolcs Nagy , musl@lists.openwall.com Message-ID: <20210812005922.GD13220@brightrain.aerifal.cx> References: <0C6AAAD55DA44C6189B2FF4F5FB2C3E7@H270> <20210810213455.GB37904@port70.net> <5C60D05C95724A36B3DB9942D06CFE5F@H270> <20210811024010.GA13220@brightrain.aerifal.cx> <7143269BEC424DE6A3B0218C4268C4C8@H270> <20210811160938.GB13220@brightrain.aerifal.cx> <20210811175723.GC13220@brightrain.aerifal.cx> <20210811221610.GE37904@port70.net> <13F146D849AC41A6821080A0307B8796@H270> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13F146D849AC41A6821080A0307B8796@H270> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] Properly simplified nextafter() On Thu, Aug 12, 2021 at 12:43:36AM +0200, Stefan Kanthak wrote: > Szabolcs Nagy wrote: > > >* Rich Felker [2021-08-11 13:57:23 -0400]: > >> On Wed, Aug 11, 2021 at 06:50:28PM +0200, Stefan Kanthak wrote: > >> > Rich Felker wrote: > >> > > static __inline unsigned __FLOAT_BITS(float __f) > >> > > { > >> > > union {float __f; unsigned __i;} __u; > >> > > __u.__f = __f; > >> > > return __u.__i; > >> > > } > >> > > > >> > > #define isnan(x) ( \ > >> > > sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \ > >> > > sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \ > >> > > __fpclassifyl(x) == FP_NAN) > >> > > > >> > > So, nope. > >> > > >> > GCC typically uses its __builtin_isnan() for isnan(), which doesn't > >> > use integer instructions or reloads: > >> > >> That's only if you #define isnan(x) __builtin_isnan(x) > > > > even then it should use int arithmetics, see below > [...] > > it is also wrong: isnan must not signal for signaling nan. > > ARGH: I recommend to read the subject first, then the C standard and > recall how nextafter() is supposed to handle signalling NANs! > > I believe he was saying the implementation of isnan is wrong because isnan isn't allowed to do that. Not that the behavior conflicts with the contract for nextafter. Rich