Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jan 2003 17:36:42 -0500 (EST)
From:      Daniel Eischen <eischen@pcnet1.pcnet.com>
To:        Ben Mesander <ben@timing.com>
Cc:        Warner Losh <imp@harmony.village.org>, freebsd-arch@FreeBSD.ORG
Subject:   Re: _REENTRANT in math.h & libm oddities. 
Message-ID:  <Pine.GSO.4.10.10301231731250.25074-100000@pcnet1.pcnet.com>
In-Reply-To: <15920.25508.766136.494182@piglet.timing.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 23 Jan 2003, Ben Mesander wrote:

> Warner Losh writes:
>  > In message <Pine.GSO.4.10.10301231601440.12720-100000@pcnet1.pcnet.com> Daniel Eischen writes:
>  > : 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.
>  > 
>  > Then FreeBSD's source tree is basically wrong, since it uses
>  > _THREAD_SAFE for this in many places.  But most of them appear to be
>  > just defining the macro for compiles and such.  There's a little bit
>  > in libc's stdio still, but that's the only significant place that uses
>  > it in the tree.  I'm not sure about out-of-tree software.
> 
> Lots of things for various UNIX flavors seem to use _REENTRANT (see
> contrib & ports for examples).
> 
> But even so, I disagree that the _r function definitions should only
> appear in math.h if _REENTRANT is defined. That is, I disagree unless
> the POSIX specification says otherwise; I've been surprised by it
> before. I was unaware that POSIX mentioned _REENTRANT.
> 
> You can call _r functions even if you are not a threaded application.

Compiling with -D_REENTRANT doesn't mean you have to be a
threaded program, nor automatically linked to the threads
library :-)

> Other _r functions in libc, etc. can be called even if you are not
> threaded; I don't see why the gamma functions in the math library would 
> be different.

Here's an excerpt from Solaris 9 <math.h>:

  #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
  ...

  /*
   * Reentrant version of gamma & lgamma; passes signgam back by reference
   * as the second argument; user must allocate space for signgam.
   */
  #ifdef _REENTRANT
  extern double gamma_r __P((double, int *));
  extern double lgamma_r __P((double, int *));
  
  #if defined(__MATHERR_ERRNO_DONTCARE)
  #pragma does_not_read_global_data(gamma_r, lgamma_r)
  #endif
  #endif

  ...

  #endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

-- 
Dan Eischen


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10301231731250.25074-100000>