DCE for the HP e3000 (B3821-90002)

Programming with Kernel Threads
stdio Interfaces
Chapter 5
58
stdio Interfaces
Some of the stdio interfaces (such as getchar() and putchar()) are available as functions
within C/XL and as macros defined in stdio.h. The macro versions exist for performance
reasons. Calls to the library implementation of these interfaces is intercepted by the
thread wrapper functions, making them thread-safe; but the macros have not been made
thread-safe. Since the thread-safe wrapper implementations should be used by default,
the names of the macros have been changed by adding an _unlocked suffix (for example,
getchar_unlocked()). This allows programmers to invoke the _unlocked macros and not
pay the performance penalty of an extra function call and the cost of acquiring and
releasing a lock.
Some of the _unlocked interfaces are outlined in POSIX 1003.4a, Draft 5. To support the
use of the _unlocked interfaces, the functions flockfile() and funlockfile() are provided. These
functions can be used to explicitly lock and unlock a file object. Therefore, exclusive
access to a file for a series of _unlocked stdio calls is ensured, without having to lock and
unlock the file on every call.
The additional stdio interfaces in thdwrp.h are:
The functions flockfile() and funlockfile() are implemented as part of /usr/lib/libdce.a.
getc_unlocked getchar_unlocked
putc_unlocked putchar_unlocked