diff options
Diffstat (limited to 'lib/libc/stdio/fread.c')
-rw-r--r-- | lib/libc/stdio/fread.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c index 22436ec..7132e85 100644 --- a/lib/libc/stdio/fread.c +++ b/lib/libc/stdio/fread.c @@ -40,6 +40,11 @@ static char sccsid[] = "@(#)fread.c 8.2 (Berkeley) 12/11/93"; #include <stdio.h> #include <string.h> +#include "local.h" +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif size_t fread(buf, size, count, fp) @@ -59,6 +64,9 @@ fread(buf, size, count, fp) */ if ((resid = count * size) == 0) return (0); +#ifdef _THREAD_SAFE + _thread_flockfile(fp,__FILE__,__LINE__); +#endif if (fp->_r < 0) fp->_r = 0; total = resid; @@ -77,5 +85,8 @@ fread(buf, size, count, fp) (void)memcpy((void *)p, (void *)fp->_p, resid); fp->_r -= resid; fp->_p += resid; +#ifdef _THREAD_SAFE + _thread_funlockfile(fp); +#endif return (count); } |