Module: xenomai-forge
Branch: master
Commit: 771afd21a6a36bab7c5ac2ec2ffa5d3c7b28e402
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=771afd21a6a36bab7c5ac2ec2ffa5d3c7b28e402

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Dec  9 18:20:04 2011 +0100

copperplate/threadobj: enable thread finalization code with TLS

This patch fixes a regression introduced by 714a2447c, which
mistakenly disables the invocation of the thread finalizer when TLS
are used.

---

 include/copperplate/threadobj.h |    5 +++--
 lib/copperplate/threadobj.c     |   12 +++++-------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index f18f4e4..8553995 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -155,6 +155,8 @@ extern int threadobj_high_prio;
 
 extern int threadobj_irq_prio;
 
+extern pthread_key_t threadobj_tskey;
+
 #ifdef HAVE___THREAD
 
 extern __thread __attribute__ ((tls_model ("initial-exec")))
@@ -163,6 +165,7 @@ struct threadobj *__threadobj_current;
 static inline void threadobj_set_current(struct threadobj *thobj)
 {
        __threadobj_current = thobj;
+       pthread_setspecific(threadobj_tskey, thobj);
 }
 
 static inline struct threadobj *threadobj_current(void)
@@ -172,8 +175,6 @@ static inline struct threadobj *threadobj_current(void)
 
 #else /* !HAVE___THREAD */
 
-extern pthread_key_t threadobj_tskey;
-
 static inline void threadobj_set_current(struct threadobj *thobj)
 {
        pthread_setspecific(threadobj_tskey, thobj);
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 15e1c1b..94a4f21 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -76,12 +76,12 @@ static void cancel_sync(struct threadobj *thobj);
 __thread __attribute__ ((tls_model ("initial-exec")))
 struct threadobj *__threadobj_current;
 
-static inline void threadobj_init_key(void)
-{
-}
-
-#else /* !HAVE____THREAD */
+#endif
 
+/*
+ * We need the thread object key regardless of whether TLS is
+ * available to us, to run the thread finalizer routine.
+ */
 pthread_key_t threadobj_tskey;
 
 static inline void threadobj_init_key(void)
@@ -90,8 +90,6 @@ static inline void threadobj_init_key(void)
                panic("failed to allocate TSD key");
 }
 
-#endif /* !HAVE____THREAD */
-
 #ifdef CONFIG_XENO_COBALT
 
 #include "cobalt/internal.h"


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to