summaryrefslogtreecommitdiff
path: root/libc/stdio/_stdio.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-12-06 22:41:21 +0000
committerEric Andersen <andersen@codepoet.org>2006-12-06 22:41:21 +0000
commit99d6c367c4820a072dc4ada51561df17e2093778 (patch)
tree969945da0bce7248de98eefedaeb590f5cfdd85e /libc/stdio/_stdio.h
parentaeba32a371882d602f6863320880f0c69c824b77 (diff)
stdio update from mjn3
Diffstat (limited to 'libc/stdio/_stdio.h')
-rw-r--r--libc/stdio/_stdio.h74
1 files changed, 65 insertions, 9 deletions
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 348f5ec5d..6647a6f0e 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -23,20 +23,76 @@
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
-#define __STDIO_THREADLOCK_OPENLIST \
- __pthread_mutex_lock(&_stdio_openlist_lock)
+#define __STDIO_THREADLOCK_OPENLIST_ADD \
+ do { \
+ struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \
+ _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \
+ __pthread_mutex_unlock, \
+ &_stdio_openlist_add_lock); \
+ __pthread_mutex_lock(&_stdio_openlist_add_lock); \
-#define __STDIO_THREADUNLOCK_OPENLIST \
- __pthread_mutex_unlock(&_stdio_openlist_lock)
+#define __STDIO_THREADUNLOCK_OPENLIST_ADD \
+ _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1); \
+ } while (0)
-#define __STDIO_THREADTRYLOCK_OPENLIST \
- __pthread_mutex_trylock(&_stdio_openlist_lock)
-#else
+#ifdef __STDIO_BUFFERS
-#define __STDIO_THREADLOCK_OPENLIST ((void)0)
-#define __STDIO_THREADUNLOCK_OPENLIST ((void)0)
+#define __STDIO_THREADLOCK_OPENLIST_DEL \
+ do { \
+ struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \
+ _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \
+ __pthread_mutex_unlock, \
+ &_stdio_openlist_del_lock); \
+ __pthread_mutex_lock(&_stdio_openlist_del_lock); \
+
+#define __STDIO_THREADUNLOCK_OPENLIST_DEL \
+ _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1); \
+ } while (0)
+
+#define __STDIO_OPENLIST_INC_USE \
+do { \
+ __STDIO_THREADLOCK_OPENLIST_DEL; \
+ ++_stdio_openlist_use_count; \
+ __STDIO_THREADUNLOCK_OPENLIST_DEL; \
+} while (0)
+
+extern void _stdio_openlist_dec_use(void);
+
+#define __STDIO_OPENLIST_DEC_USE \
+ _stdio_openlist_dec_use()
+
+#define __STDIO_OPENLIST_INC_DEL_CNT \
+do { \
+ __STDIO_THREADLOCK_OPENLIST_DEL; \
+ ++_stdio_openlist_del_count; \
+ __STDIO_THREADUNLOCK_OPENLIST_DEL; \
+} while (0)
+
+#define __STDIO_OPENLIST_DEC_DEL_CNT \
+do { \
+ __STDIO_THREADLOCK_OPENLIST_DEL; \
+ --_stdio_openlist_del_count; \
+ __STDIO_THREADUNLOCK_OPENLIST_DEL; \
+} while (0)
+
+#endif
+
+#endif /* __UCLIBC_HAS_THREADS__ */
+
+#ifndef __STDIO_THREADLOCK_OPENLIST_ADD
+#define __STDIO_THREADLOCK_OPENLIST_ADD ((void)0)
+#define __STDIO_THREADUNLOCK_OPENLIST_ADD ((void)0)
+#endif
+#ifndef __STDIO_THREADLOCK_OPENLIST_DEL
+#define __STDIO_THREADLOCK_OPENLIST_DEL ((void)0)
+#define __STDIO_THREADUNLOCK_OPENLIST_DEL ((void)0)
+/* #define __STDIO_OPENLIST_USE_CNT() (0) */
+#define __STDIO_OPENLIST_INC_USE ((void)0)
+#define __STDIO_OPENLIST_DEC_USE ((void)0)
+#define __STDIO_OPENLIST_INC_DEL_CNT ((void)0)
+#define __STDIO_OPENLIST_DEC_DEL_CNT ((void)0)
#endif
#define __UNDEFINED_OR_NONPORTABLE ((void)0)