From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4785 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf issues Date: Fri, 4 Apr 2014 20:54:13 +0200 Message-ID: <20140404185413.GH3034@port70.net> References: <20140404141515.GD3034@port70.net> <20140404150705.GN26358@brightrain.aerifal.cx> 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: ger.gmane.org 1396637672 22180 80.91.229.3 (4 Apr 2014 18:54:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Apr 2014 18:54:32 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4789-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 04 20:54:25 2014 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 1WW9Fx-0000Gc-5d for gllmg-musl@plane.gmane.org; Fri, 04 Apr 2014 20:54:25 +0200 Original-Received: (qmail 11886 invoked by uid 550); 4 Apr 2014 18:54:24 -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 11878 invoked from network); 4 Apr 2014 18:54:24 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4785 Archived-At: * Morten Welinder [2014-04-04 13:42:30 -0400]: > It looks like the LDBL_EPSILON version could be used in > > roundl.c > modfl.c > ceill.c > floorl.c > > in the definition of TOINT instead of enumerating choices for > LDBL_MANT_DIG. It's basically the same thing going on yes, that would be a bit nicer (although other long double formats won't be supported anytime soon) (note that in the future these implementations may need to change the current versions raise inexact flag if result!=input, but the next version of the floating-point extension standard for c will require suppressing inexact, which i dont know how to do with simple arithmetics efficiently without accessing the fenv..) > While I was looking for that, I noticed that this modfl fallback looks > problematic. Even if long double and double are the same thing > under the hood, I don't think you can cast pointers like that and > assume it works. It needs a temporary. > > #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 > long double modfl(long double x, long double *iptr) > { > return modf(x, (double *)iptr); > } yes, this is an aliasing violation, nice catch the original idea was to allow tail call opt for these wrappers, so they are a single branch instruction, we should fix it but i think we can rely on that the ptr representations are the same: long double modfl(long double x, long double *iptr) { union {long double *ld; double *d;} u = {iptr}; return modf(x, u.d); }