This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[c++0x] thread_local


Just curious if thread_local could "piggy back" __thread  (well,
RID_THREAD really). I've never really modified the c/c++ front-end so
I'm not aware of the big picture but the attached patch has a trivial
test case that passes (and thus far I can't see any regressions caused
by the patch, on x64_64-unknown-linux anyway).

Is it really this simple? If so, I can whip up some testcases and a
changelog entry.

Cheers,
Chris

PS. Just FYI here's some code I was using for a slightly-less-trivial
testcase. Unfortunately it uses a local libstdc++ <thread>
implementation I haven't submitted yet but you could modify it to use
boost.thread or pthreads if you're so inclined to see it work ;)

#include <thread>

thread_local int j = 42;

void foo() {  j = 43; }

int main()
{
  std::thread t(foo);
  t.join();

  if(j != 42) abort();

  return 0;
}

Attachment: thread_local.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]