Re: Problem compiling w/POSIX threads (fwd)

Linus Torvalds (Linus.Torvalds@cs.helsinki.fi)
Sat, 9 Mar 1996 11:58:15 +0200


Nagy Peter: "Re: Problem compiling w/POSIX threads (fwd)" (Mar 7, 10:26):
>
>
> On Wed, 6 Mar 1996, Eric Plante wrote:
> > monLinux:~/xrec$ gcc -c xrec_main.c -D_MIT_POSIX_THREADS
> > In file included from /usr/include/pthread/mit/cond.h:45,
> > from /usr/include/pthread/mit/pthread.h:56,
> > from /usr/include/pthread.h:9,
> > from xrec_main.c:3:
> > /usr/include/pthread/mit/sys/timers.h:46: redefinition of `struct timespec'
> >
> > What xrec_main does is irrelevent, since this happens on line 3 of the
> > source which is "#include <pthread.h>".I've taken a quick look, and in
> > the file /usr/include/pthread/mit/fd.h there is a line that goes:
> >
> > struct timespec;
> >
> > And in the file /usr/include/pthread/mit/sys/timer.h there is a line that
> > goes:
> >
> > struct timespec {
> > time_t ts_sec;
> > long ts_nsec;

This is incorrect. The "ts_" prefix _sounds_ like the logical one (yes,
I was fooled too), but the correct prefix is "tv_" (I just
double-checked with the Solaris and OSF/1 header files)

> > };
> >
> > SO.. Am I doing something stupid?

No. The newer kernel headers have "struct timespec" in them already,
and they have the correct prefix (there was one kernel release with the
wrong prefix due to the same confusion with the pthreads library, but
that was quickly fixed).

You should probably remove the "struct timespec" from the pthreads
headers, and if anything tries to use "ts_sec" or "ts_nsec", just change
it to a "tv_xxx" instead.

Linus