RFC: getc() and putc() as macros

Daniel Eischen eischen at vigrid.com
Sat Mar 13 21:53:57 PST 2004


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



More information about the freebsd-threads mailing list