guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread local storage


From: Ken Raeburn
Subject: Re: Thread local storage
Date: Tue, 6 Oct 2009 13:44:44 -0400

On Oct 4, 2009, at 10:03, Ludovic Courtès wrote:
I looked again at how/whether we could improve thread-local storage
access, using compiler support (the ‘__thread’ storage class).

For the most part I think the wip-tls changes look good. In the non- __thread case, though, you've eliminated the pthread_key_create call, making it not work on my Mac. (In addition to the still-present i18n.c compilation problem.) Assuming that __thread variables are by default initialized to 0 (or NULL or whatever we specify), we also don't need anything in init_thread_key when we have __thread support. I suggest something like the patch below. I haven't tried it on a system *with* the __thread support though.

Ken

--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -538,11 +538,13 @@ on_thread_exit (void *v)

static scm_i_pthread_once_t init_thread_key_once = SCM_I_PTHREAD_ONCE_INIT;

+#ifndef SCM_HAVE_THREAD_STORAGE_CLASS
 static void
 init_thread_key (void)
 {
-  SET_CURRENT_THREAD (NULL);
+  scm_i_pthread_key_create (&scm_i_thread_key, NULL);
 }
+#endif

 /* Perform any initializations necessary to bring the current thread
    into guile mode, initializing Guile itself, if necessary.
@@ -561,7 +563,9 @@ scm_i_init_thread_for_guile (SCM_STACKITEM *base, SCM parent)
 {
   scm_i_thread *t;

+#ifndef SCM_HAVE_THREAD_STORAGE_CLASS
   scm_i_pthread_once (&init_thread_key_once, init_thread_key);
+#endif

   t = SCM_I_CURRENT_THREAD;
   if (t == NULL)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]