summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/fgets.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/fgets.c')
-rw-r--r--newlib/libc/stdio/fgets.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c
index 7f02e3fcb..21bfdd4c6 100644
--- a/newlib/libc/stdio/fgets.c
+++ b/newlib/libc/stdio/fgets.c
@@ -98,6 +98,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
CHECK_INIT(ptr, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
#ifdef __SCLE
if (fp->_flags & __SCLE)
@@ -113,10 +114,12 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
if (c == EOF && s == buf)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return NULL;
}
*s = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return buf;
}
#endif
@@ -135,6 +138,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
if (s == buf)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return 0;
}
break;
@@ -160,6 +164,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len);
s[len] = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return (buf);
}
fp->_r -= len;
@@ -170,6 +175,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
while ((n -= len) != 0);
*s = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return buf;
}