Loading...
stdio/putc.3 Libc-262.3.2 Libc-583
--- Libc/Libc-262.3.2/stdio/putc.3
+++ Libc/Libc-583/stdio/putc.3
@@ -34,15 +34,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.15 2004/03/17 12:46:17 tjr 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 +52,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 +102,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 +154,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 +167,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.