From 29ac6bd228d1c75dc4c19105fa149861bff04720 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Sun, 11 Feb 2001 22:06:43 +0000 Subject: libc MT-safety, part 2. Add a lock to FILE. flockfile and friends are now implemented (for the most part) in libc. flockfile_debug is implemented in libc_r; I suppose it's about time to kill it but will do it in a future commit. Fix a potential deadlock in _fwalk in a threaded environment. A file flag (__SIGN) was added to stdio.h that, when set, tells _fwalk to ignore it in its walk. This seemed to be needed in refill.c because each file needs to be locked when flushing. Add a stub for pthread_self in libc. This is needed by flockfile which is allowed by POSIX to be recursive. Make fgetpos() error return value (-1) match man page. Remove recursive calls to locked functions (stdio); I think I've got them all, but I may have missed a couple. A few K&R -> ANSI conversions along with removal of a few instances of "register". $Id$ -> $FreeBSD$ in libc/stdio/rget.c Not objected to: -arch, a few months ago --- lib/libc/stdio/ferror.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'lib/libc/stdio/ferror.c') diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c index 2311926b1bd2..c4424c6a9900 100644 --- a/lib/libc/stdio/ferror.c +++ b/lib/libc/stdio/ferror.c @@ -42,16 +42,24 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* LIBC_SCCS and not lint */ +#include "namespace.h" #include +#include "un-namespace.h" +#include "libc_private.h" /* - * A subroutine version of the macro ferror. + * ferror has traditionally been a macro in . That is no + * longer true because it needs to be thread-safe. + * + * #undef ferror */ -#undef ferror - int -ferror(fp) - FILE *fp; +ferror(FILE *fp) { - return (__sferror(fp)); + int ret; + + FLOCKFILE(fp); + ret = __sferror(fp); + FUNLOCKFILE(fp); + return (ret); } -- cgit v1.3