From owner-freebsd-current Fri Jan 22 10:47:01 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA21121 for freebsd-current-outgoing; Fri, 22 Jan 1999 10:47:01 -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 KAA21115 for ; Fri, 22 Jan 1999 10:46:59 -0800 (PST) (envelope-from Kurt@OpenLDAP.Org) Received: from OpenLDAP.Org (localhost [127.0.0.1]) by cantor.boolean.net (8.9.1/8.9.1) with ESMTP id SAA21910; Fri, 22 Jan 1999 18:52:47 GMT (envelope-from Kurt@OpenLDAP.Org) Message-ID: <36A8C6F3.5D611CA9@OpenLDAP.Org> Date: Fri, 22 Jan 1999 10:44:03 -0800 From: "Kurt D. Zeilenga" Organization: OpenLDAP X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en-GB,en-US,en,de-DE,de MIME-Version: 1.0 To: "Richard Seaman, Jr." CC: freebsd-current@FreeBSD.ORG Subject: Re: -D_REENTRANT (Was: Using LinuxThreads) References: <19990119024539.A88383@top.worldcontrol.com> <19990119140613.B826@shale.csir.co.za> <19990119091151.F600@tar.com> <19990121181228.A98581@shale.csir.co.za> <3.0.5.32.19990121114214.00958c30@localhost> <19990121143940.D5495@tar.com> <36A7A395.29B3E8A7@OpenLDAP.Org> <19990122114153.H92540@tar.com> <36A8BA23.8AE3B430@OpenLDAP.Org> <19990122121949.I92540@tar.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "Richard Seaman, Jr." wrote: > > On Fri, Jan 22, 1999 at 09:49:23AM -0800, Kurt D. Zeilenga wrote: > > "Richard Seaman, Jr." wrote: > > > _THREAD_SAFE is only used in stdio.h. Looking at what's there, it could > > > be rewritten to eliminate _THREAD_SAFE entirely, at a (very slight) > > > performance penalty. You'd have to check __isthreaded (could be done > > > once, instead of twice, as in the code now) each time you call one > > > of the functions defined within the _THREAD_SAFE switch. All > > > _THREAD_SAFE does is let you avoid checking __isthreaded when you're > > > not threaded. > > > > So, if I want to produce a library which can be safely used by both > > threaded and non-threaded applications I should NOT define -D_THREAD_SAFE > > such that __isthreaded is always checked by the library. > > I guess I was a little unclear. > > 1) I think you would have to rewrite a little bit of the header to > use the __isthreaded test on a couple of more functions. > > 2) If you always define -D_THREAD_SAFE, __isthreaded will be > checked whether you're threaded or not. I would think that most third party libraries (from Ports) do not compile with -D_THREAD_SAFE. As such, __isthreaded won't be checked and the library cannot be safely used in a threaded environment. > You could also just eliminate _THREAD_SAFE entirely by letting > __isthreaded get checked on each relevant call. I would much prefer this. Then third party libraries compiled without -D_THREAD_SAFE can be used in threaded environments (though they might require external synchronization). Kurt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message