2 * Copyright (c) 1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * and/or other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 <<getc_unlocked>>---non-thread-safe version of getc (macro)
29 int getc_unlocked(FILE *<[fp]>);
32 int _getc_unlocked_r(FILE *<[fp]>);
35 <<getc_unlocked>> is a non-thread-safe version of <<getc>> declared in
36 <<stdio.h>>. <<getc_unlocked>> may only safely be used within a scope
37 protected by flockfile() (or ftrylockfile()) and funlockfile(). These
38 functions may safely be used in a multi-threaded program if and only
39 if they are called while the invoking thread owns the ( FILE *)
40 object, as is the case after a successful call to the flockfile() or
41 ftrylockfile() functions. If threads are disabled, then
42 <<getc_unlocked>> is equivalent to <<getc>>.
44 The <<_getc_unlocked_r>> function is simply the reentrant version of
45 <<get_unlocked>> which passes an additional reentrancy structure pointer
52 POSIX 1003.1 requires <<getc_unlocked>>. <<getc_unlocked>> may be
53 implemented as a macro, so arguments should not have side-effects.
55 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
56 <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
58 #if defined(LIBC_SCCS) && !defined(lint)
59 static char sccsid
[] = "%W% (Berkeley) %G%";
60 #endif /* LIBC_SCCS and not lint */
66 * A subroutine version of the macro getc_unlocked.
72 _getc_unlocked_r (struct _reent
*ptr
,
75 /* CHECK_INIT is called (eventually) by __srefill_r. */
77 return __sgetc_r (ptr
, fp
);
83 getc_unlocked (register FILE *fp
)
85 return __sgetc_r (_REENT
, fp
);
88 #endif /* !_REENT_ONLY */