How to determine which pthread, was: Re: last libc_rdependenciesleft on current

Marco van de Voort marcov at stack.nl
Wed Feb 11 07:11:09 PST 2004


> On Tue, Feb 10, 2004 at 11:36:25PM +0100, Marco van de Voort wrote:
> > 
> > 
> > lang/fpc-devel (and to a lesser degree lang/fpc) are not libc_r dependant
> > themselves, but generate libc_r programs when language threading is used.
> > 
> > I'll fix this in the coming weeks, but rather like to do this runtime. 
> > 
> > How can I detect (in a non C/libc program, iow without using headers or
> > libraries, so in the general FreeBSD environment), whether I should pass
> > -lc_r to the linker or -lc -lpthread ? 
> > (sysctl or uname based solutions come to mind)
> 
> Look at how bsd.port.mk decides.

.if ${OSVERSION} < 500016
PTHREAD_CFLAGS?=        -D_THREAD_SAFE
PTHREAD_LIBS?=          -pthread
.elif ${OSVERSION} < 502102
PTHREAD_CFLAGS?=        -D_THREAD_SAFE
PTHREAD_LIBS?=          -lc_r
.else
PTHREAD_CFLAGS?=
PTHREAD_LIBS?=          -lpthread
.endif

Thnx, this is doable.

What does the -D_THREAD_SAFE mean? (I mean does it mean that libc isn't
thread safe, that it is thread_safe etc etc, or does it interact with the
C code that is being compiled (the port))


More information about the freebsd-ports mailing list