This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

RE: libgcj and the NPTL posix threads implementation


On Mon, 2004-03-01 at 13:42, Jeff Sturm wrote:
> What can you reliably test for, besides catching a signal if TLS isn't
> available?

I think we'd want to do something like this for x86...

static int using_NPTL = 0;

...and...

#ifdef _CS_GNU_LIBPTHREAD_VERSION
  size_t n = confstr (_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
  if (n > 0)
  {
    char* buf = (char*)alloca(n);
    confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, n);
    if (strstr (buf, "NPTL"))
      using_NPTL = true;
  }
#endif

..and..

inline _Jv_ThreadId_t
_Jv_ThreadSelf (void)
{
  if (using_NPTL)
  {
    size_t id;
    asm ("mov %%gs:0x0, %0" : "=r"(id));
    return id;
  } else {
     ...use Boehm's caching thread identity code...
  }
}


I think this would always work, but I really wish we didn't have to.

AG

-- 
Anthony Green <green@redhat.com>
Red Hat, Inc.


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