From owner-freebsd-current Thu Jan 21 11:45:00 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA17823 for freebsd-current-outgoing; Thu, 21 Jan 1999 11:45:00 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from cantor.boolean.net (cantor.boolean.net [209.133.111.73]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA17818 for ; Thu, 21 Jan 1999 11:44:58 -0800 (PST) (envelope-from Kurt@OpenLDAP.Org) Received: from gypsy (localhost [127.0.0.1]) by cantor.boolean.net (8.9.1/8.9.1) with SMTP id TAA04310; Thu, 21 Jan 1999 19:50:37 GMT (envelope-from Kurt@OpenLDAP.Org) Message-Id: <3.0.5.32.19990121114214.00958c30@localhost> X-Sender: guru@localhost X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32) Date: Thu, 21 Jan 1999 11:42:14 -0800 To: Jeremy Lea From: "Kurt D. Zeilenga" Subject: Re: Using LinuxThreads Cc: "Richard Seaman, Jr." , freebsd-current@FreeBSD.ORG In-Reply-To: <19990121181228.A98581@shale.csir.co.za> References: <19990119091151.F600@tar.com> <19990118182717.A15566@top.worldcontrol.com> <19990119024539.A88383@top.worldcontrol.com> <19990119140613.B826@shale.csir.co.za> <19990119091151.F600@tar.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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! > 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