NAME
getc_unlocked
getchar_unlocked
putc_unlocked
putchar_unlocked — stdio
with explicit client locking
SYNOPSIS
#include <stdio.h> int getc_unlocked(FILE *stream); int getchar_unlocked(void); int putc_unlocked(int c, FILE *stream); int putchar_unlocked(int c);
DESCRIPTION
Versions of the functions getc(3) , getchar(3) , putc(3) , and putchar(3) respectively named getc_unlocked() , getchar_unlocked() , putc_unlocked(3) , and putchar_unlocked(3) are provided which are functionally identical to the original versions with the exception that they are not required to be implemented in a thread-safe manner. They may only safely be used within a scope protected by flockfile(3) (or ftrylockfile(3) ) and funlockfile(3) . These functions may safely be used in a multi-threaded program if and only if they are called while the invoking thread owns the ( FILE * ) object, as is the case after a successful call of the flockfile(3) or ftrylockfile(3) functions.
RETURN VALUE
See getc(3) , getchar(3) , putc(3) , and putchar(3) .
ERRORS
No errors are defined.
EXAMPLES
None.
APPLICATION USAGE
Because they may be implemented as macros, getc_unlocked() and
putc_unlocked() may treat incorrectly a stream argument with side effects.
In particular, getc_unlocked (* f ++) and
putc_unlocked (* f ++) will not necessarily work as expected. Therefore, use
of these functions should be preceded by the appropriate "#undef
getc_unlocked" or "#undef putc_unlocked" statement in such
situations.
FUTURE DIRECTIONS
None.
SEE ALSO
getc(3) , getchar(3) , putc(3) , putchar(3) , <stdio.h> .
DERIVATION
Derived from the POSIX Threads Extension (1003.1c-1995)