[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

aCaB acab at clamav.net
Sun Apr 4 01:08:44 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit b772821fa2f450bd7f786ef5459442cef810d067
Author: aCaB <acab at clamav.net>
Date:   Thu Oct 29 23:39:24 2009 +0100

    win32: upgrade pthreads to CVSHEAD

diff --git a/ChangeLog b/ChangeLog
index 1be0de2..d23e0b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Oct 29 23:42:57 CET 2009 (acab)
+-----------------------------------
+ * win32/3rdparty/pthreads: upgrade to CVS HEAD
+
 Thu Oct 29 17:27:40 CET 2009 (acab)
 -----------------------------------
  * win32: don't use . or .. in UNC names
diff --git a/win32/3rdparty/pthreads/ANNOUNCE b/win32/3rdparty/pthreads/ANNOUNCE
index 97d94e7..d15d18a 100644
--- a/win32/3rdparty/pthreads/ANNOUNCE
+++ b/win32/3rdparty/pthreads/ANNOUNCE
@@ -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 --git a/win32/3rdparty/pthreads/CONTRIBUTORS b/win32/3rdparty/pthreads/CONTRIBUTORS
index e5b7325..0d650e1 100644
--- a/win32/3rdparty/pthreads/CONTRIBUTORS
+++ b/win32/3rdparty/pthreads/CONTRIBUTORS
@@ -114,6 +114,7 @@ Piet van Bruggen	pietvb at newbridges dot nl
 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 --git a/win32/3rdparty/pthreads/ChangeLog b/win32/3rdparty/pthreads/ChangeLog
index b85d9f9..7bd1774 100644
--- a/win32/3rdparty/pthreads/ChangeLog
+++ b/win32/3rdparty/pthreads/ChangeLog
@@ -1,4 +1,105 @@
-2006-12-20  Ross Johnson <ross.johnson at homemail.com.au>
+2009-03-03  Stephan O'Farrill <stephan dot ofarrill at gmail dot com>
+
+	* 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  <RKindred at SwRI dot edu>
+
+        * 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  <seppig_relay at gmx dot de>
+
+        * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate):
+        Remove potential and superfluous null pointer assignment.
+
+2007-11-22  Ivan Pizhenko  <ivanp4 at ua dot fm>
+
+        * 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  <mr at marcelruff dot info>
+
+        * errno.c (_errno): Fix test for pthread_self() success.
+        * need_errno.h: Remove unintentional line wrap from #if line.
+
+2007-07-14  Mike Romanchuk  <mromanchuk at empirix dot com>
+
+        * pthread.h (timespec): Fix tv_sec type.
+
+2007-01-07  Sinan Kaya <sinan.kaya at siemens dot com>
+
+        * need_errno.h: Fix declaration of _errno - the local version of
+        _errno() is used, e.g. by WinCE.
+
+2007-01-06  Ross Johnson <ross.johnson at homemail dot com dot au>
+
+        * 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 <mr at marcelruff dot info>
+
+        * 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 <rotenca at telvia dot it>
+
+        * 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 <eric dot berge at quantum dot com>
+
+        * pthread_cond_destroy.c: Add LeaveCriticalSection before returning
+        after errors.
+
+2007-01-04  Ross Johnson <ross.johnson at homemail dot com dot au>
+
+        * 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 <KSTREITH at ball dot com>
+
+        * implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64
+        support.
+        
+2006-12-20  Ross Johnson <ross.johnson at homemail dot com dot au>
 
         * sem_destroy.c: Fix the race involving invalidation of the sema;
         fix incorrect return of EBUSY resulting from the mutex trylock
diff --git a/win32/3rdparty/pthreads/FAQ b/win32/3rdparty/pthreads/FAQ
index 4f2d449..cb1786c 100644
--- a/win32/3rdparty/pthreads/FAQ
+++ b/win32/3rdparty/pthreads/FAQ
@@ -30,6 +30,9 @@ Q 9	Cancelation doesn't work for me, why?
 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 @@ This should not be a problem with recent versions of MinGW32.
 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 --git a/win32/3rdparty/pthreads/NEWS b/win32/3rdparty/pthreads/NEWS
