Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 1999 11:42:14 -0800
From:      "Kurt D. Zeilenga" <Kurt@OpenLDAP.Org>
To:        Jeremy Lea <reg@shale.csir.co.za>
Cc:        "Richard Seaman, Jr." <dick@tar.com>, freebsd-current@FreeBSD.ORG
Subject:   Re: Using LinuxThreads
Message-ID:  <3.0.5.32.19990121114214.00958c30@localhost>
In-Reply-To: <19990121181228.A98581@shale.csir.co.za>
References:  <19990119091151.F600@tar.com> <19990118182717.A15566@top.worldcontrol.com> <Pine.BSF.4.05.9901182203500.11971-100000@janus.syracuse.net> <19990119024539.A88383@top.worldcontrol.com> <19990119140613.B826@shale.csir.co.za> <19990119091151.F600@tar.com>

next in thread | previous in thread | raw e-mail | index | archive | help
At 06:12 PM 1/21/99 +0200, Jeremy Lea wrote:
>On Tue, Jan 19, 1999 at 09:11:51AM -0600, Richard Seaman, Jr. wrote:
>> Actually, the new version, in FreeBSD "ports" form, doesn't require 
>> -DLINUXTHREADS anymore, but it does require -I/usr/local/include to
>> pick up the right header, since it installs a pthread.h into 
>> /usr/local/include.  This conflicts with the pthread.h in /usr/include.

It doesn't conflict, it overrides the pthread.h in /usr/include iff the
port is installed AND the application is compiled with -I/usr/local/include.

Sounds a lot like how various other 'replacement' libraries are implemented.

>This is nagging at me.  Having two headers of the same name, but importantly
>different content is asking for touble.  There needs to be a way to ensure
>that only one or the other is picked up.  The best way I can think of is to
>only include the contents of the user thread pthread.h if _THREAD_SAFE is
>defined (to force people to use the right defines...) and the contents of
>kernel thread pthread.h if _REENTRANT (and not _THREAD_SAFE) is defined. 
>This has the added bonus of meaning that most linux apps wont have to be
>patched.

Of course, this would only work if the contents of the two pthread.h files
were merged.  I'm not sure this is a good idea.

If you did this, do NOT use -D_REENTRANT or -D_THREAD_SAFE as the conditional
to determine the content.  Use -DLINUXTHREADS or something.

>To many applications have configure scripts which might find
>/usr/local/lib/libpthread, but not /usr/local/include/pthread.h, or find
>/usr/lib/libc_r and find /usr/local/include/pthread.h.

Garbage in, garbage out.   If the configure script in handed ill defined
environment settings (CPPFLAGS, LDFLAGS) you get what you deserve!

><Thinking> Can gcc be made to define _THREAD_SAFE automatically if -pthread
>is given? And _REENTRANT if -kthread is given?

-pthread/-kthread, in my option, should be considerred linker options
(basically just a short hand for -lc_r -nostdlib)


BTW, why does FreeBSD use -D_THREAD_SAFE AND -D_REENTRANT (math.h)
while most other PThread (final) implementations use -D_REENTRANT?

Also, the cc(1) says to use -D_THREADSAFE not -D_THREAD_SAFE.

Personallly, I think -DREENTRANT should be used for include all prototypes
for reentrant functions not requiring thread support (like strtok_r) and
-D_THREAD_SAFE routines only implemented in -lc_r.  If possible, functions
should be implemented in both -lc and -lc_r such that 3rd party libraries
wouldn't have to create both a -lfoolib vs. -lfoolib_r versions (unless
their _r versions requires threading).

Kurt

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.19990121114214.00958c30>