This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: libgcj and the NPTL posix threads implementation
- From: Anthony Green <green at redhat dot com>
- To: Jeff Sturm <jsturm at one-point dot com>
- Cc: Andrew Haley <aph at redhat dot com>, "Boehm, Hans" <hans dot boehm at hp dot com>, "'Michael Koch'" <konqueror at gmx dot de>, java at gcc dot gnu dot org
- Date: Mon, 01 Mar 2004 14:10:38 -0800
- Subject: RE: libgcj and the NPTL posix threads implementation
- Organization: Red Hat, Inc.
- References: <Pine.LNX.4.44.0403011639240.17464-100000@ops2.one-point.com>
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.