__uclibc_mutex_unlock

Joakim Tjernlund joakim.tjernlund at transmode.se
Sat Jan 6 02:10:13 UTC 2007


> -----Original Message-----
> From: uclibc-bounces at uclibc.org 
> [mailto:uclibc-bounces at uclibc.org] On Behalf Of Joakim Tjernlund
> Sent: den 6 januari 2007 01:44
> To: uclibc at uclibc.org
> Subject: __uclibc_mutex_unlock
> 
> Did some digging into the ARM SEGV landly has seen
> recently and this makes me wounder:
> 
> Can anyone tell me why uclibc_mutex.h uses
> __uclibc_mutex_unlock in macro __UCLIBC_MUTEX_CONDITIONAL_LOCK()
> instead of __pthread_mutex_unlock()?
> 
>  Jocke

Took a crack at fixing this but I am too tiered(and lazy)
to test it.

Anyone feel like testing(with/without thread support and dynamic
vs. static)? Or perhaps just comment?

 Jocke

Index: libc/sysdeps/linux/common/bits/uClibc_mutex.h
===================================================================
--- libc/sysdeps/linux/common/bits/uClibc_mutex.h	(revision 17166)
+++ libc/sysdeps/linux/common/bits/uClibc_mutex.h	(working copy)
@@ -36,7 +36,7 @@
 		struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer;				\
 		if (C) {										\
 			_pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer,			\
-										__uclibc_mutex_unlock,	\
+						    (void (*) (void *))__pthread_mutex_unlock,		\
 										&(M));			\
 			__pthread_mutex_lock(&(M));							\
 		}											\
Index: libc/misc/pthread/Makefile.in
===================================================================
--- libc/misc/pthread/Makefile.in	(revision 17169)
+++ libc/misc/pthread/Makefile.in	(working copy)
@@ -8,8 +8,8 @@
 MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread
 MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread
 
-libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/unlock.o
-libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
+#libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/unlock.o
+#libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
 
 objclean-y += misc_pthread_objclean
 
Index: libc/misc/internals/__uClibc_main.c
===================================================================
--- libc/misc/internals/__uClibc_main.c	(revision 17166)
+++ libc/misc/internals/__uClibc_main.c	(working copy)
@@ -399,3 +399,29 @@
      */
     exit(main(argc, argv, __environ));
 }
+
+#ifdef __UCLIBC_HAS_THREADS__
+/* Weaks for internal library use only.
+ *
+ * We need to define weaks here to cover all the pthread functions that
+ * libc itself will use so that we aren't forced to link libc against
+ * libpthread.  This file is only used in libc.a and since we have
+ * weaks here, they will be automatically overridden by libpthread.a
+ * if it gets linked in.
+ */
+
+static int __pthread_return_0 (void) { return 0; }
+static void __pthread_return_void (void) { return; }
+
+weak_alias (__pthread_return_0, __pthread_mutex_init)
+weak_alias (__pthread_return_0, __pthread_mutex_lock)
+weak_alias (__pthread_return_0, __pthread_mutex_trylock)
+weak_alias (__pthread_return_0, __pthread_mutex_unlock)
+weak_alias (__pthread_return_void, _pthread_cleanup_push_defer)
+weak_alias (__pthread_return_void, _pthread_cleanup_pop_restore)
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+weak_alias (__pthread_return_0, __pthread_mutexattr_init)
+weak_alias (__pthread_return_0, __pthread_mutexattr_destroy)
+weak_alias (__pthread_return_0, __pthread_mutexattr_settype)
+# endif
+#endif




More information about the uClibc mailing list