Subject: Re: pthreads plan
To: Greg Hudson <ghudson@MIT.EDU>
From: Todd Vierling <>
List: tech-userlevel
Date: 11/06/1999 19:21:16
On Sat, 6 Nov 1999, Greg Hudson wrote:

: > Support questions or not, just tell people "set _REENTRANT... the
: > pthread man pages tell you to do so."
: And if they want to use a third-party library like Motif, tell them
: they're screwed?

Thread safety is much more than compiling the libraries you use with
_REENTRANT.  MT-safe code requires a knowledge of function reentrancy, and
implementation of same, to work correctly.

With that said, third party libraries known to be MT-safe should be using
_REENTRANT already - and that includes packages (Hello Al & Hubert!).  ;)
Libraries compiled _REENTRANT don't have to be linked against _REENTRANT
programs - it's kind of like a "compatible step up" in the compilation.

: If you're asking for the value of errno, you probably aren't in a
: performance-critical situation.  getc and putc are much more worth
: worrying about.

Yes, true.  Which means that these could easily be the following, assuming 
my assertion about _REENTRANT and libraries above:

#define getc_unlocked(a) current_definition_of_getc
#define putc_unlocked(a) current_definition_of_getc
 * (note that getc_unlocked and putc_unlocked are already defined to be this
 * in POSIX...)
#define getc(a) fgetc(a)
#define putc(a,b) fputc(a,b)
/* and fgetc/fputc would do proper locking in the function... */
#define getc(a) getc_unlocked(a)
#define putc(a,b) putc_unlocked(a,b)

-- Todd Vierling (