This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Thread support in cygwin!


On Apr 13 11:36, Joost Kraaijeveld wrote:
> On Thu, 2006-04-13 at 11:00 +0200, Samuel Thibault wrote:
> > Joost Kraaijeveld, le Thu 13 Apr 2006 10:45:39 +0200, a écrit :
> > > On Thu, 2006-04-13 at 09:42 +0200, Samuel Thibault wrote:
> > > > Joost Kraaijeveld, le Thu 13 Apr 2006 08:10:15 +0200, a écrit :
> > > > > No, it means that _POSIX_THREADS  is not defined. 
> > > > 
> > > > Cygwin should define it.
> > > Why? 
> > 
> > In unistd.h I mean. (And by really looking at it, unistd.h includes
> > sys/unistd.h which itself includes sys/features.h, which defines it, so
> > the problem here is probably that the user includes pthread.h instead of
> > unistd.h (I haven't kept the mail)).
> 
> You are right here: see also 
> http://www.opengroup.org/onlinepubs/007908799/xsh/unistd.h.html or
> http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html
> (The Single UNIX ® Specification, Version 2 or 3).
> 
> Although not required by a pthread spec (as far as I can see) it might
> be a good idea to include (the pthread part) unistd.h in the pthread.h
> as Linux and pthreads-win32 seem to do.

As far as I can see, Linux doesn't:

  $ echo "#include <pthread.h>" > x.c
  $ gcc -M x.c
  x.o: x.c /usr/include/pthread.h /usr/include/features.h \
    /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h /usr/include/sched.h \
    /usr/include/bits/types.h /usr/include/bits/wordsize.h \
    /usr/lib/gcc/i386-redhat-linux/3.4.5/include/stddef.h \
    /usr/include/bits/typesizes.h /usr/include/time.h \
    /usr/include/bits/sched.h /usr/include/bits/time.h \
    /usr/include/signal.h /usr/include/bits/sigset.h \
    /usr/include/bits/pthreadtypes.h /usr/include/bits/initspin.h \
    /usr/include/bits/sigthread.h

And it doesn't make sense to me.  The _POSIX_THREAD* values are already
included through /usr/include/features.h and the _SC_THREAD* values are
only used for sysconf, which requires to include unistd.h anyway.

As for Cygwin:

  $ gcc -M x.c
  x.o: x.c /usr/include/pthread.h /usr/include/sys/types.h \
    /usr/include/_ansi.h /usr/include/newlib.h /usr/include/sys/config.h \
    /usr/include/machine/ieeefp.h /usr/include/cygwin/config.h \
    /usr/include/machine/_types.h /usr/include/sys/_types.h \
    /usr/include/sys/lock.h \
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h \
    /usr/include/machine/types.h /usr/include/sys/features.h \
    /usr/include/cygwin/types.h /usr/include/sys/sysmacros.h \
    /usr/include/stdint.h /usr/include/endian.h /usr/include/signal.h \
    /usr/include/_ansi.h /usr/include/sys/signal.h \
    /usr/include/cygwin/signal.h /usr/include/sched.h /usr/include/time.h \
    /usr/include/sys/reent.h /usr/include/machine/time.h \
    /usr/include/cygwin/time.h

You can see that /usr/include/sys/features.h is included, so the
_POSIX_THREAD* defines are available.

I see only one problem here, which is that _SC_THREAD* values are
currently not supported by sysconf(), hence returning -1.  I'll add
the handling for these values to sysconf().


Corinna

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]