Next: , Previous: , Up: Stdio   [Contents][Index]


4.34 getc_unlocked—non-thread-safe version of getc (macro)

Synopsis

#include <stdio.h>
int getc_unlocked(FILE *fp);

#include <stdio.h>
int _getc_unlocked_r(FILE *fp);

Description
getc_unlocked is a non-thread-safe version of getc declared in stdio.h. getc_unlocked may only safely be used within a scope protected by flockfile() (or ftrylockfile()) and funlockfile(). 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 to the flockfile() or ftrylockfile() functions. If threads are disabled, then getc_unlocked is equivalent to getc.

The _getc_unlocked_r function is simply the reentrant version of get_unlocked which passes an additional reentrancy structure pointer argument: ptr.


Returns
See getc.


Portability
POSIX 1003.1 requires getc_unlocked. getc_unlocked may be implemented as a macro, so arguments should not have side-effects.

Supporting OS subroutines required: close, fstat, isatty, lseek, read, sbrk, write.