From owner-freebsd-threads@FreeBSD.ORG Sat Mar 13 21:53:57 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 3487616A4CE; Sat, 13 Mar 2004 21:53:57 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id C452F43D1D; Sat, 13 Mar 2004 21:53:56 -0800 (PST) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i2E5rtW7001969; Sun, 14 Mar 2004 00:53:55 -0500 (EST) Date: Sun, 14 Mar 2004 00:53:55 -0500 (EST) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Tim Robbins In-Reply-To: <20040314010805.GA21447@cat.robbins.dropbear.id.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 05:53:57 -0000 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... -- Dan Eischen