diff options
Diffstat (limited to 'newlib/libc/stdio/local.h')
-rw-r--r-- | newlib/libc/stdio/local.h | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 24d21360e..434d3f85c 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -68,16 +68,19 @@ { \ int __oldfpcancel; \ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldfpcancel); \ - _flockfile (_fp) + if (!(_fp->_flags2 & __SNLK)) \ + _flockfile (_fp) /* Exit from a stream oriented critical section prematurely: */ # define _newlib_flockfile_exit(_fp) \ - _funlockfile (_fp); \ + if (!(_fp->_flags2 & __SNLK)) \ + _funlockfile (_fp); \ pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); /* End a stream oriented critical section: */ # define _newlib_flockfile_end(_fp) \ - _funlockfile (_fp); \ + if (!(_fp->_flags2 & __SNLK)) \ + _funlockfile (_fp); \ pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); \ } @@ -99,17 +102,20 @@ pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \ } -#else /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ +#elif !defined(__SINGLE_THREAD__) /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ # define _newlib_flockfile_start(_fp) \ { \ - _flockfile(_fp) + if (!(_fp->_flags2 & __SNLK)) \ + _flockfile (_fp) # define _newlib_flockfile_exit(_fp) \ - _funlockfile(_fp); \ + if (!(_fp->_flags2 & __SNLK)) \ + _funlockfile(_fp); \ # define _newlib_flockfile_end(_fp) \ - _funlockfile(_fp); \ + if (!(_fp->_flags2 & __SNLK)) \ + _funlockfile(_fp); \ } # define _newlib_sfp_lock_start() \ @@ -123,6 +129,15 @@ __sfp_lock_release (); \ } +#else /* __SINGLE_THREAD__ */ + +# define _newlib_flockfile_start(_fp) +# define _newlib_flockfile_exit(_fp) +# define _newlib_flockfile_end(_fp) +# define _newlib_sfp_lock_start() +# define _newlib_sfp_lock_exit() +# define _newlib_sfp_lock_end() + #endif /* _STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); |