From owner-freebsd-current Fri Jan 22 09:42:09 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA12897 for freebsd-current-outgoing; Fri, 22 Jan 1999 09:42:09 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from ns.tar.com (ns.tar.com [204.95.187.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA12881 for ; Fri, 22 Jan 1999 09:42:07 -0800 (PST) (envelope-from dick@ns.tar.com) Received: (from dick@localhost) by ns.tar.com (8.9.2/8.9.1) id LAA23750; Fri, 22 Jan 1999 11:41:53 -0600 (CST) (envelope-from dick) Date: Fri, 22 Jan 1999 11:41:53 -0600 From: "Richard Seaman, Jr." To: "Kurt D. Zeilenga" Cc: freebsd-current@FreeBSD.ORG Subject: Re: -D_REENTRANT (Was: Using LinuxThreads) Message-ID: <19990122114153.H92540@tar.com> 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> <19990121181228.A98581@shale.csir.co.za> <3.0.5.32.19990121114214.00958c30@localhost> <19990121143940.D5495@tar.com> <36A7A395.29B3E8A7@OpenLDAP.Org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: <36A7A395.29B3E8A7@OpenLDAP.Org>; from Kurt D. Zeilenga on Thu, Jan 21, 1999 at 02:00:53PM -0800 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Jan 21, 1999 at 02:00:53PM -0800, Kurt D. Zeilenga wrote: > > For kernel threading you just use libc. Whether or not libc generates > > thread safe (re-entrant) calls depends on whether its also linked with > > a library that 1) sets __isthreaded to a non-zero value, 2) has a _spinlock() > > implementationm, and 3) implements the functions flockfile, funlockfile, etc. > > There are also a few macros in header files that require _THREAD_SAFE to > > be defined to be thread safe. > > > I was hoping to be able to produce one ldap library that could be safely > linked with or without threads. However, if I must define _THREAD_SAFE > to generate code to be linked with threads then I must produce two libraries > (-lfoolib compiled with -U_THREAD_SAFE and -lfoolib_r with -D_THREAD_SAFE). _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. -- Richard Seamman, Jr. email: dick@tar.com 5182 N. Maple Lane phone: 414-367-5450 Chenequa WI 53058 fax: 414-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message