Loading...
--- Libc/Libc-262/stdio/putc.3
+++ Libc/Libc-763.11/stdio/putc.3
@@ -13,10 +13,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
@@ -34,15 +30,17 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)putc.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/putc.3,v 1.8 2001/10/01 16:08:59 ru Exp $
+.\" $FreeBSD: src/lib/libc/stdio/putc.3,v 1.16 2007/01/09 00:28:07 imp Exp $
.\"
-.Dd June 4, 1993
+.Dd January 10, 2003
.Dt PUTC 3
.Os
.Sh NAME
.Nm fputc ,
.Nm putc ,
+.Nm putc_unlocked ,
.Nm putchar ,
+.Nm putchar_unlocked ,
.Nm putw
.Nd output a character or word to a stream
.Sh LIBRARY
@@ -50,13 +48,33 @@
.Sh SYNOPSIS
.In stdio.h
.Ft int
-.Fn fputc "int c" "FILE *stream"
+.Fo fputc
+.Fa "int c"
+.Fa "FILE *stream"
+.Fc
.Ft int
-.Fn putc "int c" "FILE *stream"
+.Fo putc
+.Fa "int c"
+.Fa "FILE *stream"
+.Fc
.Ft int
-.Fn putchar "int c"
+.Fo putc_unlocked
+.Fa "int c"
+.Fa "FILE *stream"
+.Fc
.Ft int
-.Fn putw "int w" "FILE *stream"
+.Fo putchar
+.Fa "int c"
+.Fc
+.Ft int
+.Fo putchar_unlocked
+.Fa "int c"
+.Fc
+.Ft int
+.Fo putw
+.Fa "int w"
+.Fa "FILE *stream"
+.Fc
.Sh DESCRIPTION
The
.Fn fputc
@@ -80,25 +98,44 @@
.Pp
The
.Fn putchar
-macro
+function
is identical to
.Fn putc
with an output stream of
-.Em stdout .
+.Dv stdout .
.Pp
The
.Fn putw
function
writes the specified
-.Em int
+.Vt int
to the named output
.Fa stream .
+.Pp
+The
+.Fn putc_unlocked
+and
+.Fn putchar_unlocked
+functions are equivalent to
+.Fn putc
+and
+.Fn putchar
+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 output being interspersed from multiple
+threads writing to the same stream.
.Sh RETURN VALUES
The functions,
.Fn fputc ,
-.Fn putc
+.Fn putc ,
+.Fn putchar ,
+.Fn putc_unlocked ,
and
-.Fn putchar
+.Fn putchar_unlocked
return the character written.
If an error occurs, the value
.Dv EOF
@@ -113,8 +150,10 @@
or if an attempt is made to write a read-only stream.
.Sh SEE ALSO
.Xr ferror 3 ,
+.Xr flockfile 3 ,
.Xr fopen 3 ,
.Xr getc 3 ,
+.Xr putwc 3 ,
.Xr stdio 3
.Sh STANDARDS
The functions
@@ -124,13 +163,19 @@
.Fn putchar ,
conform to
.St -isoC .
+The
+.Fn putc_unlocked
+and
+.Fn putchar_unlocked
+functions conform to
+.St -p1003.1-2001 .
A function
.Fn putw
function appeared in
.At v6 .
.Sh BUGS
The size and byte order of an
-.Em int
+.Vt int
varies from one machine to another, and
.Fn putw
is not recommended for portable applications.