delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/04/13/08:11:11

X-Spam-Check-By: sourceware.org
Date: Thu, 13 Apr 2006 14:10:57 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: Cygwin <cygwin AT cygwin DOT com>
Subject: Re: Thread support in cygwin!
Message-ID: <20060413121057.GJ9135@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: Cygwin <cygwin AT cygwin DOT com>
References: <3894619 DOT post AT talk DOT nabble DOT com> <1144908615 DOT 22144 DOT 6 DOT camel AT localhost> <20060413074220 DOT GA4280 AT implementation DOT labri DOT fr> <1144917939 DOT 22144 DOT 21 DOT camel AT localhost> <20060413090026 DOT GD4280 AT implementation DOT labri DOT fr> <1144921003 DOT 22144 DOT 29 DOT camel AT localhost>
Mime-Version: 1.0
In-Reply-To: <1144921003.22144.29.camel@localhost>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019