summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fread.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/fread.c')
-rw-r--r--lib/libc/stdio/fread.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index 22436ec..4f67fbf 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -35,11 +35,20 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
static char sccsid[] = "@(#)fread.c 8.2 (Berkeley) 12/11/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* LIBC_SCCS and not lint */
#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 +68,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 +89,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);
}
OpenPOWER on IntegriCloud