2013-03-26 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/stdio/local.h (_STDIO_WITH_THREAD_CANCELLATION_SUPPORT): New define. * libc/stdio/fclose.c: Use _STDIO_WITH_THREAD_CANCELLATION_SUPPORT. * libc/stdio/freopen.c: Likewise. * libc/stdio64/freopen64.c: Likewise.
This commit is contained in:
		| @@ -1,3 +1,12 @@ | |||||||
|  | 2013-03-26  Sebastian Huber <sebastian.huber@embedded-brains.de> | ||||||
|  |  | ||||||
|  | 	* libc/stdio/local.h (_STDIO_WITH_THREAD_CANCELLATION_SUPPORT): | ||||||
|  | 	New define. | ||||||
|  | 	* libc/stdio/fclose.c: Use | ||||||
|  | 	_STDIO_WITH_THREAD_CANCELLATION_SUPPORT. | ||||||
|  | 	* libc/stdio/freopen.c: Likewise. | ||||||
|  | 	* libc/stdio64/freopen64.c: Likewise. | ||||||
|  |  | ||||||
| 2013-03-15  Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-03-15  Sebastian Huber <sebastian.huber@embedded-brains.de> | ||||||
|  |  | ||||||
| 	* newlib/libc/stdio/findfp.c (glue_with_file): New. | 	* newlib/libc/stdio/findfp.c (glue_with_file): New. | ||||||
|   | |||||||
| @@ -78,7 +78,7 @@ _DEFUN(_fclose_r, (rptr, fp), | |||||||
|  |  | ||||||
|   /* We can't use the _newlib_flockfile_XXX macros here due to the |   /* We can't use the _newlib_flockfile_XXX macros here due to the | ||||||
|      interlocked locking with the sfp_lock. */ |      interlocked locking with the sfp_lock. */ | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|   int __oldcancel; |   int __oldcancel; | ||||||
|   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); |   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); | ||||||
| #endif | #endif | ||||||
| @@ -87,7 +87,7 @@ _DEFUN(_fclose_r, (rptr, fp), | |||||||
|   if (fp->_flags == 0)		/* not open! */ |   if (fp->_flags == 0)		/* not open! */ | ||||||
|     { |     { | ||||||
|       _funlockfile (fp); |       _funlockfile (fp); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|       pthread_setcancelstate (__oldcancel, &__oldcancel); |       pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|       return (0); |       return (0); | ||||||
| @@ -112,7 +112,7 @@ _DEFUN(_fclose_r, (rptr, fp), | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   __sfp_lock_release (); |   __sfp_lock_release (); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|   pthread_setcancelstate (__oldcancel, &__oldcancel); |   pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -102,7 +102,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), | |||||||
|  |  | ||||||
|   /* We can't use the _newlib_flockfile_XXX macros here due to the |   /* We can't use the _newlib_flockfile_XXX macros here due to the | ||||||
|      interlocked locking with the sfp_lock. */ |      interlocked locking with the sfp_lock. */ | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|   int __oldcancel; |   int __oldcancel; | ||||||
|   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); |   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); | ||||||
| #endif | #endif | ||||||
| @@ -111,7 +111,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), | |||||||
|   if ((flags = __sflags (ptr, mode, &oflags)) == 0) |   if ((flags = __sflags (ptr, mode, &oflags)) == 0) | ||||||
|     { |     { | ||||||
|       _funlockfile (fp); |       _funlockfile (fp); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|       pthread_setcancelstate (__oldcancel, &__oldcancel); |       pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|       _fclose_r (ptr, fp); |       _fclose_r (ptr, fp); | ||||||
| @@ -222,7 +222,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), | |||||||
|       __lock_close_recursive (fp->_lock); |       __lock_close_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|       __sfp_lock_release (); |       __sfp_lock_release (); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|       pthread_setcancelstate (__oldcancel, &__oldcancel); |       pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|       return NULL; |       return NULL; | ||||||
| @@ -242,7 +242,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   _funlockfile (fp); |   _funlockfile (fp); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|   pthread_setcancelstate (__oldcancel, &__oldcancel); |   pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|   return fp; |   return fp; | ||||||
|   | |||||||
| @@ -45,7 +45,12 @@ | |||||||
|    section before reaching the end of the critical section's code end, use |    section before reaching the end of the critical section's code end, use | ||||||
|    the appropriate _newlib_XXX_exit macro. */ |    the appropriate _newlib_XXX_exit macro. */ | ||||||
|  |  | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) \ | ||||||
|  |     && !defined (__rtems__) | ||||||
|  | #define _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
| #include <pthread.h> | #include <pthread.h> | ||||||
|  |  | ||||||
| /* Start a stream oriented critical section: */ | /* Start a stream oriented critical section: */ | ||||||
| @@ -84,7 +89,7 @@ | |||||||
| 	  pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \ | 	  pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| #else /* __SINGLE_THREAD__ || !_POSIX_THREADS */ | #else /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ | ||||||
|  |  | ||||||
| # define _newlib_flockfile_start(_fp) \ | # define _newlib_flockfile_start(_fp) \ | ||||||
| 	{ \ | 	{ \ | ||||||
| @@ -108,7 +113,7 @@ | |||||||
| 		__sfp_lock_release (); \ | 		__sfp_lock_release (); \ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| #endif /* !__SINGLE_THREAD__ && _POSIX_THREADS */ | #endif /* _STDIO_WITH_THREAD_CANCELLATION_SUPPORT */ | ||||||
|  |  | ||||||
| extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); | extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); | ||||||
| extern int    _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); | extern int    _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); | ||||||
|   | |||||||
| @@ -102,7 +102,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp), | |||||||
|  |  | ||||||
|   /* We can't use the _newlib_flockfile_XXX macros here due to the |   /* We can't use the _newlib_flockfile_XXX macros here due to the | ||||||
|      interlocked locking with the sfp_lock. */ |      interlocked locking with the sfp_lock. */ | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|   int __oldcancel; |   int __oldcancel; | ||||||
|   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); |   pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); | ||||||
| #endif | #endif | ||||||
| @@ -111,7 +111,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp), | |||||||
|   if ((flags = __sflags (ptr, mode, &oflags)) == 0) |   if ((flags = __sflags (ptr, mode, &oflags)) == 0) | ||||||
|     { |     { | ||||||
|       _funlockfile (fp); |       _funlockfile (fp); | ||||||
| #if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) | #ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT | ||||||
|       pthread_setcancelstate (__oldcancel, &__oldcancel); |       pthread_setcancelstate (__oldcancel, &__oldcancel); | ||||||
| #endif | #endif | ||||||
|       _fclose_r (ptr, fp); |       _fclose_r (ptr, fp); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user