thread-local storage: c++ front end

Jason Merrill jason@redhat.com
Tue May 21 21:47:00 GMT 2002


>>>>> "Richard" == Richard Henderson <rth@redhat.com> writes:

> Could someone more fluent in C++ than I look this over to see what bits
> I've missed?  I'm most interested in kinds of initializations that result
> in code being generated, rather than raw data.

> Also, I'm not sure how to handle class members.  I want non-static class
> members to reject the __thread specifier, but it seems reasonable to
> support thread-local static class members.  Similarly with static members
> of template classes.  (Those are just normal global data with complex
> names, after all.)

So something like

  struct A {
    static __thread int i;
  };

  __thread int A::i = 42;

  template <typename T> struct B {
    static __thread T t;
  };

  template <typename T> 
  __thread T B<T>::t = 42;

  int main ()
  {
    int j = B<int>::t;
  }

?

> + 	  /* The thread-local storage area is initialized via block copy
> + 	     inside the dynamic loader or other appropriate system library.
> + 	     We cannot support anything that requires complexity.  */
> + 	  if (DECL_THREAD_LOCAL (decl))
> + 	    {
> + 	      error ("thread-local storage cannot be initialized by constructor");
> + 	      init = error_mark_node;
> + 	    }

This should probably go in obscure_complex_init.

Any reason the tls tests need their own directory?  There are few enough
that I'd tend to put them under special.

Jason



More information about the Gcc-patches mailing list