pthreads, part 3

Alex Waugh alex at alexwaugh.com
Sat Dec 28 13:17:47 PST 2002


In message <3E0DFB95.4080108 at dsvr.net>
          Nick Burrett <nick at dsvr.net> wrote:

> Alex Waugh wrote:
> > Some miscellaneous pthreads changes:
> > 
> > Changed errno back to a global variable, as some programs had problems
> > with the macro
> > Fix problem with programs like links that have their own sched.h
> > Add support for restoring the CPSR on a 32bit OS
> > Various APCS32 fixes
> 
> > Index: unixlib/source/clib/pthread.h
> > ===================================================================
> > RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/clib/pthread.h,v
> > retrieving revision 1.3
> > diff -u -r1.3 pthread.h
> > --- unixlib/source/clib/pthread.h	15 Dec 2002 13:16:55 -0000	1.3
> > +++ unixlib/source/clib/pthread.h	26 Dec 2002 17:40:40 -0000
> > @@ -22,7 +22,8 @@
> >  #define __need_clock_t
> >  #include <time.h>
> >  
> > -#include <sched.h> /* for struct sched_param */
> > +#include "sched.h" /* for struct sched_param */
> > +/* uses "" rather than <> to prevent problems with programs that have their own sched.h */
> 
> I disagree with this change.   The problem lies with 'links' or the 
> include path specifiers that you are using.  '<...>' are for system 
> headers, which sched.h, being in the standard C library, is.

The problem is as follows
links has its source split into several directories
one of the directories has a sched.h file
The different directories are added to the include search list with
gcc -I
some source files in links #include <sys/types.h>
sys/types.h includes pthread.h
pthread.h includes sched.h, but because links has added things to the
include search path the wrong sched.h gets picked up

I think ultimately the problem is that there is no way AFAIK to specify
"add this directory to the #include "" search but not the #include <>
search path" so many programs have to add directories to the system
include search path which really shouldn't be added.

The reason links compiles fine on every other platform is that nobody
else seems to include pthread.h from sys/types.h
POSIX says that pthread_t and related types should be visible from
sys/types.h; Solaris has the type definitions inlined in sys/types.h,
Linux and HPUX don't have anything pthread related in sys/types.h

I don't particularly like solution in the patch, but I couldn't think of
anything better.

Alex

-- 
Alex Waugh                                           alex at alexwaugh.com

PHP, Roots, Subversion, WebJames and more from http://www.alexwaugh.com/



More information about the gcc mailing list