From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/616 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: libm Date: Mon, 5 Mar 2012 10:25:25 -0500 Message-ID: <20120305152525.GX184@brightrain.aerifal.cx> References: <20120123170715.GA197@brightrain.aerifal.cx> <20120227210253.GA25004@port70.net> <20120227222437.GH184@brightrain.aerifal.cx> <20120303225758.GA5728@port70.net> <20120304065340.GT184@brightrain.aerifal.cx> <20120304145041.GB5728@port70.net> <20120304184339.GV184@brightrain.aerifal.cx> <20120305085135.GC5728@port70.net> <20120305140459.GW184@brightrain.aerifal.cx> <20120305151710.GG5728@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1330961163 23098 80.91.229.3 (5 Mar 2012 15:26:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Mar 2012 15:26:03 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-617-gllmg-musl=m.gmane.org@lists.openwall.com Mon Mar 05 16:26:02 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1S4ZnW-0001SD-3W for gllmg-musl@plane.gmane.org; Mon, 05 Mar 2012 16:26:02 +0100 Original-Received: (qmail 12178 invoked by uid 550); 5 Mar 2012 15:25:58 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 12170 invoked from network); 5 Mar 2012 15:25:58 -0000 Content-Disposition: inline In-Reply-To: <20120305151710.GG5728@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:616 Archived-At: On Mon, Mar 05, 2012 at 04:17:11PM +0100, Szabolcs Nagy wrote: > * Rich Felker [2012-03-05 09:04:59 -0500]: > > On Mon, Mar 05, 2012 at 09:51:35AM +0100, Szabolcs Nagy wrote: > > Hm? If you need a macro to test whether an argument is an integer or > > floating point, try this: > > > > #define __IS_FP(x) !!((1?1:(x))/2) > > oh nice > (and subtle) Note that it avoids evaluating x too, so it's safe in macros that need to avoid evaluating the argument more than once. > > adopted it. In any case I see no good way to define them without > > compound literals except the function calls.. > > > > btw while testing these macros i noticed that when > multiple classification macros are used fpclassify > gets called many times > (with the previous solution) > > the extra calls could be optimized by adding > __attribute__((const)) to fpclassify > (resulted less calls, smaller code size etc) Indeed. I was wrongly thinking they'd need __attribute__((__pure__)) rather than const, which is trickier because it's only available in newish gcc. But const has been around since before 2.95 even, so just #ifdef __GNUC__ is a sufficient check for using it. Alternatively I might just move the definitions of fpclassify (at least for non-LD types) back into math.h as static inline. This would let gcc optimize it down a lot more. Rich