Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
Guardian Native C Library Calls (g - i) getc_unlocked(3)
NAME
getc_unlocked - Gets a character from a specified input stream but does not lock the stream
LIBRARY
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdio.h>
int getc_unlocked(
FILE ∗∗stream);
PARAMETERS
stream Points to the file structure of an open file.
DESCRIPTION
The getc_unlocked() function returns the next chracter (byte) from the input specified by the
stream parameter and moves the file pointer, if defined, ahead one character (byte) in stream. The
getc_unlocked( ) function is functionally equivalent to the getc() function except that it does not
perform any internal locking of the stream.
The getc_unlocked() function should only be used by multi-threaded applications that have
already used the flockfile( ) or ftrylockfile() function to acquire a mutual exclusion lock for the
stream.
NOTES
The getc_unlocked() function might be a macro (depending on the compile-time definitions
used in the source). Consequently, you cannot use this interface where a function is necessary;
for example, a subroutine pointer cannot point to it. In addition, getc_unlocked() does not work
correctly with a stream parameter that has side effects. In particular, the following does not
work:
getc_unlocked(*f++)
When a function is necessary, use the fgetc() function instead.
RETURN VALUES
If successful, the getc_unlocked() function and macro returns the next character (byte) in the
specified input stream. If the stream is at end-of-file, the end-of-file indicator for the stream is set
and the integer constant EOF is returned. If this function or macro fails or a read error occurs, the
error indicator for the stream is set, the integer constant EOF is returned, and errno is set to indi-
cate the error.
ERRORS
If any of the following conditions occur, the getc-unlocked( ) function sets errno to the
corresponding value:
[EAGAIN] The O_NONBLOCK flag is set for the underlying input stream and the process
would be delayed by the read operation.
[EBADF] The file descriptor underlying the input stream is not a valid file descriptor or is
not open for reading.
527192-018 Hewlett-Packard Company 3−17