Index: GNUmakefile =================================================================== RCS file: /cvs/pthreads-win32/pthreads/GNUmakefile,v retrieving revision 1.42 diff -u -r1.42 GNUmakefile --- GNUmakefile 20 Jun 2010 03:31:19 -0000 1.42 +++ GNUmakefile 1 Mar 2011 19:07:56 -0000 @@ -64,7 +64,7 @@ RCFLAGS = --include-dir=. # Uncomment this if config.h defines RETAIN_WSALASTERROR -#LFLAGS = -lwsock32 +LFLAGS = -lws2_32 # ---------------------------------------------------------------------- # The library can be built with some alternative behaviour to @@ -171,7 +171,6 @@ pthread_cond_wait.o \ create.o \ dll.o \ - autostatic.o \ errno.o \ pthread_exit.o \ fork.o \ Index: Makefile =================================================================== RCS file: /cvs/pthreads-win32/pthreads/Makefile,v retrieving revision 1.44 diff -u -r1.44 Makefile --- Makefile 22 Jun 2010 01:19:08 -0000 1.44 +++ Makefile 1 Mar 2011 19:07:56 -0000 @@ -27,11 +27,11 @@ OPTIM = /O2 /Ob2 OPTIMD = -CFLAGS = /W3 /MD /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H +CFLAGS = /W3 /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H CFLAGSD = /Zi $(CFLAGS) # Uncomment this if config.h defines RETAIN_WSALASTERROR -#XLIBS = wsock32.lib +XLIBS = wsock32.lib # Default cleanup style CLEANUP = __CLEANUP_C @@ -59,7 +59,6 @@ condvar.obj \ create.obj \ dll.obj \ - autostatic.obj \ errno.obj \ exit.obj \ fork.obj \ @@ -117,7 +116,6 @@ pthread_cond_wait.obj \ create.obj \ dll.obj \ - autostatic.obj \ errno.obj \ pthread_exit.obj \ fork.obj \ @@ -399,50 +397,50 @@ @ nmake clean VC-inlined-debug VCE: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll VCE-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll + @ nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll VSE: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll VSE-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll + @ nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll VC: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll VC-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll + @ nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll # # The so-called inlined DLL is just a single translation unit with # inlining optimisation turned on. # VCE-inlined: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp VCE-inlined-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp + @ nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp VSE-inlined: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp VSE-inlined-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp + @ nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp VC-inlined: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp + @ nmake /nologo EHFLAGS="$(OPTIM) /MD $(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp VC-inlined-debug: - nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp + nmake /nologo EHFLAGS="$(OPTIMD) /MDd $(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp VC-static: - @ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static + @ nmake /nologo EHFLAGS="$(OPTIM) /MT $(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static VC-static-debug: - @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static + @ nmake /nologo EHFLAGS="$(OPTIMD) /MTd $(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static realclean: clean if exist pthread*.dll del pthread*.dll Index: config.h =================================================================== RCS file: /cvs/pthreads-win32/pthreads/config.h,v retrieving revision 1.17 diff -u -r1.17 config.h --- config.h 20 Jun 2010 03:31:19 -0000 1.17 +++ config.h 1 Mar 2011 19:07:56 -0000 @@ -56,7 +56,7 @@ * and calling SetLastError() isn't enough restore it. You'll also need to * link against wsock32.lib (or libwsock32.a for MinGW). */ -#undef RETAIN_WSALASTERROR +#define RETAIN_WSALASTERROR /* # ---------------------------------------------------------------------- @@ -124,6 +124,9 @@ #ifdef __MINGW32__ #define HAVE_MODE_T +#ifdef _WIN64 +#define HAVE_STRUCT_TIMESPEC 1 +#endif #endif #ifdef __BORLANDC__ Index: create.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/create.c,v retrieving revision 1.64 diff -u -r1.64 create.c --- create.c 6 Jan 2007 13:44:40 -0000 1.64 +++ create.c 1 Mar 2011 19:07:56 -0000 @@ -90,7 +90,7 @@ int result = EAGAIN; int run = PTW32_TRUE; ThreadParms *parms = NULL; - long stackSize; + size_t stackSize; int priority; pthread_t self; Index: global.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/global.c,v retrieving revision 1.47 diff -u -r1.47 global.c --- global.c 20 Jun 2010 03:31:19 -0000 1.47 +++ global.c 1 Mar 2011 19:07:56 -0000 @@ -54,6 +54,7 @@ BOOL ptw32_smp_system = PTW32_TRUE; /* Safer if assumed true initially. */ +#ifndef _WIN64 /* * Function pointer to InterlockedCompareExchange if it exists, otherwise * it will be set at runtime to a substitute local version with the same @@ -64,6 +65,7 @@ PTW32_INTERLOCKED_LONG, PTW32_INTERLOCKED_LONG) = NULL; +#endif /* * Function pointer to QueueUserAPCEx if it exists, otherwise Index: implement.h =================================================================== RCS file: /cvs/pthreads-win32/pthreads/implement.h,v retrieving revision 1.121 diff -u -r1.121 implement.h --- implement.h 20 Jun 2010 03:31:19 -0000 1.121 +++ implement.h 1 Mar 2011 19:07:56 -0000 @@ -77,14 +77,37 @@ #include "sched.h" #if defined(HAVE_C_INLINE) || defined(__cplusplus) -#define INLINE inline +# define INLINE inline +# ifdef PTW32_BUILD_INLINED +# define EXTERN_INLINE inline +# else +# define EXTERN_INLINE +# endif #else -#define INLINE +# define INLINE +# define EXTERN_INLINE +#endif + +#if (defined(_MSC_VER) && _MSC_VER < 1200 || defined(__DMC__)) && !defined(_WIN64) +/* + * VC++5.0 or early compiler's header has no INT_PTR/UINT_PTR types. + */ +#define INT_PTR long +#define UINT_PTR unsigned long +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) +/* + * VC++6.0 or early compiler's header has no DWORD_PTR/LONG_PTR/ULONG_PTR types. + */ +#define DWORD_PTR UINT_PTR +#define LONG_PTR INT_PTR +#define ULONG_PTR UINT_PTR #endif #if defined (__MINGW32__) || (_MSC_VER >= 1300) -#define PTW32_INTERLOCKED_LONG long -#define PTW32_INTERLOCKED_LPLONG long* +#define PTW32_INTERLOCKED_LONG LONG +#define PTW32_INTERLOCKED_LPLONG LPLONG #else #define PTW32_INTERLOCKED_LONG PVOID #define PTW32_INTERLOCKED_LPLONG PVOID* @@ -219,7 +242,7 @@ }; /* - * Possible values, other than PTW32_OBJECT_INVALID, + * Possible values, other than PTW32_SPIN_INVALID, * for the "interlock" element in a spinlock. * * In this implementation, when a spinlock is initialised, @@ -235,13 +258,14 @@ * "u.cpus" isn't used for anything yet, but could be used at * some point to optimise spinlock behaviour. */ +#define PTW32_SPIN_INVALID (0) #define PTW32_SPIN_UNLOCKED (1) #define PTW32_SPIN_LOCKED (2) #define PTW32_SPIN_USE_MUTEX (3) struct pthread_spinlock_t_ { - long interlock; /* Locking element for multi-cpus. */ + LONG interlock; /* Locking element for multi-cpus. */ union { int cpus; /* No. of cpus if multi cpus, or */ @@ -256,9 +280,9 @@ { struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ - LONG readyFlag; /* set after lock is released by + LONG_PTR readyFlag; /* set after lock is released by predecessor */ - LONG nextFlag; /* set after 'next' ptr is set by + LONG_PTR nextFlag; /* set after 'next' ptr is set by successor */ }; @@ -268,8 +292,8 @@ struct pthread_barrier_t_ { - unsigned int nCurrentBarrierHeight; - unsigned int nInitialBarrierHeight; + ULONG nCurrentBarrierHeight; + ULONG nInitialBarrierHeight; int pshared; sem_t semBarrierBreeched; void * lock; /* MCS lock */ @@ -511,10 +535,12 @@ #define PTW32_MIN(a,b) ((a)>(b)?(b):(a)) +#ifndef _WIN64 /* Declared in global.c */ extern PTW32_INTERLOCKED_LONG (WINAPI * ptw32_interlocked_compare_exchange) (PTW32_INTERLOCKED_LPLONG, PTW32_INTERLOCKED_LONG, PTW32_INTERLOCKED_LONG); +#endif /* Declared in pthread_cancel.c */ extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD); @@ -567,6 +593,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 * lock); PTW32_INTERLOCKED_LONG WINAPI ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location, @@ -663,8 +690,8 @@ # endif # endif #else -# include -# endif +# include +#endif /* @@ -672,11 +699,15 @@ * See ptw32_InterlockedCompareExchange.c */ #ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_interlocked_compare_exchange -# endif +# ifdef _WIN64 +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# else +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_interlocked_compare_exchange +# endif +#endif #ifndef PTW32_INTERLOCKED_EXCHANGE -#define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange +# define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange #endif Index: pthread.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread.c,v retrieving revision 1.9 diff -u -r1.9 pthread.c --- pthread.c 20 Jun 2010 03:31:19 -0000 1.9 +++ pthread.c 1 Mar 2011 19:07:56 -0000 @@ -49,7 +49,6 @@ #include "condvar.c" #include "create.c" #include "dll.c" -#include "autostatic.c" #include "errno.c" #include "exit.c" #include "fork.c" Index: pthread.h =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread.h,v retrieving revision 1.141 diff -u -r1.141 pthread.h --- pthread.h 27 Feb 2011 01:09:58 -0000 1.141 +++ pthread.h 1 Mar 2011 19:09:21 -0000 @@ -198,12 +198,6 @@ #include #endif -#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) -/* - * VC++6.0 or early compiler's header has no DWORD_PTR type. - */ -typedef unsigned long DWORD_PTR; -#endif /* * ----------------- * autoconf switches @@ -248,6 +242,9 @@ # if defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif +# if defined(__MINGW32__) && defined(_WIN64) +# define HAVE_STRUCT_TIMESPEC 1 +# endif #endif /* Index: pthread_barrier_wait.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_barrier_wait.c,v retrieving revision 1.8 diff -u -r1.8 pthread_barrier_wait.c --- pthread_barrier_wait.c 20 Jun 2010 03:31:19 -0000 1.8 +++ pthread_barrier_wait.c 1 Mar 2011 19:07:56 -0000 @@ -87,8 +87,8 @@ result = ptw32_semwait (&(b->semBarrierBreeched)); } - if ((PTW32_INTERLOCKED_LONG)InterlockedIncrement((LPLONG)&b->nCurrentBarrierHeight) - == (PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight) + if ((ULONG)InterlockedIncrement((LPLONG)&b->nCurrentBarrierHeight) + == b->nInitialBarrierHeight) { /* * We are the last thread to cross this barrier Index: pthread_cancel.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_cancel.c,v retrieving revision 1.12 diff -u -r1.12 pthread_cancel.c --- pthread_cancel.c 20 Jun 2010 03:31:19 -0000 1.12 +++ pthread_cancel.c 1 Mar 2011 19:07:56 -0000 @@ -47,7 +47,7 @@ } static void CALLBACK -ptw32_cancel_callback (DWORD unused) +ptw32_cancel_callback (DWORD_PTR unused) { ptw32_throw (PTW32_EPS_CANCEL); Index: pthread_exit.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_exit.c,v retrieving revision 1.9 diff -u -r1.9 pthread_exit.c --- pthread_exit.c 15 May 2007 13:46:42 -0000 1.9 +++ pthread_exit.c 1 Mar 2011 19:07:56 -0000 @@ -89,7 +89,7 @@ */ #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex ((unsigned) value_ptr); + _endthreadex ((unsigned)(UINT_PTR) value_ptr); #else _endthread (); #endif Index: pthread_mutex_lock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_mutex_lock.c,v retrieving revision 1.15 diff -u -r1.15 pthread_mutex_lock.c --- pthread_mutex_lock.c 15 May 2007 13:46:42 -0000 1.15 +++ pthread_mutex_lock.c 1 Mar 2011 19:07:56 -0000 @@ -72,11 +72,11 @@ if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((LONG) PTW32_INTERLOCKED_EXCHANGE( + if (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) 1) != 0) { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( + while (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) -1) != 0) { @@ -92,7 +92,7 @@ { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( (PTW32_INTERLOCKED_LPLONG) &mx->lock_idx, (PTW32_INTERLOCKED_LONG) 1, (PTW32_INTERLOCKED_LONG) 0) == 0) @@ -115,7 +115,7 @@ } else { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( + while (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) -1) != 0) { Index: pthread_mutex_timedlock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_mutex_timedlock.c,v retrieving revision 1.15 diff -u -r1.15 pthread_mutex_timedlock.c --- pthread_mutex_timedlock.c 25 Apr 2005 14:42:42 -0000 1.15 +++ pthread_mutex_timedlock.c 1 Mar 2011 19:07:56 -0000 @@ -134,11 +134,11 @@ if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((LONG) PTW32_INTERLOCKED_EXCHANGE( + if (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) 1) != 0) { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( + while (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) -1) != 0) { @@ -153,7 +153,7 @@ { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( (PTW32_INTERLOCKED_LPLONG) &mx->lock_idx, (PTW32_INTERLOCKED_LONG) 1, (PTW32_INTERLOCKED_LONG) 0) == 0) @@ -176,7 +176,7 @@ } else { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( + while (PTW32_INTERLOCKED_EXCHANGE( (LPLONG) &mx->lock_idx, (LONG) -1) != 0) { Index: pthread_mutex_unlock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_mutex_unlock.c,v retrieving revision 1.13 diff -u -r1.13 pthread_mutex_unlock.c --- pthread_mutex_unlock.c 25 Jan 2005 07:58:21 -0000 1.13 +++ pthread_mutex_unlock.c 1 Mar 2011 19:07:56 -0000 @@ -61,8 +61,8 @@ { LONG idx; - idx = (LONG) PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, - (LONG) 0); + idx = PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, + (LONG) 0); if (idx != 0) { if (idx < 0) @@ -93,8 +93,8 @@ { mx->ownerThread.p = NULL; - if ((LONG) PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, - (LONG) 0) < 0) + if (PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, + (LONG) 0) < 0) { /* Someone may be waiting on that mutex */ if (SetEvent (mx->event) == 0) Index: pthread_spin_destroy.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_spin_destroy.c,v retrieving revision 1.8 diff -u -r1.8 pthread_spin_destroy.c --- pthread_spin_destroy.c 1 Jan 2005 14:36:17 -0000 1.8 +++ pthread_spin_destroy.c 1 Mar 2011 19:07:56 -0000 @@ -55,13 +55,11 @@ { result = pthread_mutex_destroy (&(s->u.mutex)); } - else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) - & (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_OBJECT_INVALID, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + else if (PTW32_SPIN_UNLOCKED != + (LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + (PTW32_INTERLOCKED_LPLONG)&(s->interlock), + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_INVALID, + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_UNLOCKED)) { result = EINVAL; } Index: pthread_spin_lock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_spin_lock.c,v retrieving revision 1.7 diff -u -r1.7 pthread_spin_lock.c --- pthread_spin_lock.c 1 Jan 2005 14:36:17 -0000 1.7 +++ pthread_spin_lock.c 1 Mar 2011 19:07:56 -0000 @@ -60,13 +60,11 @@ s = *lock; - while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED == - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + while (PTW32_SPIN_LOCKED == + (LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + (PTW32_INTERLOCKED_LPLONG)&(s->interlock), + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_LOCKED, + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_UNLOCKED)) { } Index: pthread_spin_trylock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_spin_trylock.c,v retrieving revision 1.7 diff -u -r1.7 pthread_spin_trylock.c --- pthread_spin_trylock.c 1 Jan 2005 14:36:17 -0000 1.7 +++ pthread_spin_trylock.c 1 Mar 2011 19:07:56 -0000 @@ -60,13 +60,11 @@ s = *lock; - switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + switch ((LONG) + PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + (PTW32_INTERLOCKED_LPLONG)&(s->interlock), + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_LOCKED, + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_UNLOCKED)) { case PTW32_SPIN_UNLOCKED: return 0; Index: pthread_spin_unlock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_spin_unlock.c,v retrieving revision 1.7 diff -u -r1.7 pthread_spin_unlock.c --- pthread_spin_unlock.c 1 Jan 2005 14:36:17 -0000 1.7 +++ pthread_spin_unlock.c 1 Mar 2011 19:07:56 -0000 @@ -55,13 +55,11 @@ return EPERM; } - switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED)) + switch ((LONG) + PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + (PTW32_INTERLOCKED_LPLONG)&(s->interlock), + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_UNLOCKED, + (PTW32_INTERLOCKED_LONG)PTW32_SPIN_LOCKED)) { case PTW32_SPIN_LOCKED: return 0; Index: pthread_timechange_handler_np.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/pthread_timechange_handler_np.c,v retrieving revision 1.5 diff -u -r1.5 pthread_timechange_handler_np.c --- pthread_timechange_handler_np.c 1 Jan 2005 14:36:17 -0000 1.5 +++ pthread_timechange_handler_np.c 1 Mar 2011 19:07:56 -0000 @@ -103,5 +103,5 @@ LeaveCriticalSection (&ptw32_cond_list_lock); - return (void *) (result != 0 ? EAGAIN : 0); + return (void *)(INT_PTR) (result != 0 ? EAGAIN : 0); } Index: ptw32_MCS_lock.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_MCS_lock.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_MCS_lock.c --- ptw32_MCS_lock.c 20 Jun 2010 03:31:19 -0000 1.5 +++ ptw32_MCS_lock.c 1 Mar 2011 19:07:56 -0000 @@ -98,13 +98,20 @@ * Set event if an event handle has been stored in the flag, and * set flag to -1 otherwise. Note that -1 cannot be a valid handle value. */ -INLINE void -ptw32_mcs_flag_set (LONG * flag) +static INLINE void +ptw32_mcs_flag_set (LONG_PTR * flag) { +#ifdef _WIN64 + HANDLE e = (HANDLE)InterlockedCompareExchange64( + (PLONGLONG)flag, + (LONGLONG)-1, + (LONGLONG)0); +#else HANDLE e = (HANDLE)PTW32_INTERLOCKED_COMPARE_EXCHANGE( (PTW32_INTERLOCKED_LPLONG)flag, (PTW32_INTERLOCKED_LONG)-1, (PTW32_INTERLOCKED_LONG)0); +#endif if ((HANDLE)0 != e) { /* another thread has already stored an event handle in the flag */ @@ -118,19 +125,30 @@ * Store an event handle in the flag and wait on it if the flag has not been * set, and proceed without creating an event otherwise. */ -INLINE void -ptw32_mcs_flag_wait (LONG * flag) +static INLINE void +ptw32_mcs_flag_wait (LONG_PTR * flag) { +#ifdef _WIN64 + if (0 == InterlockedExchangeAdd64((PLONGLONG)flag, 0)) /* MBR fence */ +#else if (0 == InterlockedExchangeAdd((LPLONG)flag, 0)) /* MBR fence */ +#endif { /* the flag is not set. create event. */ HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL); - if (0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE( +#ifdef _WIN64 + if (0 == InterlockedCompareExchange64( + (PLONGLONG)flag, + (LONGLONG)e, + (LONGLONG)0)) +#else + if (0 == (LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( (PTW32_INTERLOCKED_LPLONG)flag, (PTW32_INTERLOCKED_LONG)e, (PTW32_INTERLOCKED_LONG)0)) +#endif { /* stored handle in the flag. wait on it now. */ WaitForSingleObject(e, INFINITE); @@ -148,7 +166,7 @@ * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -INLINE void +EXTERN_INLINE void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) { ptw32_mcs_local_node_t *pred; @@ -159,8 +177,13 @@ node->next = 0; /* initially, no successor */ /* queue for the lock */ - pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE((PTW32_INTERLOCKED_LPLONG)lock, - (PTW32_INTERLOCKED_LONG)node); +#ifdef _WIN64 + pred = (ptw32_mcs_local_node_t *)InterlockedExchange64((PLONGLONG)lock, + (LONGLONG)node); +#else + pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE((LPLONG)lock, + (LONG)node); +#endif if (0 != pred) { @@ -179,22 +202,33 @@ * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -INLINE void +EXTERN_INLINE void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) { ptw32_mcs_lock_t *lock = node->lock; ptw32_mcs_local_node_t *next = (ptw32_mcs_local_node_t *) +#ifdef _WIN64 + InterlockedExchangeAdd64((PLONGLONG)&node->next, + (LONGLONG)0); /* MBR fence */ +#else InterlockedExchangeAdd((LPLONG)&node->next, (LONG)0); /* MBR fence */ +#endif if (0 == next) { /* no known successor */ if (node == (ptw32_mcs_local_node_t *) +#ifdef _WIN64 + InterlockedCompareExchange64((PLONGLONG)lock, + (LONGLONG)0, + (LONGLONG)node)) +#else PTW32_INTERLOCKED_COMPARE_EXCHANGE((PTW32_INTERLOCKED_LPLONG)lock, (PTW32_INTERLOCKED_LONG)0, (PTW32_INTERLOCKED_LONG)node)) +#endif { /* no successor, lock is free now */ return; @@ -203,7 +237,11 @@ /* wait for successor */ ptw32_mcs_flag_wait(&node->nextFlag); next = (ptw32_mcs_local_node_t *) +#ifdef _WIN64 + InterlockedExchangeAdd64((PLONGLONG)&node->next, 0); /* MBR fence */ +#else InterlockedExchangeAdd((LPLONG)&node->next, 0); /* MBR fence */ +#endif } /* pass the lock */ @@ -213,7 +251,7 @@ /* * ptw32_mcs_lock_try_acquire */ -INLINE int +EXTERN_INLINE int ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) { node->lock = lock; @@ -221,11 +259,19 @@ node->readyFlag = 0; node->next = 0; /* initially, no successor */ - return ((PTW32_INTERLOCKED_LPLONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE( +#ifdef _WIN64 + return (InterlockedCompareExchange64( + (PLONGLONG)lock, + (LONGLONG)node, + (LONGLONG)0) + == 0) ? 0 : EBUSY; +#else + return ((LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( (PTW32_INTERLOCKED_LPLONG)lock, (PTW32_INTERLOCKED_LONG)node, (PTW32_INTERLOCKED_LONG)0) - == (PTW32_INTERLOCKED_LPLONG)0) ? 0 : EBUSY; + == 0) ? 0 : EBUSY; +#endif } /* @@ -239,7 +285,7 @@ * * Should only be called by the thread that has the lock. */ -INLINE void +EXTERN_INLINE void ptw32_mcs_node_substitute (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node) { new_node->lock = old_node->lock; @@ -247,9 +293,15 @@ new_node->readyFlag = 0; /* Not needed - we were waiting on this */ new_node->next = 0; +#ifdef _WIN64 + if ((ptw32_mcs_local_node_t *)InterlockedCompareExchange64((PLONGLONG)new_node->lock, + (LONGLONG)new_node, + (LONGLONG)old_node) != old_node) +#else if ((ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_COMPARE_EXCHANGE((PTW32_INTERLOCKED_LPLONG)new_node->lock, (PTW32_INTERLOCKED_LONG)new_node, (PTW32_INTERLOCKED_LONG)old_node) != old_node) +#endif { /* * A successor has queued after us, so wait for them to link to us Index: ptw32_callUserDestroyRoutines.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_callUserDestroyRoutines.c,v retrieving revision 1.11 diff -u -r1.11 ptw32_callUserDestroyRoutines.c --- ptw32_callUserDestroyRoutines.c 9 May 2005 08:31:31 -0000 1.11 +++ ptw32_callUserDestroyRoutines.c 1 Mar 2011 19:07:56 -0000 @@ -39,11 +39,21 @@ #include "implement.h" #ifdef __cplusplus -# if ! defined (_MSC_VER) && ! (defined(__GNUC__) && __GNUC__ < 3) && ! defined(__WATCOMC__) +#if defined(_MSC_VER) +# include +#elif defined(__WATCOMC__) +# include +# include +#else +# if defined(__GNUC__) && __GNUC__ < 3 +# include +# else +# include using std::terminate; # endif #endif +#endif void ptw32_callUserDestroyRoutines (pthread_t thread) Index: ptw32_cond_check_need_init.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_cond_check_need_init.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_cond_check_need_init.c --- ptw32_cond_check_need_init.c 1 Jan 2005 14:36:17 -0000 1.5 +++ ptw32_cond_check_need_init.c 1 Mar 2011 19:07:56 -0000 @@ -39,7 +39,7 @@ #include "implement.h" -INLINE int +EXTERN_INLINE int ptw32_cond_check_need_init (pthread_cond_t * cond) { int result = 0; Index: ptw32_mutex_check_need_init.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_mutex_check_need_init.c,v retrieving revision 1.6 diff -u -r1.6 ptw32_mutex_check_need_init.c --- ptw32_mutex_check_need_init.c 1 Jan 2005 14:36:17 -0000 1.6 +++ ptw32_mutex_check_need_init.c 1 Mar 2011 19:07:56 -0000 @@ -45,7 +45,7 @@ static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s; -INLINE int +EXTERN_INLINE int ptw32_mutex_check_need_init (pthread_mutex_t * mutex) { register int result = 0; Index: ptw32_relmillisecs.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_relmillisecs.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_relmillisecs.c --- ptw32_relmillisecs.c 15 May 2007 13:46:42 -0000 1.5 +++ ptw32_relmillisecs.c 1 Mar 2011 19:07:56 -0000 @@ -44,7 +44,7 @@ #endif -INLINE DWORD +EXTERN_INLINE DWORD ptw32_relmillisecs (const struct timespec * abstime) { const int64_t NANOSEC_PER_MILLISEC = 1000000; Index: ptw32_rwlock_check_need_init.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_rwlock_check_need_init.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_rwlock_check_need_init.c --- ptw32_rwlock_check_need_init.c 1 Jan 2005 14:36:18 -0000 1.5 +++ ptw32_rwlock_check_need_init.c 1 Mar 2011 19:07:56 -0000 @@ -37,7 +37,7 @@ #include "pthread.h" #include "implement.h" -INLINE int +EXTERN_INLINE int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock) { int result = 0; Index: ptw32_spinlock_check_need_init.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_spinlock_check_need_init.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_spinlock_check_need_init.c --- ptw32_spinlock_check_need_init.c 1 Jan 2005 14:36:18 -0000 1.5 +++ ptw32_spinlock_check_need_init.c 1 Mar 2011 19:07:56 -0000 @@ -38,7 +38,7 @@ #include "implement.h" -INLINE int +EXTERN_INLINE int ptw32_spinlock_check_need_init (pthread_spinlock_t * lock) { int result = 0; Index: ptw32_threadStart.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_threadStart.c,v retrieving revision 1.10 diff -u -r1.10 ptw32_threadStart.c --- ptw32_threadStart.c 15 May 2005 15:28:27 -0000 1.10 +++ ptw32_threadStart.c 1 Mar 2011 19:07:56 -0000 @@ -344,7 +344,7 @@ #endif #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex ((unsigned) status); + _endthreadex ((unsigned)(UINT_PTR) status); #else _endthread (); #endif @@ -354,7 +354,7 @@ */ #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) - return (unsigned) status; + return (unsigned)(UINT_PTR) status; #endif } /* ptw32_threadStart */ Index: ptw32_throw.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_throw.c,v retrieving revision 1.10 diff -u -r1.10 ptw32_throw.c --- ptw32_throw.c 6 Jun 2008 00:23:20 -0000 1.10 +++ ptw32_throw.c 1 Mar 2011 19:07:56 -0000 @@ -79,12 +79,12 @@ switch (exception) { case PTW32_EPS_CANCEL: - exitCode = (unsigned) PTHREAD_CANCELED; + exitCode = (unsigned)(UINT_PTR) PTHREAD_CANCELED; break; case PTW32_EPS_EXIT: if (NULL != sp) { - exitCode = (unsigned) sp->exitStatus; + exitCode = (unsigned)(UINT_PTR) sp->exitStatus; } break; } @@ -166,7 +166,7 @@ #else - return (DWORD) NULL; + return (DWORD)(DWORD_PTR) NULL; #endif } Index: ptw32_timespec.c =================================================================== RCS file: /cvs/pthreads-win32/pthreads/ptw32_timespec.c,v retrieving revision 1.5 diff -u -r1.5 ptw32_timespec.c --- ptw32_timespec.c 1 Jan 2005 14:36:18 -0000 1.5 +++ ptw32_timespec.c 1 Mar 2011 19:07:56 -0000 @@ -47,7 +47,7 @@ #define PTW32_TIMESPEC_TO_FILETIME_OFFSET \ ( ((LONGLONG) 27111902 << 32) + (LONGLONG) 3577643008 ) -INLINE void +EXTERN_INLINE void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft) /* * ------------------------------------------------------------------- @@ -62,7 +62,7 @@ + (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET; } -INLINE void +EXTERN_INLINE void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts) /* * -------------------------------------------------------------------