Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-12-08 23:23:22 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-12-08 23:23:22 +0300
commit91a8eacec6575a3a2c6aa4c4cf26961870f6074a (patch)
treef5eddf39c5d7e22f148092859eeef55f141ae332 /newlib
parent414e7948118bb3b7071e7c8cbddcf371e0d48e38 (diff)
Add missing checks for __SNLK flag
* libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls dependent on __SNLK flag. * libc/stdio/findfp.c (__fp_lock): Ditto. (__fp_unlock): Ditto. * libc/stdio/freopen.c (_freopen_r): Ditto. * libc/stdio64/freopen64.c (_freopen64_r): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog9
-rw-r--r--newlib/libc/stdio/fclose.c9
-rw-r--r--newlib/libc/stdio/findfp.c6
-rw-r--r--newlib/libc/stdio/freopen.c15
-rw-r--r--newlib/libc/stdio64/freopen64.c15
5 files changed, 39 insertions, 15 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index c49f109c8..de5c84b21 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,5 +1,14 @@
2015-12-08 Corinna Vinschen <corinna@vinschen.de>
+ * libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls
+ dependent on __SNLK flag.
+ * libc/stdio/findfp.c (__fp_lock): Ditto.
+ (__fp_unlock): Ditto.
+ * libc/stdio/freopen.c (_freopen_r): Ditto.
+ * libc/stdio64/freopen64.c (_freopen64_r): Ditto.
+
+2015-12-08 Corinna Vinschen <corinna@vinschen.de>
+
* libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4.
* libc/stdio64/freopen64.c (_freopen64_r): Add missing resetting of
flag values and _mbstate.
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index cd271c490..0ce112306 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -82,11 +82,13 @@ _DEFUN(_fclose_r, (rptr, fp),
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
- _flockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _flockfile (fp);
if (fp->_flags == 0) /* not open! */
{
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -111,7 +113,8 @@ _DEFUN(_fclose_r, (rptr, fp),
FREELB (rptr, fp);
__sfp_lock_acquire ();
fp->_flags = 0; /* release this FILE for reuse */
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 27408f548..975a855c2 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -293,7 +293,8 @@ static int
_DEFUN(__fp_lock, (ptr),
FILE * ptr)
{
- _flockfile (ptr);
+ if (!(ptr->_flags2 & __SNLK))
+ _flockfile (ptr);
return 0;
}
@@ -303,7 +304,8 @@ static int
_DEFUN(__fp_unlock, (ptr),
FILE * ptr)
{
- _funlockfile (ptr);
+ if (!(ptr->_flags2 & __SNLK))
+ _funlockfile (ptr);
return 0;
}
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index 235ffba53..fb1f6c4db 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -95,7 +95,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
register FILE *__restrict fp)
{
register int f;
- int flags, oflags;
+ int flags, oflags, oflags2;
int e = 0;
CHECK_INIT (ptr, fp);
@@ -106,11 +106,14 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
- _flockfile (fp);
+ oflags2 = fp->_flags2;
+ if (!(oflags2 & __SNLK))
+ _flockfile (fp);
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -217,7 +220,8 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
__sfp_lock_acquire ();
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
@@ -241,7 +245,8 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
fp->_flags |= __SCLE;
#endif
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c
index a183fb8ea..8a069d53e 100644
--- a/newlib/libc/stdio64/freopen64.c
+++ b/newlib/libc/stdio64/freopen64.c
@@ -94,7 +94,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
register FILE *fp)
{
register int f;
- int flags, oflags;
+ int flags, oflags, oflags2;
int e = 0;
@@ -106,11 +106,14 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
- _flockfile (fp);
+ oflags2 = fp->_flags2;
+ if (!(oflags2 & __SNLK))
+ _flockfile (fp);
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -217,7 +220,8 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
__sfp_lock_acquire ();
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
@@ -244,7 +248,8 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
fp->_flags |= __SL64;
- _funlockfile (fp);
+ if (!(oflags2 & __SNLK))
+ _funlockfile (fp);
#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif