diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index 2b80ef724db1..6b86b4cda988 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -28,7 +28,10 @@ MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fgetws.3 flockfile.3 \ printf.3 putc.3 putwc.3 remove.3 scanf.3 setbuf.3 stdio.3 tmpnam.3 \ ungetc.3 ungetwc.3 wprintf.3 wscanf.3 -MLINKS+=ferror.3 clearerr.3 ferror.3 feof.3 ferror.3 fileno.3 +MLINKS+=ferror.3 ferror_unlocked.3 \ + ferror.3 clearerr.3 ferror.3 clearerr_unlocked.3 \ + ferror.3 feof.3 ferror.3 feof_unlocked.3 \ + ferror.3 fileno.3 ferror.3 fileno_unlocked.3 MLINKS+=fflush.3 fpurge.3 MLINKS+=fgets.3 gets.3 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3 diff --git a/lib/libc/stdio/ferror.3 b/lib/libc/stdio/ferror.3 index b9968f1786be..cb170a47e9f7 100644 --- a/lib/libc/stdio/ferror.3 +++ b/lib/libc/stdio/ferror.3 @@ -36,14 +36,18 @@ .\" @(#)ferror.3 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd April 19, 1994 +.Dd January 10, 2003 .Dt FERROR 3 .Os .Sh NAME .Nm clearerr , +.Nm clearerr_unlocked , .Nm feof , +.Nm feof_unlocked , .Nm ferror , -.Nm fileno +.Nm ferror_unlocked , +.Nm fileno , +.Nm fileno_unlocked .Nd check and reset stream status .Sh LIBRARY .Lb libc @@ -51,12 +55,20 @@ .In stdio.h .Ft void .Fn clearerr "FILE *stream" +.Ft void +.Fn clearerr_unlocked "FILE *stream" .Ft int .Fn feof "FILE *stream" .Ft int +.Fn feof_unlocked "FILE *stream" +.Ft int .Fn ferror "FILE *stream" .Ft int +.Fn ferror_unlocked "FILE *stream" +.Ft int .Fn fileno "FILE *stream" +.Ft int +.Fn fileno_unlocked "FILE *stream" .Sh DESCRIPTION The function .Fn clearerr @@ -86,6 +98,25 @@ The function examines the argument .Fa stream and returns its integer descriptor. +.Pp +The +.Fn clearerr_unlocked , +.Fn feof_unlocked , +.Fn ferror_unlocked , +and +.Fn fileno_unlocked +functions are equivalent to +.Fn clearerr , +.Fn feof , +.Fn ferror , +and +.Fn fileno +respectively, except that the caller is responsible for locking the stream +with +.Fn flockfile +before calling them. +These functions may be used to avoid the overhead of locking the stream +and to prevent races when multiple threads are operating on the same stream. .Sh ERRORS These functions should not fail and do not set the external variable @@ -93,6 +124,7 @@ variable .Sh SEE ALSO .Xr open 2 , .Xr fdopen 3 , +.Xr flockfile 3 , .Xr stdio 3 .Sh STANDARDS The functions