diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ANNOUNCE pthreads/ANNOUNCE --- pthreads-w32-2-8-0-release/ANNOUNCE 2006-12-22 13:36:40.000000000 +1100 +++ pthreads/ANNOUNCE 2007-01-07 00:44:39.000000000 +1100 @@ -1,4 +1,4 @@ - PTHREADS-WIN32 RELEASE 2.8.0 (2006-12-22) + PTHREADS-WIN32 RELEASE 2.9.0 (2007-??-??) ----------------------------------------- Web Site: http://sources.redhat.com/pthreads-win32/ FTP Site: ftp://sources.redhat.com/pub/pthreads-win32 diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/CONTRIBUTORS pthreads/CONTRIBUTORS --- pthreads-w32-2-8-0-release/CONTRIBUTORS 2005-06-03 18:36:26.000000000 +1000 +++ pthreads/CONTRIBUTORS 2008-06-06 10:23:20.000000000 +1000 @@ -114,6 +114,7 @@ Makoto Kato raven at oldskool dot jp AMD64 port. Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr + phadjido at cs dot uoi dot gr Contributed the QueueUserAPCEx package which makes preemptive async cancelation possible. Will Bryant will dot bryant at ecosm dot com diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ChangeLog pthreads/ChangeLog --- pthreads-w32-2-8-0-release/ChangeLog 2006-12-22 13:36:40.000000000 +1100 +++ pthreads/ChangeLog 2009-03-04 20:46:14.000000000 +1100 @@ -1,4 +1,105 @@ -2006-12-20 Ross Johnson +2009-03-03 Stephan O'Farrill + + * pthread_attr_getschedpolicy.c: Add "const" to function parameter + in accordance with SUSv3 (POSIX). + * pthread_attr_getinheritsched.c: Likewise. + * pthread_mutexattr_gettype.c: Likewise. + + +2008-06-06 Robert Kindred + + * ptw32_throw.c (ptw32_throw): Remove possible reference to NULL + pointer. (At the same time made the switch block conditionally + included only if exitCode is needed - RPJ.) + * pthread_testcancel.c (pthread_testcancel): Remove duplicate and + misplaced pthread_mutex_unlock(). + +2008-02-21 Sebastian Gottschalk + + * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate): + Remove potential and superfluous null pointer assignment. + +2007-11-22 Ivan Pizhenko + + * pthread.h (gmtime_r): gmtime returns 0 if tm represents a time + prior to 1/1/1970. Notice this to prevent raising an exception. + * pthread.h (localtime_r): Likewise for localtime. + +2007-07-14 Marcel Ruff + + * errno.c (_errno): Fix test for pthread_self() success. + * need_errno.h: Remove unintentional line wrap from #if line. + +2007-07-14 Mike Romanchuk + + * pthread.h (timespec): Fix tv_sec type. + +2007-01-07 Sinan Kaya + + * need_errno.h: Fix declaration of _errno - the local version of + _errno() is used, e.g. by WinCE. + +2007-01-06 Ross Johnson + + * ptw32_semwait.c: Add check for invalid sem_t after acquiring the + sem_t state guard mutex and before affecting changes to sema state. + +2007-01-06 Marcel Ruff + + * error.c: Fix reference to pthread handle exitStatus member for + builds that use NEED_ERRNO (i.e. WINCE). + * context.h: Add support for ARM processor (WinCE). + * mutex.c (process.h): Exclude for WINCE. + * create.c: Likewise. + * exit.c: Likewise. + * implement.h: Likewise. + * pthread_detach.c (signal.h): Exclude for WINCE. + * pthread_join.c: Likewise. + * pthread_kill.c: Likewise. + * pthread_rwlock_init.c (errno.h): Remove - included by pthread.h. + * pthread_rwlock_destroy.c: Likewise. + * pthread_rwlock_rdlock.c: Likewise. + * pthread_rwlock_timedrdlock.c: Likewise. + * pthread_rwlock_timedwrlock.c: Likewise. + * pthread_rwlock_tryrdlock.c: Likewise. + * pthread_rwlock_trywrlock.c: likewise. + * pthread_rwlock_unlock.c: Likewise. + * pthread_rwlock_wrlock.c: Likewise. + * pthread_rwlockattr_destroy.c: Likewise. + * pthread_rwlockattr_getpshared.c: Likewise. + * pthread_rwlockattr_init.c: Likewise. + * pthread_rwlockattr_setpshared.c: Likewise. + +2007-01-06 Romano Paolo Tenca + + * pthread_cond_destroy.c: Replace sem_wait() with non-cancelable + ptw32_semwait() since pthread_cond_destroy() is not a cancelation + point. + * implement.h (ptw32_spinlock_check_need_init): Add prototype. + * ptw32_MCS_lock.c: Reverse order of includes. + +2007-01-06 Eric Berge + + * pthread_cond_destroy.c: Add LeaveCriticalSection before returning + after errors. + +2007-01-04 Ross Johnson + + * ptw32_InterlockedCompareExchange.c: Conditionally skip for + Win64 as not required. + * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): + Test for InterlockedCompareExchange is not required for Win64. + * context.h: New file. Included by pthread_cancel.h and any tests + that need it (e.g. context1.c). + * pthread_cancel.c: Architecture-dependent context macros moved + to context.h. + +2007-01-04 Kip Streithorst + + * implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64 + support. + +2006-12-20 Ross Johnson * sem_destroy.c: Fix the race involving invalidation of the sema; fix incorrect return of EBUSY resulting from the mutex trylock diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/FAQ pthreads/FAQ --- pthreads-w32-2-8-0-release/FAQ 2004-11-03 12:08:42.000000000 +1100 +++ pthreads/FAQ 2007-12-16 14:47:01.000000000 +1100 @@ -30,6 +30,9 @@ Q 10 How do I generate pthreadGCE.dll and libpthreadw32.a for use with Mingw32? +Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int) + like it is for other POSIX threads implementations? + ============================================================================= Q 1 What is it? @@ -400,4 +403,49 @@ For early versions, see Thomas Pfaff's email at: http://sources.redhat.com/ml/pthreads-win32/2002/msg00000.html ------------------------------------------------------------------------------ - + +Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int) + like it is for other POSIX threads implementations? +---- + +Originally pthread_t was defined as a pointer (to the opaque pthread_t_ +struct) and later it was changed to a struct containing the original +pointer plus a sequence counter. This is allowed under both the original +POSIX Threads Standard and the current Single Unix Specification. + +When pthread_t is a simple pointer to a struct some very difficult to +debug problems arise from the process of freeing and later allocing +thread structs because new pthread_t handles can acquire the identity of +previously detached threads. The change to a struct was made, along with +some changes to their internal managment, in order to guarantee (for +practical applications) that the pthread_t handle will be unique over the +life of the running process. + +Where application code attempts to compare one pthread_t against another +directly, a compiler error will be emitted because structs can't be +compared at that level. This should signal a potentially serious problem +in the code design, which would go undetected if pthread_t was a scalar. + +The POSIX Threading API provides a function named pthread_equal() to +compare pthread_t thread handles. + +Other pthreads implementations, such as Sun's, use an int as the handle +but do guarantee uniqueness within the process scope. Win32 scalar typed +thread handles also guarantee uniqueness in system scope. It wasn't clear +how well the internal management of these handles would scale as the +number of threads and the fragmentation of the sequence numbering +increased for applications where thousands or millions of threads are +created and detached over time. The current management of threads within +pthreads-win32 using structs for pthread_t, and reusing without ever +freeing them, reduces the management time overheads to a constant, which +could be important given that pthreads-win32 threads are built on top of +Win32 threads and will therefore include that management overhead on top +of their own. The cost is that the memory resources used for thread +handles will remain at the peak level until the process exits. + +While it may be inconvenient for developers to be forced away from making +assumptions about the internals of pthread_t, the advantage for the +future development of pthread-win32, as well as those applications that +use it and other pthread implementations, is that the library is free to +change pthread_t internals and management as better methods arise. + diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/Makefile pthreads/Makefile --- pthreads-w32-2-8-0-release/Makefile 2005-06-03 18:36:27.000000000 +1000 +++ pthreads/Makefile 2007-01-07 00:44:40.000000000 +1100 @@ -27,7 +27,7 @@ OPTIM = /O2 /Ob2 OPTIMD = -CFLAGS = /W3 /MD /nologo /Yd /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H +CFLAGS = /W3 /MD /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H CFLAGSD = /Zi $(CFLAGS) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/NEWS pthreads/NEWS --- pthreads-w32-2-8-0-release/NEWS 2006-12-22 13:36:40.000000000 +1100 +++ pthreads/NEWS 2008-06-06 10:28:45.000000000 +1000 @@ -1,3 +1,51 @@ +RELEASE 2.9.0 +------------- +(2008-??-??) + +General +------- +New bug fixes in this release since 2.8.0 have NOT been applied to the +1.x.x series. + +Version 1 no longer maintained +------------------------------ +The 1.x.x series is no longer maintained. However, if you really need a +version 1, the differences between 1.11.0 and 2.7.0 are very small, mainly +revolving around the pthread_once_t_ struct. Those differences applied +as a patch to the current 2.x.x should work. Don't forget to change +the version numbering in pthread.h before building. If you distribute +such a version 1.x.x please bear in mind that your numbers may clash +with those of others doing the same thing. Please consider also making +identifying changes in version.rc to differentiate your build. + +Testing and verification +------------------------ +This release has been tested on UP and SMP architectures. Thanks to Tim +Theisen for running the Win32 SMP tests. + +Bug fixes +--------- +Various modifications and fixes to build and test for WinCE. +- Marcel Ruff, Sinan Kaya + +Fix pthread_cond_destroy() - should not be a cancellation point. Other +minor build problems fixed. +- Romano Paolo Tenca + +Remove potential deadlock condition from pthread_cond_destroy(). +- Eric Berge + +Various modifications to build and test for Win64. +- Kip Streithorst + +Various fixes to the QueueUserAPCEx async cancellation helper DLL +and pthreads code cleanups. +- Sebastian Gottschalk + +Removed potential NULL pointer reference. +- Robert Kindred + + RELEASE 2.8.0 ------------- (2006-12-22) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/README.NONPORTABLE pthreads/README.NONPORTABLE --- pthreads-w32-2-8-0-release/README.NONPORTABLE 2004-11-03 12:08:42.000000000 +1100 +++ pthreads/README.NONPORTABLE 2007-05-27 00:57:19.000000000 +1000 @@ -72,6 +72,16 @@ Applications can use the win32 handle to set win32 specific attributes of the thread. +DWORD +pthread_getw32threadid_np (pthread_t thread) + + Returns the win32 thread ID that the POSIX + thread "thread" is running as. + + Only valid when the library is built where + ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) + and otherwise returns 0. + int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind) @@ -124,7 +134,7 @@ [EINVAL] The value specified by interval is invalid. int -pthread_num_processors_np +pthread_num_processors_np (void) This routine (found on HPUX systems) returns the number of processors in the system. This implementation actually returns the number of diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/WinCE-PORT pthreads/WinCE-PORT --- pthreads-w32-2-8-0-release/WinCE-PORT 2005-04-25 12:18:00.000000000 +1000 +++ pthreads/WinCE-PORT 2007-01-07 13:40:00.000000000 +1100 @@ -3,7 +3,12 @@ completely rewritten since (2005-04-25), having been progressively broken more and more by changes to the library. All of the semaphore routines implemented for W9x/WNT/2000 and up should now also work for -WinCE. Also, pthread_mutex_timedlock should now work. [RPJ] +WinCE. Also, pthread_mutex_timedlock should now work. + +Additional WinCE updates have been applied since this as well. Check the +ChangeLog file and search for WINCE for example. (2007-01-07) + +[RPJ] ---- diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/config.h pthreads/config.h --- pthreads-w32-2-8-0-release/config.h 2005-04-25 12:18:00.000000000 +1000 +++ pthreads/config.h 2007-05-15 23:46:42.000000000 +1000 @@ -100,7 +100,7 @@ #define NEED_ERRNO #define NEED_CALLOC #define NEED_FTIME -//#define NEED_SEM +/* #define NEED_SEM */ #define NEED_UNICODE_CONSTS #define NEED_PROCESS_AFFINITY_MASK #endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/context.h pthreads/context.h --- pthreads-w32-2-8-0-release/context.h 1970-01-01 10:00:00.000000000 +1000 +++ pthreads/context.h 2007-01-07 00:44:40.000000000 +1100 @@ -0,0 +1,74 @@ +/* + * context.h + * + * Description: + * POSIX thread macros related to thread cancellation. + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: address@hidden + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef PTW32_CONTEXT_H +#define PTW32_CONTEXT_H + +#undef PTW32_PROGCTR + +#if defined(_M_IX86) || defined(_X86_) +#define PTW32_PROGCTR(Context) ((Context).Eip) +#endif + +#if defined (_M_IA64) || defined(_IA64) +#define PTW32_PROGCTR(Context) ((Context).StIIP) +#endif + +#if defined(_MIPS_) || defined(MIPS) +#define PTW32_PROGCTR(Context) ((Context).Fir) +#endif + +#if defined(_ALPHA_) +#define PTW32_PROGCTR(Context) ((Context).Fir) +#endif + +#if defined(_PPC_) +#define PTW32_PROGCTR(Context) ((Context).Iar) +#endif + +#if defined(_AMD64_) || defined(__amd64__) +#define PTW32_PROGCTR(Context) ((Context).Rip) +#endif + +#if defined(_ARM_) || defined(ARM) +#define PTW32_PROGCTR(Context) ((Context).Pc) +#endif + +#if !defined(PTW32_PROGCTR) +#error Module contains CPU-specific code; modify and recompile. +#endif + +#endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/create.c pthreads/create.c --- pthreads-w32-2-8-0-release/create.c 2005-05-06 17:31:31.000000000 +1000 +++ pthreads/create.c 2007-01-07 00:44:40.000000000 +1100 @@ -37,7 +37,7 @@ #include "pthread.h" #include "implement.h" -#ifndef _UWIN +#if ! defined(_UWIN) && ! defined(WINCE) #include #endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/errno.c pthreads/errno.c --- pthreads-w32-2-8-0-release/errno.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/errno.c 2007-11-23 01:14:58.000000000 +1100 @@ -74,7 +74,7 @@ pthread_t self; int *result; - if ((self = pthread_self ()) == NULL) + if ((self = pthread_self ()).p == NULL) { /* * Yikes! unable to allocate a thread! @@ -84,7 +84,7 @@ } else { - result = &(self->ptErrno); + result = (int *)(&self.p->exitStatus); } return (result); diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/exit.c pthreads/exit.c --- pthreads-w32-2-8-0-release/exit.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/exit.c 2007-01-07 00:44:40.000000000 +1100 @@ -37,7 +37,7 @@ #include "pthread.h" #include "implement.h" -#ifndef _UWIN +#if ! defined(_UWIN) && ! defined(WINCE) # include #endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/global.c pthreads/global.c --- pthreads-w32-2-8-0-release/global.c 2005-04-28 14:41:26.000000000 +1000 +++ pthreads/global.c 2010-02-16 01:13:58.000000000 +1100 @@ -49,7 +49,7 @@ int ptw32_concurrency = 0; -/* What features have been auto-detaected */ +/* What features have been auto-detected */ int ptw32_features = 0; BOOL ptw32_smp_system = PTW32_TRUE; /* Safer if assumed true initially. */ diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/implement.h pthreads/implement.h --- pthreads-w32-2-8-0-release/implement.h 2005-06-03 18:36:27.000000000 +1000 +++ pthreads/implement.h 2010-02-16 01:13:58.000000000 +1100 @@ -151,6 +151,9 @@ int implicit:1; void *keys; void *nextAssoc; +#ifdef _POSIX_CXX09_EXTENSIONS + int refs; /* C++ Thread Support Library extension */ +#endif }; @@ -566,6 +569,7 @@ int ptw32_cond_check_need_init (pthread_cond_t * cond); int ptw32_mutex_check_need_init (pthread_mutex_t * mutex); int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock); + int ptw32_spinlock_check_need_init (pthread_spinlock_t * spinlock); PTW32_INTERLOCKED_LONG WINAPI ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location, @@ -658,7 +662,9 @@ # endif # endif #else -# include +# ifndef WINCE +# include +# endif #endif @@ -667,7 +673,21 @@ * See ptw32_InterlockedCompareExchange.c */ #ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE -#define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_interlocked_compare_exchange +# ifdef _WIN64 + /* + * InterlockedCompareExchange is an intrinsic function in Win64. + */ +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# else + /* + * The routine pthread_win32_process_attach_np() in pthread_win32_attach_detach_np.c + * checks at runtime that InterlockedCompareExchange is supported within + * KERNEL32.DLL (or COREDLL.DLL for WinCE). This allows the same + * dll to run on all Win32 versions from Win95 onwards. Not sure if this + * is required for WinCE, but should work just the same anyway. + */ +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_interlocked_compare_exchange +# endif #endif #ifndef PTW32_INTERLOCKED_EXCHANGE diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/manual/ChangeLog pthreads/manual/ChangeLog --- pthreads-w32-2-8-0-release/manual/ChangeLog 2005-05-06 12:29:12.000000000 +1000 +++ pthreads/manual/ChangeLog 2008-06-30 22:43:42.000000000 +1000 @@ -1,3 +1,7 @@ +2008-06-30 Ross Johnson + + pthread_setschedparam.html: Fix "see also" links. + 2005-05-06 Ross Johnson * PortabilityIssues.html: Was nonPortableIssues.html. diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/manual/pthread_setschedparam.html pthreads/manual/pthread_setschedparam.html --- pthreads-w32-2-8-0-release/manual/pthread_setschedparam.html 2005-06-14 14:02:05.000000000 +1000 +++ pthreads/manual/pthread_setschedparam.html 2008-06-30 22:43:42.000000000 +1000 @@ -3,9 +3,10 @@ PTHREAD_SETSCHEDPARAM(3) manual page - + - + + @@ -86,8 +87,8 @@

