[PATCH] Modified pthread types; From: cygwin-patches@cygwin.com

Thomas Pfaff tpfaff@gmx.net
Mon Jul 8 01:13:00 GMT 2002


I have attached a new patch with your changes but with one exception:
PTHREAD_COND_INITIALIZER should be (pthread_cond_t)21

If you see memory leaks should depend on your gcc version. gcc 3.x will
use another exception handling code that does not use pthread keys to
store the exception handling context.

Thomas

Changelog:

2002-07-08  Thomas Pfaff  <tpfaff@gmx.net>

	* include/semaphore.h: Modified typedef for sem_t.
	* include/cygwin/types.h: Modified typedefs for pthread_t,
	pthread_mutex_t, pthread_key_t, pthread_attr_t,
	pthread_mutexattr_t, pthread_condattr_t, pthread_cond_t,
	pthread_rwlock_t and pthread_rwlockattr_t.
	* include/pthread.h: Modified PTHREAD_COND_INITIALIZER and
	PTHREAD_MUTEX_INITIALIZER


On Sun, 7 Jul 2002, Christoph wrote:

> > From: Thomas Pfaff
> > To: cygwin-patches.cygwin.com
>
> http://cygwin.com/ml/cygwin-patches/2002-q3/msg00052.html
>
> >
> > I have attached a patch with modified (dummy) pthread typedefs.
> >
> > This should give the compiler a chance to do some type validations,
> > for example:
> >
> > pthread_t t;
> > pthread_create(t,...) //wrong
> > pthread_create(&t,...) // right
> >
> > pthread_cancel(t) //right
> > pthread_cancel(&t)//wrong
>
>
> Using your patch I needed to tweak /usr/include/pthreads.h
> when compiling libstdc++.  Also I don't think that I saw a
> memory leak when running your test program from the
> cygwin-patch mailing list.
>
> http://cygwin.com/ml/cygwin-patches/2002-q2/msg00214.html
>
> Note I linked the CYGWIN dll to the gcc libraries generated
> by a pthreads + exception enabled compile.
>
>
> /Christoph
>
>
> --- /usr/include/pthread.h.old	2002-07-04 17:01:18.000000000 +0200
> +++ /usr/include/pthread.h	2002-07-05 20:48:12.000000000 +0200
> @@ -44,7 +44,7 @@
>  #define PTHREAD_CANCEL_DISABLE 1
>  #define PTHREAD_CANCELED ((void *)-1)
>  /* this should be a value that can never be a valid address */
> -#define PTHREAD_COND_INITIALIZER (void *)21
> +#define PTHREAD_COND_INITIALIZER (pthread_mutex_t)21
>  #define PTHREAD_CREATE_DETACHED 1
>  /* the default : joinable */
>  #define PTHREAD_CREATE_JOINABLE 0
> @@ -54,7 +54,7 @@
>  #define PTHREAD_MUTEX_ERRORCHECK 1
>  #define PTHREAD_MUTEX_NORMAL 2
>  /* this should be too low to ever be a valid address */
> -#define PTHREAD_MUTEX_INITIALIZER (void *)20
> +#define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t)20
>  #define PTHREAD_MUTEX_RECURSIVE 0
>  #define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 }
>  #define PTHREAD_PRIO_INHERIT
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pthread_types.patch
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020708/37121e4a/attachment.ksh>


More information about the Cygwin-patches mailing list