diff options
| author | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
| commit | f70177e76e605ec6e6cd5b938fa77ade5d380e87 (patch) | |
| tree | a89c7f50ec371cef4418259b9dccdd31ebb2f61f /lib/libc/stdio/fflush.c | |
| parent | 61de51cad66df0d565233915f856932159d33a4a (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/fflush.c')
| -rw-r--r-- | lib/libc/stdio/fflush.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index 4a5cf0f43084..fce893292e60 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -41,21 +41,36 @@ static char sccsid[] = "@(#)fflush.c 8.1 (Berkeley) 6/4/93"; #include <errno.h> #include <stdio.h> #include "local.h" +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif /* Flush a single file, or (if fp is NULL) all files. */ +int fflush(fp) register FILE *fp; { + int retval; if (fp == NULL) return (_fwalk(__sflush)); +#ifdef _THREAD_SAFE + _thread_flockfile(fp,__FILE__,__LINE__); +#endif if ((fp->_flags & (__SWR | __SRW)) == 0) { errno = EBADF; - return (EOF); + retval = EOF; + } else { + retval = __sflush(fp); } - return (__sflush(fp)); +#ifdef _THREAD_SAFE + _thread_funlockfile(fp); +#endif + return (retval); } +int __sflush(fp) register FILE *fp; { |