sched_setscheduler(2) , sched_getscheduler(2) , sched_getparam(2) , -pthread_attr_setschedpolicy(3) -, pthread_attr_setschedparam(3) +pthread_attr_setschedpolicy(3) +, pthread_attr_setschedparam(3) .


diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/mutex.c pthreads/mutex.c --- pthreads-w32-2-8-0-release/mutex.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/mutex.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef _UWIN +#if ! defined(_UWIN) && ! defined(WINCE) # include #endif #ifndef NEED_FTIME diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/need_errno.h pthreads/need_errno.h --- pthreads-w32-2-8-0-release/need_errno.h 2000-08-14 13:43:09.000000000 +1000 +++ pthreads/need_errno.h 2007-11-23 01:14:58.000000000 +1100 @@ -59,11 +59,21 @@ #endif #endif +/* declare reference to errno */ +#ifndef PTW32_STATIC_LIB +# ifdef PTW32_BUILD +# define PTW32_DLLPORT __declspec (dllexport) +# else +# define PTW32_DLLPORT __declspec (dllimport) +# endif +#else +# define PTW32_DLLPORT +#endif /* declare reference to errno */ #if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC) -_CRTIMP extern int * __cdecl _errno(void); +PTW32_DLLPORT int * __cdecl _errno(void); #define errno (*_errno()) #else /* ndef _MT && ndef _MD && ndef _DLL */ _CRTIMP extern int errno; diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread.h pthreads/pthread.h --- pthreads-w32-2-8-0-release/pthread.h 2006-01-25 00:59:57.000000000 +1100 +++ pthreads/pthread.h 2009-03-04 08:43:47.000000000 +1100 @@ -37,8 +37,8 @@ * See the README file for an explanation of the pthreads-win32 version * numbering scheme and how the DLL is named etc. */ -#define PTW32_VERSION 2,8,0,0 -#define PTW32_VERSION_STRING "2, 8, 0, 0\0" +#define PTW32_VERSION 2,9,0,0 +#define PTW32_VERSION_STRING "2, 9, 0, 0\0" /* There are three implementations of cancel cleanup. * Note that pthread.h is included in both application @@ -104,7 +104,7 @@ #define PTW32_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) #define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */ #endif @@ -305,7 +305,7 @@ #ifndef HAVE_STRUCT_TIMESPEC #define HAVE_STRUCT_TIMESPEC 1 struct timespec { - long tv_sec; + time_t tv_sec; long tv_nsec; }; #endif /* HAVE_STRUCT_TIMESPEC */ @@ -899,13 +899,13 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, int *); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, int inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, int * inheritsched); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, @@ -984,7 +984,7 @@ int pshared); PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); /* * Barrier Attribute Functions @@ -1184,6 +1184,10 @@ * Returns the Win32 HANDLE for the POSIX thread. */ PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); +/* + * Returns the win32 thread ID for POSIX thread. + */ +PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); /* @@ -1245,13 +1249,19 @@ ( strcpy( (_buf), ctime( (_clock) ) ), \ (_buf) ) +/* + * gmtime(tm) and localtime(tm) return 0 if tm represents + * a time prior to 1/1/1970. + */ #define gmtime_r( _clock, _result ) \ - ( *(_result) = *gmtime( (_clock) ), \ - (_result) ) + ( gmtime( (_clock) ) \ + ? (*(_result) = *gmtime( (_clock) ), (_result) ) \ + : (0) ) #define localtime_r( _clock, _result ) \ - ( *(_result) = *localtime( (_clock) ), \ - (_result) ) + ( localtime( (_clock) ) \ + ? (*(_result) = *localtime( (_clock) ), (_result) ) \ + : (0) ) #define rand_r( _seed ) \ ( _seed == _seed? rand() : rand() ) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_attr_getdetachstate.c pthreads/pthread_attr_getdetachstate.c --- pthreads-w32-2-8-0-release/pthread_attr_getdetachstate.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_attr_getdetachstate.c 2008-06-06 10:23:20.000000000 +1000 @@ -78,7 +78,6 @@ { if (ptw32_is_attr (attr) != 0 || detachstate == NULL) { - *detachstate = PTHREAD_CREATE_DETACHED; return EINVAL; } diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_attr_getinheritsched.c pthreads/pthread_attr_getinheritsched.c --- pthreads-w32-2-8-0-release/pthread_attr_getinheritsched.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_attr_getinheritsched.c 2009-03-04 08:43:47.000000000 +1100 @@ -39,7 +39,7 @@ #include "sched.h" int -pthread_attr_getinheritsched (pthread_attr_t * attr, int *inheritsched) +pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched) { if (ptw32_is_attr (attr) != 0 || inheritsched == NULL) { diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_attr_getschedpolicy.c pthreads/pthread_attr_getschedpolicy.c --- pthreads-w32-2-8-0-release/pthread_attr_getschedpolicy.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_attr_getschedpolicy.c 2009-03-04 08:43:47.000000000 +1100 @@ -39,7 +39,7 @@ #include "sched.h" int -pthread_attr_getschedpolicy (pthread_attr_t * attr, int *policy) +pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy) { if (ptw32_is_attr (attr) != 0 || policy == NULL) { diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_cancel.c pthreads/pthread_cancel.c --- pthreads-w32-2-8-0-release/pthread_cancel.c 2006-01-25 00:59:57.000000000 +1100 +++ pthreads/pthread_cancel.c 2007-01-05 12:19:56.000000000 +1100 @@ -36,34 +36,7 @@ #include "pthread.h" #include "implement.h" - -#if defined(_M_IX86) || defined(_X86_) -#define PTW32_PROGCTR(Context) ((Context).Eip) -#endif - -#if defined (_M_IA64) -#define PTW32_PROGCTR(Context) ((Context).StIIP) -#endif - -#if defined(_MIPS_) -#define PTW32_PROGCTR(Context) ((Context).Fir) -#endif - -#if defined(_ALPHA_) -#define PTW32_PROGCTR(Context) ((Context).Fir) -#endif - -#if defined(_PPC_) -#define PTW32_PROGCTR(Context) ((Context).Iar) -#endif - -#if defined(_AMD64_) -#define PTW32_PROGCTR(Context) ((Context).Rip) -#endif - -#if !defined(PTW32_PROGCTR) -#error Module contains CPU-specific code; modify and recompile. -#endif +#include "context.h" static void ptw32_cancel_self (void) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_cond_destroy.c pthreads/pthread_cond_destroy.c --- pthreads-w32-2-8-0-release/pthread_cond_destroy.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_cond_destroy.c 2007-01-07 00:44:40.000000000 +1100 @@ -135,21 +135,28 @@ * all already signaled waiters to let them retract their * waiter status - SEE NOTE 1 ABOVE!!! */ - if (sem_wait (&(cv->semBlockLock)) != 0) + if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */ { - return errno; - } - - /* - * !TRY! lock mtxUnblockLock; try will detect busy condition - * and will not cause a deadlock with respect to concurrent - * signal/broadcast. - */ - if ((result = pthread_mutex_trylock (&(cv->mtxUnblockLock))) != 0) - { - (void) sem_post (&(cv->semBlockLock)); - return result; + result = errno; } + else + { + /* + * !TRY! lock mtxUnblockLock; try will detect busy condition + * and will not cause a deadlock with respect to concurrent + * signal/broadcast. + */ + if ((result = pthread_mutex_trylock (&(cv->mtxUnblockLock))) != 0) + { + (void) sem_post (&(cv->semBlockLock)); + } + } + + if (result != 0) + { + LeaveCriticalSection (&ptw32_cond_list_lock); + return result; + } /* * Check whether cv is still busy (still has waiters) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_detach.c pthreads/pthread_detach.c --- pthreads-w32-2-8-0-release/pthread_detach.c 2005-05-16 12:36:48.000000000 +1000 +++ pthreads/pthread_detach.c 2007-01-07 00:44:40.000000000 +1100 @@ -42,7 +42,9 @@ * Not needed yet, but defining it should indicate clashes with build target * environment that should be fixed. */ -#include +#ifndef WINCE +# include +#endif int diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_exit.c pthreads/pthread_exit.c --- pthreads-w32-2-8-0-release/pthread_exit.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_exit.c 2007-05-15 23:46:42.000000000 +1000 @@ -38,7 +38,7 @@ #include "pthread.h" #include "implement.h" #ifndef _UWIN -//# include +/*# include */ #endif void diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_getw32threadhandle_np.c pthreads/pthread_getw32threadhandle_np.c --- pthreads-w32-2-8-0-release/pthread_getw32threadhandle_np.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_getw32threadhandle_np.c 2007-05-27 00:57:20.000000000 +1000 @@ -51,3 +51,15 @@ { return ((ptw32_thread_t *)thread.p)->threadH; } + +/* + * pthread_getw32threadid_np() + * + * Returns the win32 thread id that the POSIX + * thread "thread" is running as. + */ +DWORD +pthread_getw32threadid_np (pthread_t thread) +{ + return ((ptw32_thread_t *)thread.p)->thread; +} diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_join.c pthreads/pthread_join.c --- pthreads-w32-2-8-0-release/pthread_join.c 2005-05-16 01:28:27.000000000 +1000 +++ pthreads/pthread_join.c 2010-02-16 01:13:58.000000000 +1100 @@ -42,7 +42,9 @@ * Not needed yet, but defining it should indicate clashes with build target * environment that should be fixed. */ -#include +#ifndef WINCE +# include +#endif int @@ -102,7 +104,7 @@ LeaveCriticalSection (&ptw32_thread_reuse_lock); - if (result == 0) + if (0 == result) { /* * The target thread is joinable and can't be reused before we join it. @@ -122,7 +124,7 @@ /* * Pthread_join is a cancelation point. * If we are canceled then our target thread must not be - * detached (destroyed). This is guarranteed because + * detached (destroyed) by us. This is guarranteed because * pthreadCancelableWait will not return if we * are canceled. */ diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_key_create.c pthreads/pthread_key_create.c --- pthreads-w32-2-8-0-release/pthread_key_create.c 2005-05-06 17:31:32.000000000 +1000 +++ pthreads/pthread_key_create.c 2007-11-23 01:14:58.000000000 +1100 @@ -93,7 +93,7 @@ { /* * Have to manage associations between thread and key; - * Therefore, need a lock that allows multiple threads + * Therefore, need a lock that allows competing threads * to gain exclusive access to the key->threads list. * * The mutex will only be created when it is first locked. diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_key_delete.c pthreads/pthread_key_delete.c --- pthreads-w32-2-8-0-release/pthread_key_delete.c 2005-05-09 02:52:51.000000000 +1000 +++ pthreads/pthread_key_delete.c 2007-11-23 01:14:58.000000000 +1100 @@ -119,7 +119,7 @@ /* A thread could be holding the keyLock */ while (EBUSY == pthread_mutex_destroy (&(key->keyLock))) { - Sleep(1); // Ugly. + Sleep(0); /* Ugly */ } } diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_kill.c pthreads/pthread_kill.c --- pthreads-w32-2-8-0-release/pthread_kill.c 2005-06-03 18:36:28.000000000 +1000 +++ pthreads/pthread_kill.c 2007-01-07 00:44:40.000000000 +1100 @@ -41,7 +41,9 @@ * Not needed yet, but defining it should indicate clashes with build target * environment that should be fixed. */ -#include +#ifndef WINCE +# include +#endif int pthread_kill (pthread_t thread, int sig) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_mutex_lock.c pthreads/pthread_mutex_lock.c --- pthreads-w32-2-8-0-release/pthread_mutex_lock.c 2005-05-09 02:52:51.000000000 +1000 +++ pthreads/pthread_mutex_lock.c 2007-05-15 23:46:42.000000000 +1000 @@ -35,7 +35,7 @@ */ #ifndef _UWIN -//# include +/*# include */ #endif #include "pthread.h" #include "implement.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_mutexattr_gettype.c pthreads/pthread_mutexattr_gettype.c --- pthreads-w32-2-8-0-release/pthread_mutexattr_gettype.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_mutexattr_gettype.c 2009-03-04 08:43:47.000000000 +1100 @@ -39,7 +39,7 @@ int -pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind) +pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind) { int result = 0; diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_destroy.c pthreads/pthread_rwlock_destroy.c --- pthreads-w32-2-8-0-release/pthread_rwlock_destroy.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_destroy.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_init.c pthreads/pthread_rwlock_init.c --- pthreads-w32-2-8-0-release/pthread_rwlock_init.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_init.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_rdlock.c pthreads/pthread_rwlock_rdlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_rdlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_rdlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_timedrdlock.c pthreads/pthread_rwlock_timedrdlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_timedrdlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_timedrdlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_timedwrlock.c pthreads/pthread_rwlock_timedwrlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_timedwrlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_timedwrlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_tryrdlock.c pthreads/pthread_rwlock_tryrdlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_tryrdlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_tryrdlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_trywrlock.c pthreads/pthread_rwlock_trywrlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_trywrlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_trywrlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_unlock.c pthreads/pthread_rwlock_unlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_unlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_unlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlock_wrlock.c pthreads/pthread_rwlock_wrlock.c --- pthreads-w32-2-8-0-release/pthread_rwlock_wrlock.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlock_wrlock.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlockattr_destroy.c pthreads/pthread_rwlockattr_destroy.c --- pthreads-w32-2-8-0-release/pthread_rwlockattr_destroy.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlockattr_destroy.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlockattr_getpshared.c pthreads/pthread_rwlockattr_getpshared.c --- pthreads-w32-2-8-0-release/pthread_rwlockattr_getpshared.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlockattr_getpshared.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlockattr_init.c pthreads/pthread_rwlockattr_init.c --- pthreads-w32-2-8-0-release/pthread_rwlockattr_init.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlockattr_init.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_rwlockattr_setpshared.c pthreads/pthread_rwlockattr_setpshared.c --- pthreads-w32-2-8-0-release/pthread_rwlockattr_setpshared.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_rwlockattr_setpshared.c 2007-01-07 00:44:40.000000000 +1100 @@ -34,7 +34,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include "pthread.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_setspecific.c pthreads/pthread_setspecific.c --- pthreads-w32-2-8-0-release/pthread_setspecific.c 2005-05-09 02:52:51.000000000 +1000 +++ pthreads/pthread_setspecific.c 2007-11-23 01:14:58.000000000 +1100 @@ -155,13 +155,13 @@ (void) pthread_mutex_unlock(&(key->keyLock)); } - if (result == 0) - { - if (!TlsSetValue (key->key, (LPVOID) value)) - { - result = EAGAIN; - } - } + if (result == 0) + { + if (!TlsSetValue (key->key, (LPVOID) value)) + { + result = EAGAIN; + } + } } return (result); diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_testcancel.c pthreads/pthread_testcancel.c --- pthreads-w32-2-8-0-release/pthread_testcancel.c 2005-01-02 01:36:17.000000000 +1100 +++ pthreads/pthread_testcancel.c 2008-06-07 13:46:52.000000000 +1000 @@ -92,10 +92,10 @@ { ResetEvent(sp->cancelEvent); sp->state = PThreadStateCanceling; - (void) pthread_mutex_unlock (&sp->cancelLock); sp->cancelState = PTHREAD_CANCEL_DISABLE; (void) pthread_mutex_unlock (&sp->cancelLock); ptw32_throw (PTW32_EPS_CANCEL); + /* Never returns here */ } (void) pthread_mutex_unlock (&sp->cancelLock); diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/pthread_win32_attach_detach_np.c pthreads/pthread_win32_attach_detach_np.c --- pthreads-w32-2-8-0-release/pthread_win32_attach_detach_np.c 2006-12-22 13:36:40.000000000 +1100 +++ pthreads/pthread_win32_attach_detach_np.c 2010-02-16 01:13:58.000000000 +1100 @@ -91,6 +91,15 @@ #endif +#ifdef _WIN64 + +/* + * InterlockedCompareExchange routine in WIN64 is an intrinsic function. + * See PTW32_INTERLOCKED_COMPARE_EXCHANGE implement.h + */ + +#else + #ifdef WINCE /* @@ -144,6 +153,8 @@ ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; } +#endif + /* * Load QUSEREX.DLL and try to get address of QueueUserAPCEx */ @@ -272,7 +283,7 @@ */ ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. + if (sp != NULL) { ptw32_callUserDestroyRoutines (sp->ptHandle); @@ -280,10 +291,16 @@ sp->state = PThreadStateLast; /* * If the thread is joinable at this point then it MUST be joined - * or detached explicitly by the application. + * or detached explicitly by the application because it's + * detachState cannot be changed from this point on. */ (void) pthread_mutex_unlock (&sp->cancelLock); + /* + * No race condition here because detachState will not be changed + * elsewhere now that thread state is PThreadStateLast (set above + * behind mutex). + */ if (sp->detachState == PTHREAD_CREATE_DETACHED) { ptw32_threadDestroy (sp->ptHandle); diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ptw32_InterlockedCompareExchange.c pthreads/ptw32_InterlockedCompareExchange.c --- pthreads-w32-2-8-0-release/ptw32_InterlockedCompareExchange.c 2005-04-26 12:41:11.000000000 +1000 +++ pthreads/ptw32_InterlockedCompareExchange.c 2009-03-16 23:14:23.000000000 +1100 @@ -35,6 +35,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#ifndef _WIN64 + #include "pthread.h" #include "implement.h" @@ -138,7 +140,7 @@ * unsupported processor or compiler. */ - result = 0; +#error Unsupported platform or compiler! #endif @@ -250,8 +252,8 @@ * FIXME! Need memory barriers for the MOV+CMPXCHG combo? * * Tests show that this routine has almost identical timing - * to Win32's InterlockedExchange(), which is much faster than - * using the an inlined 'xchg' instruction, so it's probably + * to Win32's InterlockedExchange(), and is much faster than + * using an inlined 'xchg' instruction, so Win32 is probably * doing something similar to this (on UP systems). */ __asm__ __volatile__ @@ -273,7 +275,7 @@ * unsupported processor or compiler. */ - result = 0; +#error Unsupported platform or compiler! #endif @@ -301,3 +303,5 @@ #endif #endif + +#endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ptw32_MCS_lock.c pthreads/ptw32_MCS_lock.c --- pthreads-w32-2-8-0-release/ptw32_MCS_lock.c 2006-12-22 13:36:40.000000000 +1100 +++ pthreads/ptw32_MCS_lock.c 2007-01-07 00:44:40.000000000 +1100 @@ -89,8 +89,8 @@ * } */ -#include "implement.h" #include "pthread.h" +#include "implement.h" /* * ptw32_mcs_flag_set -- notify another thread about an event. diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ptw32_relmillisecs.c pthreads/ptw32_relmillisecs.c --- pthreads-w32-2-8-0-release/ptw32_relmillisecs.c 2005-06-03 18:36:28.000000000 +1000 +++ pthreads/ptw32_relmillisecs.c 2007-05-15 23:46:42.000000000 +1000 @@ -35,7 +35,7 @@ */ #ifndef _UWIN -//#include +/*#include */ #endif #include "pthread.h" #include "implement.h" diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ptw32_semwait.c pthreads/ptw32_semwait.c --- pthreads-w32-2-8-0-release/ptw32_semwait.c 2005-04-26 00:42:43.000000000 +1000 +++ pthreads/ptw32_semwait.c 2007-05-15 23:46:42.000000000 +1000 @@ -35,7 +35,7 @@ */ #ifndef _UWIN -//# include +/*# include */ #endif #include "pthread.h" #include "implement.h" @@ -77,8 +77,18 @@ { if ((result = pthread_mutex_lock (&s->lock)) == 0) { - int v = --s->value; + int v; + /* See sem_destroy.c + */ + if (*sem == NULL) + { + (void) pthread_mutex_unlock (&s->lock); + errno = EINVAL; + return -1; + } + + v = --s->value; (void) pthread_mutex_unlock (&s->lock); if (v < 0) @@ -89,6 +99,13 @@ #ifdef NEED_SEM if (pthread_mutex_lock (&s->lock) == 0) { + if (*sem == NULL) + { + (void) pthread_mutex_unlock (&s->lock); + errno = EINVAL; + return -1; + } + if (s->leftToUnblock > 0) { --s->leftToUnblock; diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/ptw32_throw.c pthreads/ptw32_throw.c --- pthreads-w32-2-8-0-release/ptw32_throw.c 2005-05-16 01:28:27.000000000 +1000 +++ pthreads/ptw32_throw.c 2008-06-06 10:23:20.000000000 +1000 @@ -73,6 +73,7 @@ * explicit thread exit here after cleaning up POSIX * residue (i.e. cleanup handlers, POSIX thread handle etc). */ +#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) unsigned exitCode = 0; switch (exception) @@ -81,9 +82,13 @@ exitCode = (unsigned) PTHREAD_CANCELED; break; case PTW32_EPS_EXIT: - exitCode = (unsigned) sp->exitStatus;; + if (NULL != sp) + { + exitCode = (unsigned) sp->exitStatus; + } break; } +#endif #if defined(PTW32_STATIC_LIB) diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/sched.h pthreads/sched.h --- pthreads-w32-2-8-0-release/sched.h 2005-04-01 10:55:21.000000000 +1000 +++ pthreads/sched.h 2009-03-04 08:43:47.000000000 +1100 @@ -60,7 +60,7 @@ #define PTW32_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) #define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */ #endif @@ -114,12 +114,14 @@ #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #if defined(__MINGW32__) || defined(_UWIN) -#if PTW32_LEVEL >= PTW32_LEVEL_MAX +# if PTW32_LEVEL >= PTW32_LEVEL_MAX /* For pid_t */ # include /* Required by Unix 98 */ # include -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +# else + typedef int pid_t; +# endif #else typedef int pid_t; #endif diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/tests/ChangeLog pthreads/tests/ChangeLog --- pthreads-w32-2-8-0-release/tests/ChangeLog 2005-06-12 10:28:03.000000000 +1000 +++ pthreads/tests/ChangeLog 2007-01-05 12:19:56.000000000 +1100 @@ -1,3 +1,8 @@ +2007-01-04 Ross Johnson + + * context1.c: Include context.h from library sources and remove + x86 dependence in main(). + 2005-06-12 Ross Johnson * stress1.c (millisecondsFromNow): Remove limit 0 <= millisecs < 1000; diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/tests/Makefile pthreads/tests/Makefile --- pthreads-w32-2-8-0-release/tests/Makefile 2006-12-22 13:36:41.000000000 +1100 +++ pthreads/tests/Makefile 2007-01-07 00:44:40.000000000 +1100 @@ -67,7 +67,7 @@ CPLIB = $(VCLIB) CPDLL = $(VCDLL) -CFLAGS= $(OPTIM) /W3 /WX /MD /nologo /Yd /Zi +CFLAGS= $(OPTIM) /W3 /WX /MD /nologo /Zi LFLAGS= /INCREMENTAL:NO INCLUDES=-I. BUILD_DIR=.. diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/tests/context1.c pthreads/tests/context1.c --- pthreads-w32-2-8-0-release/tests/context1.c 2005-01-02 01:36:18.000000000 +1100 +++ pthreads/tests/context1.c 2007-01-05 12:19:56.000000000 +1100 @@ -75,6 +75,7 @@ #include "test.h" #include "../implement.h" +#include "../context.h" static int washere = 0; @@ -122,10 +123,7 @@ context.ContextFlags = CONTEXT_CONTROL; GetThreadContext(hThread, &context); - /* - *_x86 only!!! - */ - context.Eip = (DWORD) anotherEnding; + PTW32_PROGCTR (context) = (DWORD_PTR) anotherEnding; SetThreadContext(hThread, &context); ResumeThread(hThread); } diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/tests/once3.c pthreads/tests/once3.c --- pthreads-w32-2-8-0-release/tests/once3.c 2006-12-22 13:36:41.000000000 +1100 +++ pthreads/tests/once3.c 2007-01-05 12:19:56.000000000 +1100 @@ -34,7 +34,7 @@ * -------------------------------------------------------------------------- * * Create several pthread_once objects and channel several threads - * through each. Make the init_routine cancelable and cancel them with + * through each. Make the init_routine cancelable and cancel them * waiters waiting. * * Depends on API functions: @@ -45,8 +45,6 @@ * pthread_once() */ -#define ASSERT_TRACE - #include "test.h" #define NUM_THREADS 100 /* Targeting each once control */ @@ -68,7 +66,6 @@ { EnterCriticalSection(&numOnce.cs); numOnce.i++; - assert(numOnce.i > 0); LeaveCriticalSection(&numOnce.cs); /* Simulate slow once routine so that following threads pile up behind it */ Sleep(10); @@ -81,11 +78,11 @@ { /* * Cancel every thread. These threads are deferred cancelable only, so - * only the thread performing the once routine (my_func) will see it (there are + * only the thread performing the init_routine will see it (there are * no other cancelation points here). The result will be that every thread - * eventually cancels only when it becomes the new once thread. + * eventually cancels only when it becomes the new initter. */ - assert(pthread_cancel(pthread_self()) == 0); + pthread_cancel(pthread_self()); assert(pthread_once(&once[(int) arg], myfunc) == 0); EnterCriticalSection(&numThreads.cs); numThreads.i++; diff -urN -x '*CVS*' pthreads-w32-2-8-0-release/tests/semaphore5.c pthreads/tests/semaphore5.c --- pthreads-w32-2-8-0-release/tests/semaphore5.c 1970-01-01 10:00:00.000000000 +1000 +++ pthreads/tests/semaphore5.c 2006-12-23 09:47:33.000000000 +1100 @@ -0,0 +1,103 @@ +/* + * File: semaphore5.c + * + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: address@hidden + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * -------------------------------------------------------------------------- + * + * Test Synopsis: Verify sem_destroy EBUSY race avoidance + * - + * + * Test Method (Validation or Falsification): + * - Validation + * + * Requirements Tested: + * - + * + * Features Tested: + * - + * + * Cases Tested: + * - + * + * Description: + * - + * + * Environment: + * - + * + * Input: + * - None. + * + * Output: + * - File name, Line number, and failed expression on failure. + * - No output on success. + * + * Assumptions: + * - + * + * Pass Criteria: + * - Process returns zero exit status. + * + * Fail Criteria: + * - Process returns non-zero exit status. + */ + +// #define ASSERT_TRACE + +#include "test.h" + +void * +thr(void * arg) +{ + assert(sem_post((sem_t *)arg) == 0); + + return 0; +} + + +int +main() +{ + pthread_t t; + sem_t s; + + assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); + assert(pthread_create(&t, NULL, thr, (void *)&s) == 0); + + assert(sem_wait(&s) == 0); + assert(sem_destroy(&s) == 0); + + assert(pthread_join(t, NULL) == 0); + + return 0; +} +