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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Aug 16 17:57:17 2009 +0200

bind: avoid multiple initialisation of pthread_keys.

They may occur when a process is linked with several skin libraries.

---

 include/asm-generic/bits/bind.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 79a4581..87cef48 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -25,6 +25,7 @@ static inline void __xeno_set_current(xnhandle_t current)
        xeno_current = current;
 }
 #else /* !HAVE___THREAD */
+pthread_once_t xeno_init_current_keys_once __attribute__((weak));
 pthread_key_t xeno_current_key __attribute__ ((weak));
 pthread_key_t xeno_current_mode_key __attribute__ ((weak));
 
@@ -46,8 +47,7 @@ static void cleanup_current_mode(void *ptr)
        free(ptr);
 }
 
-static __attribute__ ((constructor))
-void init_current_keys(void)
+static void __init_current_keys(void)
 {
        int err = pthread_key_create(&xeno_current_key, NULL);
        if (err)
@@ -61,6 +61,12 @@ void init_current_keys(void)
                exit(1);
        }
 }
+
+static __attribute__((constructor))
+void init_current_keys(void)
+{
+       pthread_once(&xeno_init_current_keys_once, __init_current_keys);
+}
 #endif /* !HAVE___THREAD */
 
 __attribute__ ((weak))


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

Reply via email to