summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-12-07 23:24:19 +0000
committerEric Andersen <andersen@codepoet.org>2006-12-07 23:24:19 +0000
commit275a4c4e6fd115a0eb4c7a15e9ac4a92414cd839 (patch)
treee0e9abc0c1a61a6c1c99601caa7c9363e8910637 /libc/stdio
parent1478c2de052374c6356db5513749a144c13791b1 (diff)
Major cleanup of internal mutex locking. Be more consistant in how we do
things, and avoid potential deadlocks caused when a thread holding a uClibc internal lock get canceled and terminates without releasing the lock. This change also provides a single place, bits/uClibc_mutex.h, for thread libraries to modify to change all instances of internal locking.
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/_stdio.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c
index c406792d7..739a061a6 100644
--- a/libc/stdio/_stdio.c
+++ b/libc/stdio/_stdio.c
@@ -154,9 +154,9 @@ FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */
FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
-pthread_mutex_t _stdio_openlist_add_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+__UCLIBC_MUTEX_INIT(_stdio_openlist_add_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#ifdef __STDIO_BUFFERS
-pthread_mutex_t _stdio_openlist_del_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+__UCLIBC_MUTEX_INIT(_stdio_openlist_del_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
volatile int _stdio_openlist_use_count = 0;
int _stdio_openlist_del_count = 0;
#endif
@@ -169,10 +169,10 @@ int _stdio_openlist_del_count = 0;
/* 2 if threading not initialized and 0 otherwise; */
int _stdio_user_locking = 2;
-void attribute_hidden __stdio_init_mutex(pthread_mutex_t *m)
+void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
{
- static const pthread_mutex_t __stdio_mutex_initializer
- = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+ const __UCLIBC_MUTEX_STATIC(__stdio_mutex_initializer,
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer));
}
@@ -190,7 +190,7 @@ void attribute_hidden _stdio_term(void)
/* First, make sure the open file list is unlocked. If it was
* locked, then I suppose there is a chance that a pointer in the
* chain might be corrupt due to a partial store.
- */
+ */
__stdio_init_mutex(&_stdio_openlist_add_lock);
#warning check
#ifdef __STDIO_BUFFERS
@@ -214,7 +214,7 @@ void attribute_hidden _stdio_term(void)
__STDIO_STREAM_DISABLE_PUTC(ptr);
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(ptr);
}
-
+
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
__stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
}