C
Chris Torek
Thanks, Richard, I've bookmarked that link. Not only does it have the
current version of putchar, it has the whole history of it ...
Well, it has the history of FreeBSD's version. (There are other
versions, some of whose history is largely unrelated.)
... It starts out, 14 years ago, looking like standard C to me ...
That was the one I wrote. Note, however, that the name __sputc
is reserved to the implementor (i.e., me).
Somewhere along the line, clc's Chris Torek became the "guy who writes
putchar for openbsd," ...
The only BSD version of putc I modified after the original releases
from Berkeley was the one in BSD/OS. None of the OpenBSD, NetBSD,
or FreeBSD changes are mine.
... does the same thing: it undefines putchar and worries about something
being f locked. I was mildly surprised not to see a test against EOF.
The "locking" is for POSIX threads. (We had to add the same thing to
BSD/OS, though the added code was a bit different.)
Since all the real work is done by the __sputc() macro and the
function it calls, the putchar() code itself always remains trivial.
The macro is defined elsewhere (originally, in <stdio.h>, but it
may have moved in some versions).