From owner-cvs-all@FreeBSD.ORG Thu Aug 7 15:32:18 2008 Return-Path: Delivered-To: cvs-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6F32106564A; Thu, 7 Aug 2008 15:32:18 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 47C3A8FC1B; Thu, 7 Aug 2008 15:32:17 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.2/8.14.2) with ESMTP id m77FVqEF080971; Thu, 7 Aug 2008 11:31:52 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.2/8.14.2/Submit) id m77FVqRB080970; Thu, 7 Aug 2008 11:31:52 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Thu, 7 Aug 2008 11:31:52 -0400 From: David Schultz To: Gabor Kovesdan Message-ID: <20080807153152.GA80835@zim.MIT.EDU> Mail-Followup-To: Gabor Kovesdan , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG References: <200808071440.m77Ee0mA057169@repoman.freebsd.org> <489B0B86.5090307@kovesdan.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <489B0B86.5090307@kovesdan.org> Cc: cvs-src@FreeBSD.ORG, src-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/lib/msun/src s_cimag.c s_cimagf.c s_cimagl.c s_conj.c s_conjf.c s_conjl.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 15:32:18 -0000 On Thu, Aug 07, 2008, Gabor Kovesdan wrote: > David Schultz ha scritto: > >das 2008-08-07 14:39:56 UTC > > > > FreeBSD src repository > > > > Modified files: > > lib/msun/src s_cimag.c s_cimagf.c s_cimagl.c s_conj.c > > s_conjf.c s_conjl.c > > Log: > > SVN rev 181374 on 2008-08-07 14:39:56Z by das > > > > Use cpack() and the gcc extension __imag__ to implement cimag() and > > conj() instead of using expressions like z * I. The latter is bad for > > several reasons: > > > > 1. It is implemented using arithmetic, which is unnecessary, and can > > generate floating point exceptions, contrary to the requirements on > > these functions. > > > > 2. gcc implements complex multiplication using a formula that breaks > > down for infinities, e.g., it gives INFINITY * I == nan + inf I. > > > I've also checked that this part was a bit messy and incomplete and I've > thought of working on this, thus I'm happy to see that you are working > on improving the C99 complex.h support. My only concern is that, is it a > good idea to use GCC extensions in our libc? Isn't this a significant > limit of the portability? A lot of things are part of the standard library specifically because they can't be implemented in standard C. Some things, such as the complex data type and the tgmath.h header, can't be implemented without compiler extensions, period. As it happens, cimag() can be implemented in standard C, but it's uglier: double cimag(complex double z) { union { complex double cpx; double components[2]; } u; u.cpx = z; return (u.components[1]); } I can convert it if you want, but it seems moot at the moment because even icc supports the rather basic __real__ and __imag__ extensions, and any compiler that doesn't support gcc's way of doing things is going to need a lot more work than this.