index 18fe543..cc7e233 100644
--- a/win32/3rdparty/pthreads/NEWS
+++ b/win32/3rdparty/pthreads/NEWS
@@ -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 --git a/win32/3rdparty/pthreads/README.NONPORTABLE b/win32/3rdparty/pthreads/README.NONPORTABLE
index aa43297..192fef6 100644
--- a/win32/3rdparty/pthreads/README.NONPORTABLE
+++ b/win32/3rdparty/pthreads/README.NONPORTABLE
@@ -72,6 +72,16 @@ pthread_getw32threadhandle_np(pthread_t thread);
 	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 @@ pthread_delay_np (const struct timespec *interval);
         [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 --git a/win32/3rdparty/pthreads/WinCE-PORT b/win32/3rdparty/pthreads/WinCE-PORT
index f5981a9..7bcfdea 100644
--- a/win32/3rdparty/pthreads/WinCE-PORT
+++ b/win32/3rdparty/pthreads/WinCE-PORT
@@ -3,7 +3,12 @@ done by Tristan Savatier. The semaphore routines have been
 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 --git a/win32/3rdparty/pthreads/config.h b/win32/3rdparty/pthreads/config.h
index d6638df..84a672e 100644
--- a/win32/3rdparty/pthreads/config.h
+++ b/win32/3rdparty/pthreads/config.h
@@ -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 --git a/win32/3rdparty/pthreads/mutex.c b/win32/3rdparty/pthreads/context.h
similarity index 62%
copy from win32/3rdparty/pthreads/mutex.c
copy to win32/3rdparty/pthreads/context.h
index 2e60dab..871aa3f 100644
--- a/win32/3rdparty/pthreads/mutex.c
+++ b/win32/3rdparty/pthreads/context.h
@@ -1,8 +1,8 @@
 /*
- * mutex.c
+ * context.h
  *
  * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
+ * POSIX thread macros related to thread cancellation.
  *
  * --------------------------------------------------------------------------
  *
@@ -34,26 +34,41 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#ifndef _UWIN
-#   include <process.h>
-#endif
-#ifndef NEED_FTIME
-#include <sys/timeb.h>
-#endif
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "ptw32_mutex_check_need_init.c"
-#include "pthread_mutex_init.c"
-#include "pthread_mutex_destroy.c"
-#include "pthread_mutexattr_init.c"
-#include "pthread_mutexattr_destroy.c"
-#include "pthread_mutexattr_getpshared.c"
-#include "pthread_mutexattr_setpshared.c"
-#include "pthread_mutexattr_settype.c"
-#include "pthread_mutexattr_gettype.c"
-#include "pthread_mutex_lock.c"
-#include "pthread_mutex_timedlock.c"
-#include "pthread_mutex_unlock.c"
-#include "pthread_mutex_trylock.c"
+#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 --git a/win32/3rdparty/pthreads/create.c b/win32/3rdparty/pthreads/create.c
index 9e9388b..55b932a 100644
--- a/win32/3rdparty/pthreads/create.c
+++ b/win32/3rdparty/pthreads/create.c
@@ -37,7 +37,7 @@
 
 #include "pthread.h"
 #include "implement.h"
-#ifndef _UWIN
+#if ! defined(_UWIN) && ! defined(WINCE)
 #include <process.h>
 #endif
 
diff --git a/win32/3rdparty/pthreads/errno.c b/win32/3rdparty/pthreads/errno.c
index 9998bb8..78aa920 100644
--- a/win32/3rdparty/pthreads/errno.c
+++ b/win32/3rdparty/pthreads/errno.c
@@ -74,7 +74,7 @@ _errno (void)
   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 @@ _errno (void)
     }
   else
     {
-      result = &(self->ptErrno);
+      result = (int *)(&self.p->exitStatus);
     }
 
   return (result);
diff --git a/win32/3rdparty/pthreads/exit.c b/win32/3rdparty/pthreads/exit.c
index 7eb9671..94369d0 100644
--- a/win32/3rdparty/pthreads/exit.c
+++ b/win32/3rdparty/pthreads/exit.c
@@ -37,7 +37,7 @@
 
 #include "pthread.h"
 #include "implement.h"
-#ifndef _UWIN
+#if ! defined(_UWIN) && ! defined(WINCE)
 #   include <process.h>
 #endif
 
diff --git a/win32/3rdparty/pthreads/implement.h b/win32/3rdparty/pthreads/implement.h
index 3d96483..cf3c7f4 100644
--- a/win32/3rdparty/pthreads/implement.h
+++ b/win32/3rdparty/pthreads/implement.h
@@ -566,6 +566,7 @@ extern "C"
   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 +659,9 @@ extern "C"
 #       endif
 #   endif
 #else
-#   include <process.h>
+#   ifndef WINCE
+#       include <process.h>
+#   endif
 #endif
 
 
@@ -667,7 +670,21 @@ extern "C"
  * 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 --git a/win32/3rdparty/pthreads/manual/ChangeLog b/win32/3rdparty/pthreads/manual/ChangeLog
index c07cdd7..ae3c308 100644
--- a/win32/3rdparty/pthreads/manual/ChangeLog
+++ b/win32/3rdparty/pthreads/manual/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-30  Ross Johnson  <ross at callisto.canberra.edu.au>
+
+	pthread_setschedparam.html: Fix "see also" links.
+
 2005-05-06  Ross Johnson  <ross at callisto.canberra.edu.au>
 
 	* PortabilityIssues.html: Was nonPortableIssues.html.
diff --git a/win32/3rdparty/pthreads/manual/pthread_setschedparam.html b/win32/3rdparty/pthreads/manual/pthread_setschedparam.html
index 920c20b..8dbb9c4 100644
--- a/win32/3rdparty/pthreads/manual/pthread_setschedparam.html
+++ b/win32/3rdparty/pthreads/manual/pthread_setschedparam.html
@@ -3,9 +3,10 @@
 <HEAD>
 	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
 	<TITLE>PTHREAD_SETSCHEDPARAM(3) manual page</TITLE>
-	<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3  (Linux)">
+	<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4  (Linux)">
 	<META NAME="CREATED" CONTENT="20050504;18110100">
-	<META NAME="CHANGED" CONTENT="20050614;14012300">
+	<META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+	<META NAME="CHANGED" CONTENT="20080630;22330400">
 	<!-- manual page source format generated by PolyglotMan v3.2, -->
 	<!-- available at http://polyglotman.sourceforge.net/ -->
 </HEAD>
@@ -86,8 +87,8 @@ codes:
 <P><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B>(2)</A>
 , <A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(2)</A>
 , <A HREF="sched_getparam.html"><B>sched_getparam</B>(2)</A> ,
-<A HREF="pthread_attr_setschedpolicy.html"><B>pthread_attr_setschedpolicy</B>(3)</A>
-, <A HREF="pthread_attr_setschedparam.html"><B>pthread_attr_setschedparam</B>(3)</A>
+<A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B>(3)</A>
+, <A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B>(3)</A>
 . 
 </P>
 <HR>
diff --git a/win32/3rdparty/pthreads/mutex.c b/win32/3rdparty/pthreads/mutex.c
index 2e60dab..0b03a45 100644
--- a/win32/3rdparty/pthreads/mutex.c
+++ b/win32/3rdparty/pthreads/mutex.c
@@ -34,7 +34,7 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#ifndef _UWIN
+#if ! defined(_UWIN) && ! defined(WINCE)
 #   include <process.h>
 #endif
 #ifndef NEED_FTIME
diff --git a/win32/3rdparty/pthreads/need_errno.h b/win32/3rdparty/pthreads/need_errno.h
index 2609f8d..a28955a 100644
--- a/win32/3rdparty/pthreads/need_errno.h
+++ b/win32/3rdparty/pthreads/need_errno.h
@@ -59,11 +59,21 @@ extern "C" {
 #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 --git a/win32/3rdparty/pthreads/pthread.h b/win32/3rdparty/pthreads/pthread.h
index f3d2dac..0bd3413 100644
--- a/win32/3rdparty/pthreads/pthread.h
+++ b/win32/3rdparty/pthreads/pthread.h
@@ -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 @@ enum {
 #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_setschedparam (pthread_attr_t *attr,
 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 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t
                                           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 @@ PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *);
  * 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 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
         ( 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 --git a/win32/3rdparty/pthreads/pthread_attr_getdetachstate.c b/win32/3rdparty/pthreads/pthread_attr_getdetachstate.c
index 978f288..188533b 100644
--- a/win32/3rdparty/pthreads/pthread_attr_getdetachstate.c
+++ b/win32/3rdparty/pthreads/pthread_attr_getdetachstate.c
@@ -78,7 +78,6 @@ pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
 {
   if (ptw32_is_attr (attr) != 0 || detachstate == NULL)
     {
-      *detachstate = PTHREAD_CREATE_DETACHED;
       return EINVAL;
     }
 
diff --git a/win32/3rdparty/pthreads/pthread_attr_getinheritsched.c b/win32/3rdparty/pthreads/pthread_attr_getinheritsched.c
index 5085077..9c6885e 100644
--- a/win32/3rdparty/pthreads/pthread_attr_getinheritsched.c
+++ b/win32/3rdparty/pthreads/pthread_attr_getinheritsched.c
@@ -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 --git a/win32/3rdparty/pthreads/pthread_attr_getschedpolicy.c b/win32/3rdparty/pthreads/pthread_attr_getschedpolicy.c
index 04adbd5..94a257d 100644
--- a/win32/3rdparty/pthreads/pthread_attr_getschedpolicy.c
+++ b/win32/3rdparty/pthreads/pthread_attr_getschedpolicy.c
@@ -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 --git a/win32/3rdparty/pthreads/pthread_cancel.c b/win32/3rdparty/pthreads/pthread_cancel.c
index 1118977..7d519ee 100644
--- a/win32/3rdparty/pthreads/pthread_cancel.c
+++ b/win32/3rdparty/pthreads/pthread_cancel.c
@@ -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 --git a/win32/3rdparty/pthreads/pthread_cond_destroy.c b/win32/3rdparty/pthreads/pthread_cond_destroy.c
index 3d29ffc..53f7a53 100644
--- a/win32/3rdparty/pthreads/pthread_cond_destroy.c
+++ b/win32/3rdparty/pthreads/pthread_cond_destroy.c
@@ -135,21 +135,28 @@ pthread_cond_destroy (pthread_cond_t * cond)
        * 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;
+	  result = 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;
+      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 --git a/win32/3rdparty/pthreads/pthread_detach.c b/win32/3rdparty/pthreads/pthread_detach.c
index 00fb6ad..b110f2b 100644
--- a/win32/3rdparty/pthreads/pthread_detach.c
+++ b/win32/3rdparty/pthreads/pthread_detach.c
@@ -42,7 +42,9 @@
  * Not needed yet, but defining it should indicate clashes with build target
  * environment that should be fixed.
  */
-#include <signal.h>
+#ifndef WINCE
+#  include <signal.h>
+#endif
 
 
 int
diff --git a/win32/3rdparty/pthreads/pthread_exit.c b/win32/3rdparty/pthreads/pthread_exit.c
index a490312..e707f07 100644
--- a/win32/3rdparty/pthreads/pthread_exit.c
+++ b/win32/3rdparty/pthreads/pthread_exit.c
@@ -38,7 +38,7 @@
 #include "pthread.h"
 #include "implement.h"
 #ifndef _UWIN
-//#   include <process.h>
+/*#   include <process.h> */
 #endif
 
 void
diff --git a/win32/3rdparty/pthreads/pthread_getw32threadhandle_np.c b/win32/3rdparty/pthreads/pthread_getw32threadhandle_np.c
index 9d22def..309a8f2 100644
--- a/win32/3rdparty/pthreads/pthread_getw32threadhandle_np.c
+++ b/win32/3rdparty/pthreads/pthread_getw32threadhandle_np.c
@@ -51,3 +51,15 @@ pthread_getw32threadhandle_np (pthread_t thread)
 {
   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 --git a/win32/3rdparty/pthreads/pthread_join.c b/win32/3rdparty/pthreads/pthread_join.c
index 8237b6c..72a3a74 100644
--- a/win32/3rdparty/pthreads/pthread_join.c
+++ b/win32/3rdparty/pthreads/pthread_join.c
@@ -42,7 +42,9 @@
  * Not needed yet, but defining it should indicate clashes with build target
  * environment that should be fixed.
  */
-#include <signal.h>
+#ifndef WINCE
+#  include <signal.h>
+#endif
 
 
 int
diff --git a/win32/3rdparty/pthreads/pthread_key_create.c b/win32/3rdparty/pthreads/pthread_key_create.c
index 5e278c2..41f4854 100644
--- a/win32/3rdparty/pthreads/pthread_key_create.c
+++ b/win32/3rdparty/pthreads/pthread_key_create.c
@@ -93,7 +93,7 @@ pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
     {
       /*
        * 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 --git a/win32/3rdparty/pthreads/pthread_key_delete.c b/win32/3rdparty/pthreads/pthread_key_delete.c
index 7da9b2f..0737e9e 100644
--- a/win32/3rdparty/pthreads/pthread_key_delete.c
+++ b/win32/3rdparty/pthreads/pthread_key_delete.c
@@ -119,7 +119,7 @@ pthread_key_delete (pthread_key_t key)
 	  /* A thread could be holding the keyLock */
 	  while (EBUSY == pthread_mutex_destroy (&(key->keyLock)))
 	    {
-	      Sleep(1); // Ugly.
+	      Sleep(0); /* Ugly */
 	    }
 	}
 
diff --git a/win32/3rdparty/pthreads/pthread_kill.c b/win32/3rdparty/pthreads/pthread_kill.c
index 7de3fe2..d360187 100644
--- a/win32/3rdparty/pthreads/pthread_kill.c
+++ b/win32/3rdparty/pthreads/pthread_kill.c
@@ -41,7 +41,9 @@
  * Not needed yet, but defining it should indicate clashes with build target
  * environment that should be fixed.
  */
-#include <signal.h>
+#ifndef WINCE
+#  include <signal.h>
+#endif
 
 int
 pthread_kill (pthread_t thread, int sig)
diff --git a/win32/3rdparty/pthreads/pthread_mutex_lock.c b/win32/3rdparty/pthreads/pthread_mutex_lock.c
index 4ca5c25..b819a7b 100644
--- a/win32/3rdparty/pthreads/pthread_mutex_lock.c
+++ b/win32/3rdparty/pthreads/pthread_mutex_lock.c
@@ -35,7 +35,7 @@
  */
 
 #ifndef _UWIN
-//#   include <process.h>
+/*#   include <process.h> */
 #endif
 #include "pthread.h"
 #include "implement.h"
diff --git a/win32/3rdparty/pthreads/pthread_mutexattr_gettype.c b/win32/3rdparty/pthreads/pthread_mutexattr_gettype.c
index b60ca30..c63fcfa 100644
--- a/win32/3rdparty/pthreads/pthread_mutexattr_gettype.c
+++ b/win32/3rdparty/pthreads/pthread_mutexattr_gettype.c
@@ -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 --git a/win32/3rdparty/pthreads/pthread_rwlock_destroy.c b/win32/3rdparty/pthreads/pthread_rwlock_destroy.c
index 5a747ed..d14b447 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_destroy.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_destroy.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_init.c b/win32/3rdparty/pthreads/pthread_rwlock_init.c
index 3e3f448..597c1ff 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_init.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_init.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_rdlock.c b/win32/3rdparty/pthreads/pthread_rwlock_rdlock.c
index dba63dd..91e1808 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_rdlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_rdlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_timedrdlock.c b/win32/3rdparty/pthreads/pthread_rwlock_timedrdlock.c
index 9348950..7133778 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_timedrdlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_timedrdlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_timedwrlock.c b/win32/3rdparty/pthreads/pthread_rwlock_timedwrlock.c
index e7d1be2..5de1e48 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_timedwrlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_timedwrlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_tryrdlock.c b/win32/3rdparty/pthreads/pthread_rwlock_tryrdlock.c
index 308900d..0fc5458 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_tryrdlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_tryrdlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_trywrlock.c b/win32/3rdparty/pthreads/pthread_rwlock_trywrlock.c
index 8ba8b5d..9997c5d 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_trywrlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_trywrlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_unlock.c b/win32/3rdparty/pthreads/pthread_rwlock_unlock.c
index 776c996..d48d187 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_unlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_unlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlock_wrlock.c b/win32/3rdparty/pthreads/pthread_rwlock_wrlock.c
index a097040..174fcbc 100644
--- a/win32/3rdparty/pthreads/pthread_rwlock_wrlock.c
+++ b/win32/3rdparty/pthreads/pthread_rwlock_wrlock.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlockattr_destroy.c b/win32/3rdparty/pthreads/pthread_rwlockattr_destroy.c
index 0fcbe84..868e727 100644
--- a/win32/3rdparty/pthreads/pthread_rwlockattr_destroy.c
+++ b/win32/3rdparty/pthreads/pthread_rwlockattr_destroy.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlockattr_getpshared.c b/win32/3rdparty/pthreads/pthread_rwlockattr_getpshared.c
index abfe63f..eeace20 100644
--- a/win32/3rdparty/pthreads/pthread_rwlockattr_getpshared.c
+++ b/win32/3rdparty/pthreads/pthread_rwlockattr_getpshared.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlockattr_init.c b/win32/3rdparty/pthreads/pthread_rwlockattr_init.c
index feb8e94..a2d2b94 100644
--- a/win32/3rdparty/pthreads/pthread_rwlockattr_init.c
+++ b/win32/3rdparty/pthreads/pthread_rwlockattr_init.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_rwlockattr_setpshared.c b/win32/3rdparty/pthreads/pthread_rwlockattr_setpshared.c
index 316532c..a83dd70 100644
--- a/win32/3rdparty/pthreads/pthread_rwlockattr_setpshared.c
+++ b/win32/3rdparty/pthreads/pthread_rwlockattr_setpshared.c
@@ -34,7 +34,6 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include <errno.h>
 #include <limits.h>
 
 #include "pthread.h"
diff --git a/win32/3rdparty/pthreads/pthread_setspecific.c b/win32/3rdparty/pthreads/pthread_setspecific.c
index f06b696..b16270e 100644
--- a/win32/3rdparty/pthreads/pthread_setspecific.c
+++ b/win32/3rdparty/pthreads/pthread_setspecific.c
@@ -155,13 +155,13 @@ pthread_setspecific (pthread_key_t key, const void *value)
 	  (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 --git a/win32/3rdparty/pthreads/pthread_testcancel.c b/win32/3rdparty/pthreads/pthread_testcancel.c
index ad7cdb9..9686d9e 100644
--- a/win32/3rdparty/pthreads/pthread_testcancel.c
+++ b/win32/3rdparty/pthreads/pthread_testcancel.c
@@ -92,10 +92,10 @@ pthread_testcancel (void)
     {
       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 --git a/win32/3rdparty/pthreads/pthread_win32_attach_detach_np.c b/win32/3rdparty/pthreads/pthread_win32_attach_detach_np.c
index 2f0bc37..7911fe1 100644
--- a/win32/3rdparty/pthreads/pthread_win32_attach_detach_np.c
+++ b/win32/3rdparty/pthreads/pthread_win32_attach_detach_np.c
@@ -91,6 +91,15 @@ pthread_win32_process_attach_np ()
 
 #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 @@ pthread_win32_process_attach_np ()
       ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;
     }
 
+#endif
+
   /*
    * Load QUSEREX.DLL and try to get address of QueueUserAPCEx
    */
diff --git a/win32/3rdparty/pthreads/ptw32_InterlockedCompareExchange.c b/win32/3rdparty/pthreads/ptw32_InterlockedCompareExchange.c
index 0094635..898591d 100644
--- a/win32/3rdparty/pthreads/ptw32_InterlockedCompareExchange.c
+++ b/win32/3rdparty/pthreads/ptw32_InterlockedCompareExchange.c
@@ -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 @@ ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location,
    * unsupported processor or compiler.
    */
 
-  result = 0;
+#error Unsupported platform or compiler!
 
 #endif
 
@@ -250,8 +252,8 @@ L1:	MOV          eax,dword ptr [ecx]
        * 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 @@ L1:	MOV          eax,dword ptr [ecx]
    * unsupported processor or compiler.
    */
 
-  result = 0;
+#error Unsupported platform or compiler!
 
 #endif
 
@@ -301,3 +303,5 @@ L1:	MOV          eax,dword ptr [ecx]
 #endif
 
 #endif
+
+#endif
diff --git a/win32/3rdparty/pthreads/ptw32_MCS_lock.c b/win32/3rdparty/pthreads/ptw32_MCS_lock.c
index 1a143ea..6b797c5 100644
--- a/win32/3rdparty/pthreads/ptw32_MCS_lock.c
+++ b/win32/3rdparty/pthreads/ptw32_MCS_lock.c
@@ -89,8 +89,8 @@
  * }
  */
 
-#include "implement.h"
 #include "pthread.h"
+#include "implement.h"
 
 /*
  * ptw32_mcs_flag_set -- notify another thread about an event.
diff --git a/win32/3rdparty/pthreads/ptw32_relmillisecs.c b/win32/3rdparty/pthreads/ptw32_relmillisecs.c
index f3e7b76..ee4a7e3 100644
--- a/win32/3rdparty/pthreads/ptw32_relmillisecs.c
+++ b/win32/3rdparty/pthreads/ptw32_relmillisecs.c
@@ -35,7 +35,7 @@
  */
 
 #ifndef _UWIN
-//#include <process.h>
+/*#include <process.h> */
 #endif
 #include "pthread.h"
 #include "implement.h"
diff --git a/win32/3rdparty/pthreads/ptw32_semwait.c b/win32/3rdparty/pthreads/ptw32_semwait.c
index 8b23d11..361366b 100644
--- a/win32/3rdparty/pthreads/ptw32_semwait.c
+++ b/win32/3rdparty/pthreads/ptw32_semwait.c
@@ -35,7 +35,7 @@
  */
 
 #ifndef _UWIN
-//#   include <process.h>
+/*#   include <process.h> */
 #endif
 #include "pthread.h"
 #include "implement.h"
@@ -77,8 +77,18 @@ ptw32_semwait (sem_t * sem)
     {
       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 @@ ptw32_semwait (sem_t * sem)
 #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 --git a/win32/3rdparty/pthreads/ptw32_throw.c b/win32/3rdparty/pthreads/ptw32_throw.c
index 493f4e4..b276119 100644
--- a/win32/3rdparty/pthreads/ptw32_throw.c
+++ b/win32/3rdparty/pthreads/ptw32_throw.c
@@ -73,6 +73,7 @@ ptw32_throw (DWORD exception)
        * 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 @@ ptw32_throw (DWORD exception)
 	  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 --git a/win32/3rdparty/pthreads/sched.h b/win32/3rdparty/pthreads/sched.h
index dfb8e93..e3e7a00 100644
--- a/win32/3rdparty/pthreads/sched.h
+++ b/win32/3rdparty/pthreads/sched.h
@@ -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 <sys/types.h>
 /* Required by Unix 98 */
 #  include <time.h>
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+# else
+  typedef int pid_t;
+# endif
 #else
 typedef int pid_t;
 #endif
diff --git a/win32/3rdparty/pthreads/tests/ChangeLog b/win32/3rdparty/pthreads/tests/ChangeLog
index 6b2c742..30f6ccb 100644
--- a/win32/3rdparty/pthreads/tests/ChangeLog
+++ b/win32/3rdparty/pthreads/tests/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-04  Ross Johnson <Ross dot Johnson at homemail dot com dot au>
+
+        * context1.c: Include context.h from library sources and remove
+        x86 dependence in main().
+
 2005-06-12  Ross Johnson  <rpj at callisto.canberra.edu.au>
 
 	* stress1.c (millisecondsFromNow): Remove limit 0 <= millisecs < 1000;
diff --git a/win32/3rdparty/pthreads/tests/SIZES.GC b/win32/3rdparty/pthreads/tests/SIZES.GC
old mode 100644
new mode 100755
diff --git a/win32/3rdparty/pthreads/tests/SIZES.GCE b/win32/3rdparty/pthreads/tests/SIZES.GCE
old mode 100644
new mode 100755
diff --git a/win32/3rdparty/pthreads/tests/SIZES.VC b/win32/3rdparty/pthreads/tests/SIZES.VC
old mode 100644
new mode 100755
diff --git a/win32/3rdparty/pthreads/tests/context1.c b/win32/3rdparty/pthreads/tests/context1.c
index 090df9c..e63dbec 100644
--- a/win32/3rdparty/pthreads/tests/context1.c
+++ b/win32/3rdparty/pthreads/tests/context1.c
@@ -75,6 +75,7 @@
 
 #include "test.h"
 #include "../implement.h"
+#include "../context.h"
 
 static int washere = 0;
 
@@ -122,10 +123,7 @@ main()
       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 --git a/win32/3rdparty/pthreads/tests/once3.c b/win32/3rdparty/pthreads/tests/once3.c
index 981bbf7..51d2daa 100644
--- a/win32/3rdparty/pthreads/tests/once3.c
+++ b/win32/3rdparty/pthreads/tests/once3.c
@@ -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 @@ myfunc(void)
 {
   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 @@ mythread(void * arg)
 {
   /*
    * 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 --git a/win32/3rdparty/pthreads/tests/valid1.c b/win32/3rdparty/pthreads/tests/semaphore5.c
similarity index 81%
copy from win32/3rdparty/pthreads/tests/valid1.c
copy to win32/3rdparty/pthreads/tests/semaphore5.c
index 4d5cab5..5f7e692 100644
--- a/win32/3rdparty/pthreads/tests/valid1.c
+++ b/win32/3rdparty/pthreads/tests/semaphore5.c
@@ -1,5 +1,5 @@
 /*
- * File: valid1.c
+ * File: semaphore5.c
  *
  *
  * --------------------------------------------------------------------------
@@ -33,26 +33,26 @@
  *
  * --------------------------------------------------------------------------
  *
- * Test Synopsis:
- * - Test that thread validation works.
+ * Test Synopsis: Verify sem_destroy EBUSY race avoidance
+ * - 
  *
  * Test Method (Validation or Falsification):
- * -
+ * - Validation
  *
  * Requirements Tested:
- * -
+ * - 
  *
  * Features Tested:
- * -
+ * - 
  *
  * Cases Tested:
- * -
+ * - 
  *
  * Description:
- * -
+ * - 
  *
  * Environment:
- * -
+ * - 
  *
  * Input:
  * - None.
@@ -62,7 +62,7 @@
  * - No output on success.
  *
  * Assumptions:
- * -
+ * - 
  *
  * Pass Criteria:
  * - Process returns zero exit status.
@@ -71,33 +71,33 @@
  * - Process returns non-zero exit status.
  */
 
-#include "test.h"
-
-enum {
-	NUMTHREADS = 1
-};
+// #define ASSERT_TRACE
 
-static int washere = 0;
+#include "test.h"
 
-void * func(void * arg)
+void *
+thr(void * arg)
 {
-  washere = 1;
-  return (void *) 0; 
+  assert(sem_post((sem_t *)arg) == 0);
+
+  return 0;
 }
- 
+
+
 int
 main()
 {
   pthread_t t;
-  void * result = NULL;
+  sem_t s;
+
+  assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
+  assert(pthread_create(&t, NULL, thr, (void *)&s) == 0);
 
-  washere = 0;
-  assert(pthread_create(&t, NULL, func, NULL) == 0);
-  assert(pthread_join(t, &result) == 0);
-  assert(result == 0);
-  assert(washere == 1);
-  sched_yield();
-  assert(pthread_kill(t, 0) == ESRCH);
+  assert(sem_wait(&s) == 0);
+  assert(sem_destroy(&s) == 0);
+
+  assert(pthread_join(t, NULL) == 0);
 
   return 0;
 }
+

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list