From owner-freebsd-arch Thu Jan 23 9:14:37 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 2B21537B401 for ; Thu, 23 Jan 2003 09:14:36 -0800 (PST) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 180E743E4A for ; Thu, 23 Jan 2003 09:14:35 -0800 (PST) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.6/8.12.3) with ESMTP id h0NHEQ1e001069; Thu, 23 Jan 2003 10:14:26 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 23 Jan 2003 10:13:35 -0700 (MST) Message-Id: <20030123.101335.95024590.imp@bsdimp.com> To: ben@timing.com Cc: freebsd-arch@FreeBSD.ORG Subject: Re: _REENTRANT in math.h & libm oddities. From: "M. Warner Losh" In-Reply-To: <15920.6175.737639.566519@piglet.timing.com> References: <15920.6175.737639.566519@piglet.timing.com> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 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. : I think the correct fix for this is to remove the #ifdef _REENTRANT : from math.h . But perhaps it is there for a reason I am not cognizant : of. If that is the case, wouldn't we be better served by using : _THREAD_SAFE in FreeBSD? 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. : - add prototypes for gammaf_r & lgammaf_r to math.h I'd add it as above. : - update the lgamma(3) man page to mention gamma_r, lgamma_r, gammaf_r, : and lgammaf_r Safe. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message