summaryrefslogtreecommitdiffstats
path: root/libc/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/_stdio.c33
-rw-r--r--libc/stdio/_stdio.h8
-rw-r--r--libc/stdio/fflush.c4
3 files changed, 29 insertions, 16 deletions
diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c
index 6084abec9..e8206889e 100644
--- a/libc/stdio/_stdio.c
+++ b/libc/stdio/_stdio.c
@@ -7,7 +7,11 @@
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
+#if defined (__UCLIBC_HAS_THREADS__) && defined (__USE_STDIO_FUTEXES__)
+#include <bits/stdio-lock.h>
+#endif
+
+libc_hidden_proto(memcpy)
libc_hidden_proto(isatty)
/* This is pretty much straight from uClibc, but with one important
@@ -160,18 +164,21 @@ FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
# ifdef __USE_STDIO_FUTEXES__
-# define __UCLIBC_IO_MUTEX_INITIALIZER _IO_lock_initializer
+_IO_lock_t _stdio_openlist_add_lock = _IO_lock_initializer;
# else
-# define __UCLIBC_IO_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+__UCLIBC_MUTEX_INIT(_stdio_openlist_add_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+# endif
+#ifdef __STDIO_BUFFERS
+# ifdef __USE_STDIO_FUTEXES__
+_IO_lock_t _stdio_openlist_del_lock = _IO_lock_initializer;
+# else
+__UCLIBC_MUTEX_INIT(_stdio_openlist_del_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
# endif
-
-__UCLIBC_IO_MUTEX_INIT(_stdio_openlist_add_lock, __UCLIBC_IO_MUTEX_INITIALIZER);
-# ifdef __STDIO_BUFFERS
-__UCLIBC_IO_MUTEX_INIT(_stdio_openlist_del_lock, __UCLIBC_IO_MUTEX_INITIALIZER);
volatile int _stdio_openlist_use_count = 0;
int _stdio_openlist_del_count = 0;
-# endif
+#endif
# endif
+
#endif
/**********************************************************************/
#ifdef __UCLIBC_HAS_THREADS__
@@ -179,6 +186,7 @@ int _stdio_openlist_del_count = 0;
/* 2 if threading not initialized and 0 otherwise; */
int _stdio_user_locking = 2;
+#ifndef __USE_STDIO_FUTEXES__
void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
{
const __UCLIBC_MUTEX_STATIC(__stdio_mutex_initializer,
@@ -186,6 +194,7 @@ void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer));
}
+#endif
#endif
/**********************************************************************/
@@ -204,7 +213,7 @@ void attribute_hidden _stdio_term(void)
STDIO_INIT_MUTEX(_stdio_openlist_add_lock);
#warning check
#ifdef __STDIO_BUFFERS
- STDIO_INIT_MUTEX(_stdio_openlist_del_lock);
+ STDIO_INIT_MUTEX(ptr->__lock); /* Shouldn't be necessary, but... */
#endif
/* Next we need to worry about the streams themselves. If a stream
@@ -226,7 +235,11 @@ void attribute_hidden _stdio_term(void)
}
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
- STDIO_INIT_MUTEX(ptr->__lock); /* Shouldn't be necessary, but... */
+#ifdef __USE_STDIO_FUTEXES__
+ _IO_lock_init (ptr->_lock);
+#else
+ __stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
+#endif
}
#endif
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index e8ef08983..27075a8ac 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -24,18 +24,18 @@
#include <bits/uClibc_mutex.h>
#define __STDIO_THREADLOCK_OPENLIST_ADD \
- __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_add_lock)
+ __UCLIBC_MUTEX_LOCK(_stdio_openlist_add_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_ADD \
- __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_add_lock)
+ __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_add_lock)
#ifdef __STDIO_BUFFERS
#define __STDIO_THREADLOCK_OPENLIST_DEL \
- __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_del_lock)
+ __UCLIBC_MUTEX_LOCK(_stdio_openlist_del_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_DEL \
- __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_del_lock)
+ __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_del_lock)
#ifdef __UCLIBC_HAS_THREADS__
diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c
index 11b837dde..e1527b3a3 100644
--- a/libc/stdio/fflush.c
+++ b/libc/stdio/fflush.c
@@ -19,11 +19,11 @@ libc_hidden_proto(fflush_unlocked)
* when all (lbf) writing streams are flushed. */
#define __MY_STDIO_THREADLOCK(__stream) \
- __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#define __MY_STDIO_THREADUNLOCK(__stream) \
- __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS)