From owner-freebsd-current@FreeBSD.ORG Mon May 28 12:30:28 2012 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B7BB106566B; Mon, 28 May 2012 12:30:28 +0000 (UTC) (envelope-from rhurlin@gwdg.de) Received: from fmailer.gwdg.de (fmailer.gwdg.de [134.76.11.16]) by mx1.freebsd.org (Postfix) with ESMTP id C03408FC16; Mon, 28 May 2012 12:30:27 +0000 (UTC) Received: from p508c743b.dip.t-dialin.net ([80.140.116.59] helo=krabat.raven.hur) by mailer.gwdg.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1SYz5d-0004Cd-NJ; Mon, 28 May 2012 14:30:25 +0200 Message-ID: <4FC36FE1.9080908@gwdg.de> Date: Mon, 28 May 2012 14:30:25 +0200 From: Rainer Hurling User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120503 Thunderbird/12.0.1 MIME-Version: 1.0 To: David Chisnall References: <4FC30090.4070003@gwdg.de> <4D8CF7D2-CBEE-438E-A9E7-9C47A8892622@FreeBSD.org> In-Reply-To: <4D8CF7D2-CBEE-438E-A9E7-9C47A8892622@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated: Id:rhurlin X-Spam-Level: - X-Virus-Scanned: (clean) by exiscan+sophie Cc: freebsd-current@FreeBSD.org Subject: Re: Use of C99 extra long double math functions after r236148 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2012 12:30:28 -0000 On 28.05.2012 10:41 (UTC+1), David Chisnall wrote: > On 28 May 2012, at 05:35, Rainer Hurling wrote: First I should note that I am by no means an expert in C / C++ or C99 standards. So my comments are only on a level of someone who is using FreeBSD for scientific purposes like GIS and math applications and who is the maintainer of some scientific ports (like math/saga). >> Yesterday r236148 (Allow inclusion of libc++ to work after including math.h) was comitted to head, many thanks. >> >> Does this mean, that extra long double functions like acoshl, expm1l or log1pl are now "really implemented"? As far as I understand, they had only been declared before? > > They are still not implemented. The header in libc++ provides wrappers around these functions for C++, but if they are not declared then the compiler throws an error. Now there is a linker error if they are used, but if they are not used then it works irrespective of whether you just include or do undefined things like include first. Ok, that's what I had supposed. Because the main difference between r236147 and r2136148 seems to be the define of _MATH_EXTRA_H_, the rest is more a type of binning? >> If this is right, are they usable on a recent CURRENT, built with gcc42 (system compiler), by ports which use gcc46 (not clang)? If not, are there any plans to implement these functions in the near future? > > I think they're one of the last bits of C99 / C11 that anyone actually cares about (C11 unicode support being another), so they'll probably get done at some point, but doing them correctly is nontrivial, except on platforms where double and long double are the same. Yes, I agree. These outstanding long double math functions (like log1pl) and better unicode support are really needed for some important third party projects like R or SAGA GIS. In the past I have read several times discussions about the correctness of long double functions on FreeBSD. Some drafts have been dismissed because of there inaccuracy in special cases. Also was discussed to get missing libm routines from NetBSD [1]. It appears as if we have to wait some more time ... >> The use of C99 extra long double functions would be of interest for example for programs like math/R, especially its upcoming releases. > > I would be very wary of anything that depends on long double. The C spec makes no constraints on the range of float, double, or long double, but by convention on most platforms float is an IEEE 754 32-bit floating point value and double is 64-bit. No such conventions apply to long doubles and I know of (widely deployed) platforms where they are 64 bits, 80 bits and 128 bits, respectively. I believe on PowerPC FreeBSD actually gets it wrong and uses 64 bits even though the platform ABI spec recommends using 128 bits. x86 uses 80-bit x87 values (although sizeof(long double) may be 16 because they have some padding bytes in memory). If your program is tolerant of a potential variation in precision between 64 bits and 128 bits, then it is probably tolerant of just using doubles. Yes, I think in most cases math/R is tolerant enough of just using doubles. But in the near future they plan to implement much more of the C99 stuff and their tolerance to offer workarounds for FreeBSD shrinks from release to release [2]. So these problems will increase :-( Many thanks for your fast und well explained answer, I really appreciate it. Rainer > David [1] http://lists.freebsd.org/pipermail/freebsd-standards/2011-February/002119.html [2] https://stat.ethz.ch/pipermail/r-devel/2012-May/064128.html And some more places I found interesting about C99 and FreeBSD [3] http://www.freebsd.org/projects/c99/index.html [4] http://wiki.freebsd.org/MissingMathStuff [5] http://marc.info/?l=freebsd-standards&m=123158761305427 [6] http://lists.freebsd.org/pipermail/freebsd-hackers/2009-March/028030.html [7] http://www.koders.com/c/fid164FD2F50C9AAA63119A641875824455B3AE6B55.aspx?s=log1pl.c [8] http://www.mail-archive.com/bug-gnulib@gnu.org/msg26571.html [9] http://leaf.dragonflybsd.org/mailarchive/commits/2011-12/msg00190.html