__thread
Fergus Henderson
fjh@cs.mu.OZ.AU
Fri Mar 14 16:50:00 GMT 2003
On 14-Mar-2003, Tam?s Gergely <gertom@rgai.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@cs.mu.oz.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.
More information about the Gcc-help
mailing list