svn commit: branches/uClibc-nptl: libc/stdio libc/sysdeps/linux/common/bit etc...
carmelo at uclibc.org
carmelo at uclibc.org
Fri Jul 11 02:34:24 PDT 2008
Author: carmelo
Date: 2008-07-11 02:34:24 -0700 (Fri, 11 Jul 2008)
New Revision: 22774
Log:
Fix some __UCLIBC_IO_MUTEX_XXXX macro to be used without FUTEX support. Thanks Khem for pointing this out
Modified:
branches/uClibc-nptl/libc/stdio/_stdio.c
branches/uClibc-nptl/libc/stdio/_stdio.h
branches/uClibc-nptl/libc/stdio/fflush.c
branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_mutex.h
branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_stdio.h
branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
Changeset:
Modified: branches/uClibc-nptl/libc/stdio/_stdio.c
===================================================================
--- branches/uClibc-nptl/libc/stdio/_stdio.c 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libc/stdio/_stdio.c 2008-07-11 09:34:24 UTC (rev 22774)
@@ -7,11 +7,7 @@
#include "_stdio.h"
-#if defined (__UCLIBC_HAS_THREADS__) && defined (__USE_STDIO_FUTEXES__)
-#include <bits/stdio-lock.h>
-#endif
-
-libc_hidden_proto(memcpy)
+/* Experimentally off - libc_hidden_proto(memcpy) */
libc_hidden_proto(isatty)
/* This is pretty much straight from uClibc, but with one important
@@ -163,22 +159,13 @@
FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
-# ifdef __USE_STDIO_FUTEXES__
-_IO_lock_t _stdio_openlist_add_lock = _IO_lock_initializer;
-# else
-__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);
+# ifdef __STDIO_BUFFERS
+__UCLIBC_IO_MUTEX_INIT(_stdio_openlist_del_lock);
volatile int _stdio_openlist_use_count = 0;
int _stdio_openlist_del_count = 0;
-#endif
+# endif
# endif
-
#endif
/**********************************************************************/
#ifdef __UCLIBC_HAS_THREADS__
@@ -213,7 +200,7 @@
STDIO_INIT_MUTEX(_stdio_openlist_add_lock);
#warning check
#ifdef __STDIO_BUFFERS
- STDIO_INIT_MUTEX(ptr->__lock); /* Shouldn't be necessary, but... */
+ STDIO_INIT_MUTEX(_stdio_openlist_del_lock);
#endif
/* Next we need to worry about the streams themselves. If a stream
@@ -235,11 +222,7 @@
}
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
-#ifdef __USE_STDIO_FUTEXES__
- _IO_lock_init (ptr->_lock);
-#else
- __stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
-#endif
+ STDIO_INIT_MUTEX(ptr->__lock); /* Shouldn't be necessary, but... */
}
#endif
Modified: branches/uClibc-nptl/libc/stdio/_stdio.h
===================================================================
--- branches/uClibc-nptl/libc/stdio/_stdio.h 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libc/stdio/_stdio.h 2008-07-11 09:34:24 UTC (rev 22774)
@@ -24,18 +24,18 @@
#include <bits/uClibc_mutex.h>
#define __STDIO_THREADLOCK_OPENLIST_ADD \
- __UCLIBC_MUTEX_LOCK(_stdio_openlist_add_lock)
+ __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_add_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_ADD \
- __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_add_lock)
+ __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_add_lock)
#ifdef __STDIO_BUFFERS
#define __STDIO_THREADLOCK_OPENLIST_DEL \
- __UCLIBC_MUTEX_LOCK(_stdio_openlist_del_lock)
+ __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_del_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_DEL \
- __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_del_lock)
+ __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_del_lock)
#ifdef __UCLIBC_HAS_THREADS__
Modified: branches/uClibc-nptl/libc/stdio/fflush.c
===================================================================
--- branches/uClibc-nptl/libc/stdio/fflush.c 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libc/stdio/fflush.c 2008-07-11 09:34:24 UTC (rev 22774)
@@ -19,11 +19,11 @@
* when all (lbf) writing streams are flushed. */
#define __MY_STDIO_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#define __MY_STDIO_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS)
Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_mutex.h
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_mutex.h 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_mutex.h 2008-07-11 09:34:24 UTC (rev 22774)
@@ -14,6 +14,7 @@
#include <pthread.h>
#include <bits/uClibc_pthread.h>
+#include <bits/libc-lock.h>
#define __UCLIBC_MUTEX_TYPE pthread_mutex_t
@@ -62,8 +63,56 @@
#define __UCLIBC_MUTEX_UNLOCK(M) \
__UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
-#else
+#ifdef __USE_STDIO_FUTEXES__
+#include <bits/stdio-lock.h>
+
+#define __UCLIBC_IO_MUTEX(M) _IO_lock_t M
+#define __UCLIBC_IO_MUTEX_LOCK(M) _IO_lock_lock(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) _IO_lock_unlock(M)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) _IO_lock_trylock(M)
+#define __UCLIBC_IO_MUTEX_INIT(M) _IO_lock_t M = _IO_lock_initializer
+#define __UCLIBC_IO_MUTEX_EXTERN(M) extern _IO_lock_t M
+
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,C) \
+ if (C) { \
+ _IO_lock_lock(M); \
+ }
+
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,C) \
+ if (C) { \
+ _IO_lock_unlock(M); \
+ }
+
+#define __UCLIBC_IO_MUTEX_AUTO_LOCK(M,A,V) \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,((A=(V))) == 0)
+
+#define __UCLIBC_IO_MUTEX_AUTO_UNLOCK(M,A) \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,((A) == 0))
+
+#define __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(M) _IO_lock_lock(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(M) _IO_lock_unlock(M)
+
+#else /* of __USE_STDIO_FUTEXES__ */
+
+#define __UCLIBC_IO_MUTEX(M) __UCLIBC_MUTEX(M)
+#define __UCLIBC_IO_MUTEX_LOCK(M) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_INIT(M) __UCLIBC_MUTEX_INIT(M, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define __UCLIBC_IO_MUTEX_EXTERN(M) __UCLIBC_MUTEX_EXTERN(M)
+#define __UCLIBC_IO_MUTEX_AUTO_LOCK(M,A,V) __UCLIBC_MUTEX_AUTO_LOCK(M,A,V)
+#define __UCLIBC_IO_MUTEX_AUTO_UNLOCK(M,A) __UCLIBC_MUTEX_AUTO_UNLOCK(M,A)
+#define __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
+
+#endif /* of __USE_STDIO_FUTEXES__ */
+
+
+#else /* of __UCLIBC_HAS_THREADS__ */
+
#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_STATIC(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
@@ -83,6 +132,15 @@
#define __UCLIBC_MUTEX_LOCK(M) ((void)0)
#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0)
-#endif
+#define __UCLIBC_IO_MUTEX_LOCK(M) ((void)0)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) ((void)0)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) ((void)0)
+#define __UCLIBC_IO_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_IO_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#endif /* of __UCLIBC_HAS_THREADS__ */
+
+#define __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) \
+ __UCLIBC_IO_MUTEX_TRYLOCK(M)
+
#endif /* _UCLIBC_MUTEX_H */
Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_stdio.h
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2008-07-11 09:34:24 UTC (rev 22774)
@@ -117,9 +117,6 @@
/**********************************************************************/
#include <bits/uClibc_mutex.h>
-#ifdef __USE_STDIO_FUTEXES__
-#include <bits/stdio-lock.h>
-#endif
/* user_locking
* 0 : do auto locking/unlocking
@@ -135,76 +132,42 @@
#define __STDIO_AUTO_THREADLOCK_VAR \
__UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking)
-#ifdef __USE_STDIO_FUTEXES__
-#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) \
- if (__infunc_user_locking == 0) { \
- _IO_lock_unlock((__stream)->_lock); \
- }
-
-#define __STDIO_ALWAYS_THREADLOCK(__stream) \
- _IO_lock_lock((__stream)->_lock)
-
-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) \
- _IO_lock_trylock((__stream)->_lock)
-
-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
- _IO_lock_unlock((__stream)->_lock)
-
-#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
- _IO_lock_lock_cancel_unsafe((__stream)->__lock)
-
-#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
- _IO_lock_trylock_cancel_unsafe((__stream)->__lock)
-
-#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
- _IO_lock_unlock_cancel_unsafe((__stream)->__lock)
-
-#else /* __USE_STDIO_FUTEXES__ */
-
-
#define __STDIO_AUTO_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
+ __UCLIBC_IO_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
(__stream)->__user_locking)
#define __STDIO_AUTO_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
+ __UCLIBC_IO_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
#define __STDIO_ALWAYS_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_LOCK((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_LOCK((__stream)->__lock)
#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_UNLOCK((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_UNLOCK((__stream)->__lock)
#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
-#endif
-
#ifdef __UCLIBC_HAS_THREADS__
#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
#else
#define __STDIO_SET_USER_LOCKING(__stream) ((void)0)
#endif
+#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
/**********************************************************************/
@@ -320,12 +283,8 @@
#endif
#ifdef __UCLIBC_HAS_THREADS__
int __user_locking;
-#ifdef __USE_STDIO_FUTEXES__
- _IO_lock_t _lock;
-#else
- __UCLIBC_MUTEX(__lock);
+ __UCLIBC_IO_MUTEX(__lock);
#endif
-#endif
/* Everything after this is unimplemented... and may be trashed. */
#if __STDIO_BUILTIN_BUF_SIZE > 0
unsigned char __builtinbuf[__STDIO_BUILTIN_BUF_SIZE];
@@ -400,17 +359,9 @@
extern struct __STDIO_FILE_STRUCT *_stdio_openlist;
#ifdef __UCLIBC_HAS_THREADS__
-#ifdef __USE_STDIO_FUTEXES__
-extern _IO_lock_t _stdio_openlist_add_lock;
-#else
-__UCLIBC_MUTEX_EXTERN(_stdio_openlist_add_lock);
-#endif
+__UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_add_lock);
#ifdef __STDIO_BUFFERS
-#ifdef __USE_STDIO_FUTEXES__
-extern _IO_lock_t _stdio_openlist_del_lock;
-#else
-__UCLIBC_MUTEX_EXTERN(_stdio_openlist_del_lock);
-#endif
+__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
Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c 2008-07-11 08:23:52 UTC (rev 22773)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c 2008-07-11 09:34:24 UTC (rev 22774)
@@ -58,6 +58,7 @@
#endif
}
+extern __typeof(fork) __libc_fork;
pid_t __libc_fork (void)
{
pid_t pid;
@@ -119,11 +120,7 @@
break;
}
-#ifdef __USE_STDIO_FUTEXES__
- _IO_lock_lock (_stdio_openlist_add_lock);
-#else
- __pthread_mutex_lock(&_stdio_openlist_add_lock);
-#endif
+ __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(_stdio_openlist_add_lock);
#ifndef NDEBUG
pid_t ppid = THREAD_GETMEM (THREAD_SELF, tid);
@@ -199,11 +196,7 @@
THREAD_SETMEM (THREAD_SELF, pid, parentpid);
/* We execute this even if the 'fork' call failed. */
-#ifdef __USE_STDIO_FUTEXES__
- _IO_lock_unlock(_stdio_openlist_add_lock);
-#else
- __pthread_mutex_unlock(&_stdio_openlist_add_lock);
-#endif
+ __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(_stdio_openlist_add_lock);
/* Run the handlers registered for the parent. */
while (allp != NULL)
More information about the uClibc-cvs
mailing list