libgcj and the NPTL posix threads implementation
Andrew Haley
aph@redhat.com
Mon Mar 1 22:16:00 GMT 2004
Anthony Green writes:
> 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.
It won't be so very long until all this stuff really is stable. Give
it 6 months or so.
Andrew.
More information about the Java
mailing list