diff options
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;  {  | 
