summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common/bits/uClibc_stdio.h
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
commit62a21af8006ab04282fdc354c5b4dc765f56d058 (patch)
tree568761d58289238aa14cced3f0010809d4d28c00 /libc/sysdeps/linux/common/bits/uClibc_stdio.h
parentef250238dc1572caf859c2b64652f9cdfb0d9e42 (diff)
downloaduClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.bz2
uClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.xz
BIG BIG commit: all left files merged from trunk [rev 22714]. Currenntly NPTL sh4 port build and work fine. All committed to allow Khem Ray working on a working branch to integrate the ARM nptl port. MIPS nptl port not tested but should still building and working fine. There are some other part non yet merged with trunk (misc/internals and some headers file that need some more work). Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/sysdeps/linux/common/bits/uClibc_stdio.h')
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h111
1 files changed, 38 insertions, 73 deletions
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index a75f971eb..0af2d5db5 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -55,7 +55,7 @@
/**********************************************************************/
/* Make sure defines related to large files are consistent. */
-#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
+#ifdef _LIBC
#ifdef __UCLIBC_HAS_LFS__
#undef __USE_LARGEFILE
@@ -116,12 +116,7 @@
#endif
/**********************************************************************/
-#ifdef __UCLIBC_HAS_THREADS__
-/* Need this for pthread_mutex_t. */
-#include <bits/pthreadtypes.h>
-#ifdef __USE_STDIO_FUTEXES__
-#include <bits/stdio-lock.h>
-#endif
+#include <bits/uClibc_mutex.h>
/* user_locking
* 0 : do auto locking/unlocking
@@ -135,70 +130,45 @@
* This way, we avoid calling the weak lock/unlock functions.
*/
-#define __STDIO_AUTO_THREADLOCK_VAR int __infunc_user_locking
+#define __STDIO_AUTO_THREADLOCK_VAR \
+ __UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking)
-#ifdef __USE_STDIO_FUTEXES__
+#define __STDIO_AUTO_THREADLOCK(__stream) \
+ __UCLIBC_IO_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
+ (__stream)->__user_locking)
-#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
-
-#define __STDIO_AUTO_THREADLOCK(__stream) \
- if ((__infunc_user_locking = (__stream)->__user_locking) == 0) { \
- _IO_lock_lock((__stream)->_lock); \
- }
+#define __STDIO_AUTO_THREADUNLOCK(__stream) \
+ __UCLIBC_IO_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
-#define __STDIO_AUTO_THREADUNLOCK(__stream) \
- if (__infunc_user_locking == 0) { \
- _IO_lock_unlock((__stream)->_lock); \
- }
+#define __STDIO_ALWAYS_THREADLOCK(__stream) \
+ __UCLIBC_IO_MUTEX_LOCK((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADLOCK(__stream) \
- _IO_lock_lock((__stream)->_lock)
+#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
+ __UCLIBC_IO_MUTEX_UNLOCK((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) \
- _IO_lock_trylock((__stream)->_lock)
+#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
+ __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
- _IO_lock_unlock((__stream)->_lock)
-
-#else
+#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
+ __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
-#define __STDIO_AUTO_THREADLOCK(__stream) \
- if ((__infunc_user_locking = (__stream)->__user_locking) == 0) { \
- __pthread_mutex_lock(&(__stream)->__lock); \
- }
-
-#define __STDIO_AUTO_THREADUNLOCK(__stream) \
- if (__infunc_user_locking == 0) { \
- __pthread_mutex_unlock(&(__stream)->__lock); \
- }
+#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
+ __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
+#ifdef __UCLIBC_HAS_THREADS__
#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
-
-#define __STDIO_ALWAYS_THREADLOCK(__stream) \
- __pthread_mutex_lock(&(__stream)->__lock)
-
-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) \
- __pthread_mutex_trylock(&(__stream)->__lock)
-
-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
- __pthread_mutex_unlock(&(__stream)->__lock)
-
-#endif
-
-#else /* __UCLIBC_HAS_THREADS__ */
-
-#define __STDIO_AUTO_THREADLOCK_VAR ((void)0)
-
-#define __STDIO_AUTO_THREADLOCK(__stream) ((void)0)
-#define __STDIO_AUTO_THREADUNLOCK(__stream) ((void)0)
-
+#else
#define __STDIO_SET_USER_LOCKING(__stream) ((void)0)
+#endif
-#define __STDIO_ALWAYS_THREADLOCK(__stream) ((void)0)
-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) (0) /* Always succeed. */
-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) ((void)0)
+#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __USE_STDIO_FUTEXES__
+#define STDIO_INIT_MUTEX(M) _IO_lock_init(M)
+#else
+#define STDIO_INIT_MUTEX(M) __stdio_init_mutex(& M)
+#endif
+#endif
-#endif /* __UCLIBC_HAS_THREADS__ */
/**********************************************************************/
#define __STDIO_IOFBF 0 /* Fully buffered. */
@@ -313,11 +283,7 @@ struct __STDIO_FILE_STRUCT {
#endif
#ifdef __UCLIBC_HAS_THREADS__
int __user_locking;
-#ifdef __USE_STDIO_FUTEXES__
- _IO_lock_t _lock;
-#else
- pthread_mutex_t __lock;
-#endif
+ __UCLIBC_IO_MUTEX(__lock);
#endif
/* Everything after this is unimplemented... and may be trashed. */
#if __STDIO_BUILTIN_BUF_SIZE > 0
@@ -393,16 +359,14 @@ extern void _stdio_term(void) attribute_hidden;
extern struct __STDIO_FILE_STRUCT *_stdio_openlist;
#ifdef __UCLIBC_HAS_THREADS__
-#ifdef __USE_STDIO_FUTEXES__
-extern _IO_lock_t _stdio_openlist_lock;
-#else
-extern pthread_mutex_t _stdio_openlist_lock;
+__UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_add_lock);
+#ifdef __STDIO_BUFFERS
+__UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_del_lock);
+extern volatile int _stdio_openlist_use_count; /* _stdio_openlist_del_lock */
+extern int _stdio_openlist_del_count; /* _stdio_openlist_del_lock */
#endif
-extern int _stdio_openlist_delflag;
extern int _stdio_user_locking;
-/* #ifdef _LIBC */
-extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden;
-/* #endif */
+extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
#endif
#endif
@@ -428,7 +392,8 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden;
extern int __fgetc_unlocked(FILE *__stream);
extern int __fputc_unlocked(int __c, FILE *__stream);
-/* First define the default definitions. They overriden below as necessary. */
+/* First define the default definitions.
+ They are overridden below as necessary. */
#define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
#define __FGETC(__stream) (fgetc)((__stream))
#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream))