This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __thread
- From: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- To: Tam?s Gergely <gertom at rgai dot hu>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>, gcc at gcc dot gnu dot org, Daniel Jacobowitz <drow at mvista dot com>, mohamed dot abbas at intel dot com
- Date: Sat, 15 Mar 2003 03:25:42 +1100
- Subject: Re: __thread
- References: <3E71FE95.7070000@rgai.hu>
On 14-Mar-2003, Tam?s Gergely <gertom at rgai dot hu> wrote:
> In file included from ../include/pthread.h:1,
> from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:23,
> from ../sysdeps/generic/ldsodefs.h:34,
> from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
> from ../sysdeps/unix/sysv/linux/init-first.c:32:
> ../linuxthreads/sysdeps/pthread/pthread.h:163: error: parse error before
> "__thread"
Ouch. According to the C standard, the section of the namespace
starting with "__" is reserved for use by the implementation, but the
implementation consists of two parts, a compiler and a library,
and in this case there is a name clash -- GCC's use of "__thread"
clashes with glibc's use of it.
> The line in ../linuxthreads/sysdeps/pthread/pthread.h was:
>
> extern int pthread_create (pthread_t *__restrict __thread,
In GCC 3.2, "__thread" is just an ordinary identifier,
so this gets parsed as a parameter name. That is what
the glibc source intended.
In current CVS GCC, "__thread" is now a keyword, and as such it is not
allowed to appear here. That's why CVS GCC reports a syntax error.
> - Is that a bug in gcc-3.2 that it accepts __thread? (By the way, it
> accepts anything at that place.)
No. In 3.2, "__thread" is just an ordinary identifier (in the
implementation name space, since it starts with "__"). Since
it is used as a parameter name in a function declaration,
any other identifier would do just as well.
> - What is the purpose of the fixinc directory?
To fix problems like this, if they occur in already-installed
header files.
> - Could the things in the fixinc "correct" the glibc headers, and if they
> could, how?
In theory, yes, although I don't know if they do currently, and I'm not sure
if fixinc is run on Linux anyway.
> - How can I get the snapshot to compile glibc?
Change the glibc sources to use a different identifier, e.g.
"__thread_param", instead of "__thread".
--
Fergus Henderson <fjh at cs dot mu dot oz dot au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.