pwd_grp.c: unlocked functions [PATCH]

Shaun Jackman sjackman at
Fri Oct 7 21:25:21 UTC 2005

2005/10/7, Rob Landley <rob at>:
> So you're saying people might want to use the thread _unsafe_ versions with
> threads.  Ok, I'll bite.  The libc-internal locking in the normal versions
> (which should never call back into your code, nor should your code have
> access to the libc internal locks to take them out of order) might
> conceivably screw you up how?

Each putc call requires a mutex lock and unlock. If that's in an inner
loop, it could hamper performance. putc_unlocked allows you to move
the locking outside of the loop.

> P.S.  I rather dislike FILE *.  It's unnecessary complexity.  It all boils
> down to a syscall anyway, and throwing in an I/O reblocking layer on the
> assumption that pathological I/O patterns are the norm is a bit silly, and
> requires you to _introduce_ gratuitous flush() calls to avoid subtle bugs so
> it's not exactly transparent anyway, is it?

The syscall write(1, &c, 1) is far more heavyweight than putchar(c),
which boils down to *stdout->p++ = c.


More information about the busybox mailing list