Loading...
stdio/getc.3 Libc-262.3.2 Libc-583
--- Libc/Libc-262.3.2/stdio/getc.3
+++ Libc/Libc-583/stdio/getc.3
@@ -34,15 +34,17 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)getc.3	8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/getc.3,v 1.11 2001/10/01 16:08:59 ru Exp $
+.\" $FreeBSD: src/lib/libc/stdio/getc.3,v 1.19 2004/03/17 12:37:28 tjr Exp $
 .\"
-.Dd June 4, 1993
+.Dd January 10, 2003
 .Dt GETC 3
 .Os
 .Sh NAME
 .Nm fgetc ,
 .Nm getc ,
+.Nm getc_unlocked ,
 .Nm getchar ,
+.Nm getchar_unlocked ,
 .Nm getw
 .Nd get next character or word from input stream
 .Sh LIBRARY
@@ -54,7 +56,11 @@
 .Ft int
 .Fn getc "FILE *stream"
 .Ft int
-.Fn getchar
+.Fn getc_unlocked "FILE *stream"
+.Ft int
+.Fn getchar "void"
+.Ft int
+.Fn getchar_unlocked "void"
 .Ft int
 .Fn getw "FILE *stream"
 .Sh DESCRIPTION
@@ -83,14 +89,35 @@
 .Fn getw
 function
 obtains the next
-.Em int
+.Vt int
 (if present)
 from the stream pointed at by
 .Fa stream .
+.Pp
+The
+.Fn getc_unlocked
+and
+.Fn getchar_unlocked
+functions are equivalent to
+.Fn getc
+and
+.Fn getchar
+respectively,
+except that the caller is responsible for locking the stream
+with
+.Xr flockfile 3
+before calling them.
+These functions may be used to avoid the overhead of locking the stream
+for each character, and to avoid input being dispersed among multiple
+threads reading from the same stream.
 .Sh RETURN VALUES
 If successful, these routines return the next requested object
 from the
 .Fa stream .
+Character values are returned as an
+.Vt "unsigned char"
+converted to an
+.Vt int .
 If the stream is at end-of-file or a read error occurs,
 the routines return
 .Dv EOF .
@@ -109,19 +136,27 @@
 .Xr clearerr 3 .
 .Sh SEE ALSO
 .Xr ferror 3 ,
+.Xr flockfile 3 ,
 .Xr fopen 3 ,
 .Xr fread 3 ,
+.Xr getwc 3 ,
 .Xr putc 3 ,
 .Xr ungetc 3
 .Sh STANDARDS
 The
 .Fn fgetc ,
-.Fn getc
+.Fn getc ,
 and
 .Fn getchar
 functions
 conform to
 .St -isoC .
+The
+.Fn getc_unlocked
+and
+.Fn getchar_unlocked
+functions conform to
+.St -p1003.1-2001 .
 .Sh BUGS
 Since
 .Dv EOF
@@ -132,7 +167,7 @@
 must be used to check for failure after calling
 .Fn getw .
 The size and byte order of an
-.Em int
+.Vt int
 varies from one machine to another, and
 .Fn getw
 is not recommended for portable applications.