From owner-freebsd-threads@FreeBSD.ORG Sun Mar 14 01:03:05 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F35916A4CE for ; Sun, 14 Mar 2004 01:03:05 -0800 (PST) Received: from smtp01.syd.iprimus.net.au (smtp01.syd.iprimus.net.au [210.50.30.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D00A43D31 for ; Sun, 14 Mar 2004 01:03:04 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from robbins.dropbear.id.au (210.50.81.10) by smtp01.syd.iprimus.net.au (7.0.024) id 402BA92700A298BC; Sun, 14 Mar 2004 20:03:02 +1100 Received: by robbins.dropbear.id.au (Postfix, from userid 1000) id AA3EB41C0; Sun, 14 Mar 2004 20:03:24 +1100 (EST) Date: Sun, 14 Mar 2004 20:03:24 +1100 From: Tim Robbins To: Daniel Eischen Message-ID: <20040314090324.GA23093@cat.robbins.dropbear.id.au> References: <20040314010805.GA21447@cat.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i cc: threads@freebsd.org Subject: Re: RFC: getc() and putc() as macros X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2004 09:03:05 -0000 On Sun, Mar 14, 2004 at 12:53:55AM -0500, Daniel Eischen wrote: > On Sun, 14 Mar 2004, Tim Robbins wrote: > > > On Sat, Mar 13, 2004 at 10:05:14AM -0500, Daniel Eischen wrote: > > > > > On Sat, 13 Mar 2004, Tim Robbins wrote: > > > > > > > The patch below re-adds macro versions of getc(), getchar(), putc(), > > > > putchar(), feof(), ferror(), fileno() and clearerr(), using the value of > > > > __isthreaded to decide between the fast inline single-threaded code and > > > > the more general function equivalent (as suggested by Alfred). Is this > > > > approach safe? > > > > > > I don't really like this. It exposes __isthreaded and others > > > that are implementation. > > > > Can you think of a better way? > > I think it was I that got rid of the macros for getc() et al. > I did it when libc_r was divorced from libc, and the macro > _THREAD_SAFE was no longer necessary. > > Solaris uses _REENTRANT to toggle between macros and functions. > For the macro versions, it accesses the FILE directly instead > of making a function call. > > I think the _unlocked versions of the functions are there for > a reason. If an application isn't going to be threaded, then > it can always use the unlocked versions... Perhaps they could in theory, but in practice, single threaded applications don't use the _unlocked functions. They haven't needed to, since most serious operating systems except FreeBSD 5 provide getc() and putc() macros. (I wish we put as much effort into optimizing stdio as we have put into implementing a micro-optimized thread system like SA...) Tim