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 Sun, 29 Feb 2004, Anthony Green wrote:
> + inline _Jv_ThreadId_t
> + _Jv_ThreadSelf (void)
> + {
> +   size_t id;
> +   asm ("mov %%gs:0x8, %0" : "=r"(id));
> +   return id;
> + }

I'm curious what the special significance of offset 0x8 might be.  As I
understand TLS on glibc, "move %gs:0, %eax" would place the thread pointer
in %eax, which is sufficient for these purposes as a pointer to an opaque
per-thread structure.

Equivalently, you could do:

static __thread _Jv_ThreadId_t me;
...
  return me;

and set the variable during thread creation.  It is more portable, and
should work anywhere TLS is available.  But your version is more efficient
within a DSO.

Jeff


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