From owner-freebsd-arch Thu Jan 23 13: 6:59 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 037AF37B407 for ; Thu, 23 Jan 2003 13:06:53 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5033343E4A for ; Thu, 23 Jan 2003 13:06:52 -0800 (PST) (envelope-from eischen@pcnet1.pcnet.com) Received: from localhost (eischen@localhost) by mail.pcnet.com (8.12.3/8.12.1) with ESMTP id h0NL6e9n014606; Thu, 23 Jan 2003 16:06:41 -0500 (EST) Date: Thu, 23 Jan 2003 16:06:40 -0500 (EST) From: Daniel Eischen To: "M. Warner Losh" Cc: ben@timing.com, freebsd-arch@FreeBSD.ORG Subject: Re: _REENTRANT in math.h & libm oddities. In-Reply-To: <20030123.101335.95024590.imp@bsdimp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 23 Jan 2003, M. Warner Losh wrote: > In message: <15920.6175.737639.566519@piglet.timing.com> > Ben Mesander writes: > : Recently while working on some threading issues I noticed an oddity > : in /usr/include/math.h : the definitions of two functions, gamma_r and > : lgamma_r, are protected with #ifdef _REENTRANT . I suspect this is a > : historical artifact, as the FreeBSD manpage for gcc indicates that > : -D_THREAD_SAFE is the proper way to indicate that you are compiling > : threaded code on FreeBSD. > > The #ifdef in math.h is way historical: > > 1.1 (jkh 19-Aug-94): #ifdef _REENTRANT > 1.12 (obrien 21-Mar-02): double gamma_r(double, int *); > 1.12 (obrien 21-Mar-02): double lgamma_r(double, int *); > 1.1 (jkh 19-Aug-94): #endif /* _REENTRANT */ > > Since Sun donated this stuff to BSD back in 1993, I suspect that it > comes from Solaris' -D_REENTRANT stuff that was/is done for threaded > programs. The gcc manpage is wrong. It should state _REENTRANT instead of _THREAD_SAFE. POSIX specifies that _REENTRANT be defined to get these functions. I know that we always provide implementations of most of these _r functions so it might not make sense to #ifdef them in the header files, but I don't know that always making them visible would be against the spec or cause namespace pollution. > I can see no harm in just removing the ifdef. However, a quick survey > of the header files shows that a number of the _r functions have ifdef > protection for namespace pollution. One of the standard's wonks will > have to tell us for sure which standard(s) these comply to. The > functions generally don't have an ifdef _THREAD_SAFE around them. > > : Also note that there are reentrant API's available for gammaf & > lgamma: : gammaf_r and lgammaf_r, but there are no prototypes for > these in : math.h. Additionally, there is no mention of the four > functions : gamma_r, lgamma_r, gammaf_r, and lgammaf_r on the > lgamma(3) man page. > > This is likely also an issue. > : Is it worthwhile to work up a patch to: > : - remove _REENTRANT from math.h (and replace with _THREAD_SAFE if > : people think that is appropriate) > > I'd remove it completely, unless the standard's wonks think some name > space pollution avoiding typedef is necessary. I'd tend to leave them in. We're not violating the spec by leaving them in, but may be by removing them. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message