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: Ulrich Weigand <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: jsturm at one-point dot com
- Cc: green at redhat dot com, hans dot boehm at hp dot com, konqueror at gmx dot de, java at gcc dot gnu dot org
- Date: Wed, 3 Mar 2004 04:43:27 +0100 (CET)
- Subject: RE: libgcj and the NPTL posix threads implementation
Jeff Sturm wrote:
>static int __thread x;
>int t(void) {
> return x;
>}
>
>compare the output compiled with -fPIC:
>
>t:
> pushl %ebx
> call __i686.get_pc_thunk.bx
> addl $_GLOBAL_OFFSET_TABLE_, %ebx
> leal x@TLSLDM(%ebx), %eax
> call ___tls_get_addr@PLT
> popl %ebx
> movl x@DTPOFF(%eax), %eax
> ret
>
>vs. without:
>
>t:
> movl %gs:x@NTPOFF, %eax
> ret
>
>The former is necessary in a DSO where the exact thread-local offset can't
>be known at compile time.
However, for smalls amount of data you're allowed to use
static int __thread x __attribute__ ((tls_model ("initial-exec")));
in a library; try this with -fPIC, it'll be much more efficient ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de