From 1183e5acfa10c7bda1dc39034d6e2fa6dec6016f Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 6 Mar 2011 10:46:44 +0000 Subject: 64 bit compatibility (mingw64) --- ChangeLog | 6 +++++ GNUmakefile | 2 +- README.NONPORTABLE | 4 ++-- autostatic.c | 6 ++--- config.h | 5 +++- create.c | 6 ++--- global.c | 2 -- implement.h | 49 +++++++++---------------------------- pthread.h | 9 ++++--- pthread_exit.c | 2 +- pthread_win32_attach_detach_np.c | 31 ------------------------ ptw32_MCS_lock.c | 28 ++++++++++------------ ptw32_relmillisecs.c | 6 ++++- ptw32_threadDestroy.c | 2 +- ptw32_threadStart.c | 8 +++---- ptw32_throw.c | 6 ++--- sched.h | 7 ++++-- semaphore.h | 5 +++- tests/ChangeLog | 6 +++++ tests/GNUmakefile | 52 +++++++++++++++++++++++++++------------- tests/barrier5.c | 4 ++-- tests/benchtest1.c | 9 +++++-- tests/benchtest2.c | 9 +++++-- tests/benchtest3.c | 9 +++++-- tests/benchtest4.c | 9 +++++-- tests/benchtest5.c | 9 +++++-- tests/cancel3.c | 8 +++---- tests/cancel4.c | 8 +++---- tests/cancel5.c | 10 ++++---- tests/cancel6a.c | 8 +++---- tests/cancel6d.c | 10 ++++---- tests/cancel7.c | 6 +++-- tests/cancel8.c | 6 +++-- tests/cancel9.c | 6 ++--- tests/condvar2.c | 4 ++++ tests/condvar2_1.c | 6 ++++- tests/condvar3.c | 4 ++++ tests/condvar3_1.c | 6 ++++- tests/condvar3_2.c | 6 ++++- tests/condvar3_3.c | 6 ++++- tests/condvar4.c | 4 ++++ tests/condvar5.c | 4 ++++ tests/condvar6.c | 4 ++++ tests/condvar7.c | 4 ++++ tests/condvar8.c | 4 ++++ tests/condvar9.c | 4 ++++ tests/delay2.c | 4 ++-- tests/detach1.c | 4 ++-- tests/exception1.c | 18 +++++++------- tests/exit3.c | 2 +- tests/exit4.c | 2 +- tests/exit5.c | 2 +- tests/join1.c | 4 ++-- tests/join2.c | 2 +- tests/join3.c | 2 +- tests/mutex4.c | 4 ++-- tests/mutex8.c | 4 ++++ tests/mutex8e.c | 4 ++++ tests/mutex8n.c | 4 ++++ tests/mutex8r.c | 4 ++++ tests/once2.c | 6 ++--- tests/once3.c | 6 ++--- tests/reuse1.c | 2 +- tests/rwlock2_t.c | 4 ++++ tests/rwlock3_t.c | 4 ++++ tests/rwlock4_t.c | 4 ++++ tests/rwlock5_t.c | 4 ++++ tests/rwlock6.c | 4 ++-- tests/rwlock6_t.c | 12 ++++++---- tests/rwlock6_t2.c | 20 +++++++++------- tests/rwlock7.c | 11 ++++++--- tests/rwlock8.c | 11 ++++++--- tests/sizes.c | 36 ++++++++++++++-------------- tests/spin3.c | 4 ++-- tests/spin4.c | 17 +++++++++---- tests/stress1.c | 10 +++++--- 76 files changed, 374 insertions(+), 250 deletions(-) diff --git a/ChangeLog b/ChangeLog index b937403..be0a351 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-06 Ross Johnson + + * several (MINGW64): Cast and call fixups for 64 bit compatibility; + clean build via x86_64-w64-mingw32 cross toolchain on Linux i686 + targeting x86_64 win64. + 2011-03-04 Ross Johnson * implement.h (PTW32_INTERLOCKED_*): Mingw32 does not provide diff --git a/GNUmakefile b/GNUmakefile index 652edb8..ceffd9f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -64,7 +64,7 @@ XOPT = 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 diff --git a/README.NONPORTABLE b/README.NONPORTABLE index 85195e1..35ff44f 100644 --- a/README.NONPORTABLE +++ b/README.NONPORTABLE @@ -75,11 +75,11 @@ pthread_getw32threadhandle_np(pthread_t thread); DWORD pthread_getw32threadid_np (pthread_t thread) - Returns the win32 thread ID that the POSIX + Returns the Windows native thread ID that the POSIX thread "thread" is running as. Only valid when the library is built where - ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) + ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) and otherwise returns 0. diff --git a/autostatic.c b/autostatic.c index b68c5af..ab9326a 100755 --- a/autostatic.c +++ b/autostatic.c @@ -36,7 +36,7 @@ #ifdef PTW32_STATIC_LIB -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) #include "pthread.h" #include "implement.h" @@ -52,7 +52,7 @@ static void on_process_exit(void) pthread_win32_process_detach_np (); } -#if defined(__MINGW32__) +#if defined(__MINGW64__) || defined(__MINGW32__) # define attribute_section(a) __attribute__((section(a))) #elif defined(_MSC_VER) # define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a)) @@ -64,6 +64,6 @@ attribute_section(".dtors") void *gcc_dtor = on_process_exit; attribute_section(".CRT$XCU") void *msc_ctor = on_process_init; attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit; -#endif /* defined(__MINGW32__) || defined(_MSC_VER) */ +#endif /* defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) */ #endif /* PTW32_STATIC_LIB */ diff --git a/config.h b/config.h index 402b963..0d1e1be 100644 --- a/config.h +++ b/config.h @@ -130,7 +130,10 @@ #define HAVE_C_INLINE #endif -#ifdef __MINGW32__ +#if defined(__MINGW64__) +#define HAVE_MODE_T +#define HAVE_STRUCT_TIMESPEC +#elif defined(__MINGW32__) #define HAVE_MODE_T #endif diff --git a/create.c b/create.c index 55b932a..dfc6967 100644 --- a/create.c +++ b/create.c @@ -200,7 +200,7 @@ pthread_create (pthread_t * tid, * finished with it here. */ -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) tp->threadH = threadH = @@ -225,7 +225,7 @@ pthread_create (pthread_t * tid, } } -#else /* __MINGW32__ && ! __MSVCRT__ */ +#else /* * This lock will force pthread_threadStart() to wait until we have @@ -265,7 +265,7 @@ pthread_create (pthread_t * tid, (void) pthread_mutex_unlock (&tp->cancelLock); -#endif /* __MINGW32__ && ! __MSVCRT__ */ +#endif result = (threadH != 0) ? 0 : EAGAIN; diff --git a/global.c b/global.c index 60ccaff..f423377 100644 --- a/global.c +++ b/global.c @@ -52,8 +52,6 @@ int ptw32_concurrency = 0; /* What features have been auto-detaected */ int ptw32_features = 0; -BOOL ptw32_smp_system = PTW32_TRUE; /* Safer if assumed true initially. */ - /* * Function pointer to QueueUserAPCEx if it exists, otherwise * it will be set at runtime to a substitute routine which cannot unblock diff --git a/implement.h b/implement.h index 9e449cb..5df0f93 100644 --- a/implement.h +++ b/implement.h @@ -82,7 +82,7 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #define INLINE #endif -#if defined (__MINGW32__) || (_MSC_VER >= 1300) +#if defined (__MINGW64__) || defined(__MINGW32__) || (_MSC_VER >= 1300) #define PTW32_INTERLOCKED_LONG long #define PTW32_INTERLOCKED_LPLONG long* #else @@ -90,7 +90,7 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #define PTW32_INTERLOCKED_LPLONG PVOID* #endif -#if defined(__MINGW32__) +#if defined(__MINGW64__) || defined(__MINGW32__) #include #elif defined(__BORLANDC__) #define int64_t ULONGLONG @@ -511,11 +511,6 @@ struct ThreadKeyAssoc #define PTW32_MIN(a,b) ((a)>(b)?(b):(a)) -/* Declared in global.c */ -extern PTW32_INTERLOCKED_LONG (WINAPI * - ptw32_interlocked_compare_exchange) - (PTW32_INTERLOCKED_LPLONG, PTW32_INTERLOCKED_LONG, PTW32_INTERLOCKED_LONG); - /* Declared in pthread_cancel.c */ extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD); @@ -536,8 +531,6 @@ extern int ptw32_concurrency; extern int ptw32_features; -extern BOOL ptw32_smp_system; /* True: SMP system, False: Uni-processor system */ - extern CRITICAL_SECTION ptw32_thread_reuse_lock; extern CRITICAL_SECTION ptw32_mutex_test_init_lock; extern CRITICAL_SECTION ptw32_cond_list_lock; @@ -601,7 +594,7 @@ extern "C" void ptw32_rwlock_cancelwrwait (void *arg); -#if ! defined (__MINGW32__) || defined (__MSVCRT__) +#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) unsigned __stdcall #else void @@ -727,24 +720,12 @@ extern "C" # define PTW32_INTERLOCKED_EXCHANGE(location, value) \ ({ \ __typeof (value) _result; \ - (ptw32_smp_system) ? ({ \ __asm__ __volatile__ \ ( \ "xchgl %0,(%1)" \ :"=r" (_result) \ :"r" (location), "0" (value) \ :"memory", "cc"); \ - }) : ({ \ - __asm__ __volatile__ \ - ( \ - "0:\n\t" \ - "movl %1,%%eax\n\t" \ - "cmpxchgl %2,(%1)\n\t" \ - "jnz 0b" \ - :"=&a" (_result) \ - :"r" (location), "r" (value) \ - :"memory", "cc"); \ - }); \ _result; \ }) # define PTW32_INTERLOCKED_EXCHANGE_ADD(location, value) \ @@ -811,24 +792,12 @@ extern "C" # define PTW32_INTERLOCKED_EXCHANGE64(location, value) \ ({ \ __typeof (value) _result; \ - (ptw32_smp_system) ? ({ \ __asm__ __volatile__ \ ( \ "xchgq %0,(%1)" \ :"=r" (_result) \ :"r" (location), "0" (value) \ :"memory", "cc"); \ - }) : ({ \ - __asm__ __volatile__ \ - ( \ - "0:\n\t" \ - "movq %1,%%eax\n\t" \ - "cmpxchgq %2,(%1)\n\t" \ - "jnz 0b" \ - :"=&a" (_result) \ - :"r" (location), "r" (value) \ - :"memory", "cc"); \ - }); \ _result; \ }) # define PTW32_INTERLOCKED_EXCHANGE_ADD64(location, value) \ @@ -867,11 +836,15 @@ extern "C" :"memory", "cc"); \ _temp - 1; \ }) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR PTW32_INTERLOCKED_COMPARE_EXCHANGE64 -# define PTW32_INTERLOCKED_EXCHANGE_PTR PTW32_INTERLOCKED_EXCHANGE64 +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ + PTW32_INTERLOCKED_COMPARE_EXCHANGE64(location, (size_t)value, (size_t)comparand) +# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ + PTW32_INTERLOCKED_EXCHANGE64(location, (size_t)value) # else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR PTW32_INTERLOCKED_COMPARE_EXCHANGE -# define PTW32_INTERLOCKED_EXCHANGE_PTR PTW32_INTERLOCKED_EXCHANGE +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ + PTW32_INTERLOCKED_COMPARE_EXCHANGE(location, (size_t)value, (size_t)comparand) +# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ + PTW32_INTERLOCKED_EXCHANGE(location, (size_t)value) # endif #else # define PTW32_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange diff --git a/pthread.h b/pthread.h index d487340..1002af3 100644 --- a/pthread.h +++ b/pthread.h @@ -190,7 +190,7 @@ */ /* Try to avoid including windows.h */ -#if defined(__MINGW32__) && defined(__cplusplus) +#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus) #define PTW32_INCLUDE_WINDOWS_H #endif @@ -245,7 +245,10 @@ enum { # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif @@ -303,7 +306,7 @@ enum { #endif #ifndef HAVE_STRUCT_TIMESPEC -#define HAVE_STRUCT_TIMESPEC 1 +#define HAVE_STRUCT_TIMESPEC #ifndef _TIMESPEC_DEFINED #define _TIMESPEC_DEFINED struct timespec { diff --git a/pthread_exit.c b/pthread_exit.c index a3f7a03..a2d7f8f 100644 --- a/pthread_exit.c +++ b/pthread_exit.c @@ -88,7 +88,7 @@ pthread_exit (void *value_ptr) * Implicit POSIX handles are cleaned up in ptw32_throw() now. */ -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex ((unsigned) (size_t) value_ptr); #else _endthread (); diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index bb83fd7..8116dd7 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -51,8 +51,6 @@ BOOL pthread_win32_process_attach_np () { BOOL result = TRUE; - DWORD_PTR vProcessCPUs; - DWORD_PTR vSystemCPUs; result = ptw32_processInitialize (); @@ -62,35 +60,6 @@ pthread_win32_process_attach_np () ptw32_features = 0; - -#if defined(NEED_PROCESS_AFFINITY_MASK) - - ptw32_smp_system = PTW32_FALSE; - -#else - - if (GetProcessAffinityMask (GetCurrentProcess (), - &vProcessCPUs, &vSystemCPUs)) - { - int CPUs = 0; - DWORD_PTR bit; - - for (bit = 1; bit != 0; bit <<= 1) - { - if (vSystemCPUs & bit) - { - CPUs++; - } - } - ptw32_smp_system = (CPUs > 1); - } - else - { - ptw32_smp_system = PTW32_FALSE; - } - -#endif - /* * Load QUSEREX.DLL and try to get address of QueueUserAPCEx */ diff --git a/ptw32_MCS_lock.c b/ptw32_MCS_lock.c index 55e4565..bb942ba 100644 --- a/ptw32_MCS_lock.c +++ b/ptw32_MCS_lock.c @@ -183,12 +183,8 @@ 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 *) -#ifndef _WIN64 - PTW32_INTERLOCKED_EXCHANGE_ADD((LPLONG)&node->next, 0); /* MBR fence */ -#else - PTW32_INTERLOCKED_EXCHANGE_ADD64((LONG64 *)&node->next, 0); /* MBR fence */ -#endif + ptw32_mcs_local_node_t *next = (ptw32_mcs_local_node_t *)(size_t) + PTW32_INTERLOCKED_EXCHANGE_ADD((LPLONG)&node->next, 0); /* MBR fence */ if (0 == next) { @@ -205,12 +201,8 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) /* wait for successor */ ptw32_mcs_flag_wait(&node->nextFlag); - next = (ptw32_mcs_local_node_t *) -#ifndef _WIN64 + next = (ptw32_mcs_local_node_t *)(size_t) PTW32_INTERLOCKED_EXCHANGE_ADD((LPLONG)&node->next, 0); /* MBR fence */ -#else - PTW32_INTERLOCKED_EXCHANGE_ADD64((LONG64 *)&node->next, 0); /* MBR fence */ -#endif } /* pass the lock */ @@ -228,10 +220,10 @@ ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * no node->readyFlag = 0; node->next = 0; /* initially, no successor */ - return ((PTW32_INTERLOCKED_LPLONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE( + return ((PTW32_INTERLOCKED_LPLONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( (PTW32_INTERLOCKED_LPLONG)lock, - (PTW32_INTERLOCKED_LONG)node, - (PTW32_INTERLOCKED_LONG)0) + (PTW32_INTERLOCKED_LPLONG)node, + (PTW32_INTERLOCKED_LPLONG)0) == (PTW32_INTERLOCKED_LPLONG)0) ? 0 : EBUSY; } @@ -254,9 +246,13 @@ ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node new_node->readyFlag = 0; /* Not needed - we were waiting on this */ new_node->next = 0; +#if defined(_WIN64) + if ((ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_COMPARE_EXCHANGE64((PTW32_INTERLOCKED_LPLONG)new_node->lock, +#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 + (size_t)(PTW32_INTERLOCKED_LPLONG)new_node, + (size_t)(PTW32_INTERLOCKED_LPLONG)old_node) != old_node) { /* * A successor has queued after us, so wait for them to link to us diff --git a/ptw32_relmillisecs.c b/ptw32_relmillisecs.c index dbc30a2..c9d39f3 100644 --- a/ptw32_relmillisecs.c +++ b/ptw32_relmillisecs.c @@ -54,7 +54,11 @@ ptw32_relmillisecs (const struct timespec * abstime) FILETIME ft; SYSTEMTIME st; #else /* ! NEED_FTIME */ +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif #endif /* NEED_FTIME */ @@ -93,7 +97,7 @@ ptw32_relmillisecs (const struct timespec * abstime) #ifdef _MSC_VER _ftime64_s(&currSysTime); -#elif defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0601 +#elif (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 _ftime64(&currSysTime); #else _ftime(&currSysTime); diff --git a/ptw32_threadDestroy.c b/ptw32_threadDestroy.c index eb9abfc..9e3b688 100644 --- a/ptw32_threadDestroy.c +++ b/ptw32_threadDestroy.c @@ -67,7 +67,7 @@ ptw32_threadDestroy (pthread_t thread) (void) pthread_mutex_destroy(&threadCopy.cancelLock); (void) pthread_mutex_destroy(&threadCopy.threadLock); -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) /* * See documentation for endthread vs endthreadex. */ diff --git a/ptw32_threadStart.c b/ptw32_threadStart.c index 8121d5a..8dcede3 100644 --- a/ptw32_threadStart.c +++ b/ptw32_threadStart.c @@ -116,7 +116,7 @@ ptw32_terminate () #endif -#if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__)) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined (__DMC__)) unsigned __stdcall #else @@ -148,7 +148,7 @@ ptw32_threadStart (void *vthreadParms) free (threadParms); -#if defined (__MINGW32__) && ! defined (__MSVCRT__) +#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__) /* * beginthread does not return the thread id and is running * before it returns us the thread handle, and so we do it here. @@ -343,7 +343,7 @@ ptw32_threadStart (void *vthreadParms) (void) pthread_win32_thread_detach_np (); #endif -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex ((unsigned)(size_t) status); #else _endthread (); @@ -353,7 +353,7 @@ ptw32_threadStart (void *vthreadParms) * Never reached. */ -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) return (unsigned)(size_t) status; #endif diff --git a/ptw32_throw.c b/ptw32_throw.c index 63f45f1..20068a7 100644 --- a/ptw32_throw.c +++ b/ptw32_throw.c @@ -73,7 +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__) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) unsigned exitCode = 0; switch (exception) @@ -96,7 +96,7 @@ ptw32_throw (DWORD exception) #endif -#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) +#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) _endthreadex (exitCode); #else _endthread (); @@ -166,7 +166,7 @@ ptw32_get_exception_services_code (void) #else - return (DWORD) NULL; + return (DWORD)0; #endif } diff --git a/sched.h b/sched.h index 7c78a85..b85a967 100644 --- a/sched.h +++ b/sched.h @@ -96,7 +96,10 @@ # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif @@ -113,7 +116,7 @@ #endif #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ -#if defined(__MINGW32__) || defined(_UWIN) +#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) # if PTW32_LEVEL >= PTW32_LEVEL_MAX /* For pid_t */ # include diff --git a/semaphore.h b/semaphore.h index 52438c7..891c929 100644 --- a/semaphore.h +++ b/semaphore.h @@ -95,7 +95,10 @@ # define NEED_ERRNO # define NEED_SEM # endif -# if defined(_UWIN) || defined(__MINGW32__) +# if defined(__MINGW64__) +# define HAVE_STRUCT_TIMESPEC +# define HAVE_MODE_T +# elif defined(_UWIN) || defined(__MINGW32__) # define HAVE_MODE_T # endif #endif diff --git a/tests/ChangeLog b/tests/ChangeLog index a42405f..1ca1711 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2011-03-06 Ross Johnson + + * several (MINGW64): Cast and call fixups for 64 bit compatibility; + clean build via x86_64-w64-mingw32 cross toolchain on Linux + i686 targeting x86_64 win64. + 2011-03-04 Ross Johnson * condvar3_2.c: abstime.tv_sec operation warning fixed. diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 013351f..159e376 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -37,15 +37,21 @@ CP = cp -f MV = mv -f RM = rm -f CAT = cat -#CP = copy -#MV = rename -#RM = erase -#CAT = type MKDIR = mkdir TOUCH = echo Passed > ECHO = @echo MAKE = make -k +# For cross compiling use e.g. +# # make CROSS=i386-mingw32msvc- clean GC +CROSS = + +AR = $(CROSS)ar +DLLTOOL = $(CROSS)dlltool +CC = $(CROSS)gcc +CXX = $(CROSS)g++ +RANLIB = $(CROSS)ranlib + # # Mingw32 # @@ -56,6 +62,9 @@ CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS) BUILD_DIR = .. INCLUDES = -I. +.INTERMEDIATE: %.exe %.pass +.SECONDARY: %.exe %.pass +.PRECIOUS: %.exe %.pass TEST = GC @@ -145,6 +154,9 @@ STATICTESTS = \ exception1 exception2 exception3 \ cancel9 create3 stress1 +ALLTESTS = $(TESTS) $(BENCHTESTS) + +ASM = $(ALLTESTS:%=%.s) PASSES = $(TESTS:%=%.pass) BENCHRESULTS = $(BENCHTESTS:%=%.bench) STRESSRESULTS = $(STRESSTESTS:%=%.pass) @@ -167,34 +179,40 @@ all: @ $(MAKE) clean GCE GC: - $(MAKE) TEST=GC CC=gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass + +GC-asm: + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-asm GCE: - $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass + $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass GCX: - $(MAKE) TEST=GC CC=g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass + $(MAKE) TEST=GC CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass GC-bench: - $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench GCE-bench: - $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench + $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench GC-debug: - $(MAKE) TEST=GC CC=gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass GC-static: - $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static GC-stress: $(ECHO) Stress tests can take a long time since they are trying to $(ECHO) expose weaknesses that may be intermittant or statistically rare. $(ECHO) A pass does not prove correctness, but may give greater confidence. - $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress + $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress GCE-stress: - $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress + $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress + +all-asm: $(ASM) + @ $(ECHO) ALL TESTS PASSED! Congratulations! all-pass: $(PASSES) @ $(ECHO) ALL TESTS PASSED! Congratulations! @@ -347,20 +365,20 @@ valid2.pass: valid1.pass sizes.pass: sizes.exe @ $(ECHO) Running $* - $< > SIZES.$(TEST) + ./$< > SIZES.$(TEST) @ $(CAT) SIZES.$(TEST) @ $(ECHO) Passed @ $(TOUCH) $@ %.pass: %.exe @ $(ECHO) Running $* - $* + ./$* @ $(ECHO) Passed @ $(TOUCH) $@ %.bench: $(LIB) $(DLL) $(HDR) $(QAPC) $(XXLIBS) %.exe @ $(ECHO) Running $* - $* + ./$* @ $(ECHO) Done @ $(TOUCH) $@ @@ -373,6 +391,7 @@ sizes.pass: sizes.exe @ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES) %.s: %.c $(HDR) + @ $(ECHO) Compiling $@ @ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES) $(COPYFILES): @@ -397,6 +416,7 @@ clean: - $(RM) *.e - $(RM) *.i - $(RM) *.o + - $(RM) *.s - $(RM) *.so - $(RM) *.obj - $(RM) *.pdb diff --git a/tests/barrier5.c b/tests/barrier5.c index b64b7d7..7810638 100644 --- a/tests/barrier5.c +++ b/tests/barrier5.c @@ -56,7 +56,7 @@ func(void * crossings) int result; int serialThreads = 0; - while ((LONG)crossings >= (LONG)InterlockedIncrement((LPLONG)&totalThreadCrossings)) + while ((LONG)(size_t)crossings >= (LONG)InterlockedIncrement((LPLONG)&totalThreadCrossings)) { result = pthread_barrier_wait(&barrier); @@ -97,7 +97,7 @@ main() for (i = 1; i <= j; i++) { - assert(pthread_create(&t[i], NULL, func, (void *) Crossings) == 0); + assert(pthread_create(&t[i], NULL, func, (void *)(size_t)Crossings) == 0); } serialThreadsTotal = 0; diff --git a/tests/benchtest1.c b/tests/benchtest1.c index 21e8e64..ba4abc5 100644 --- a/tests/benchtest1.c +++ b/tests/benchtest1.c @@ -53,8 +53,13 @@ pthread_mutex_t mx; pthread_mutexattr_t ma; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif long durationMilliSecs; long overHeadMilliSecs = 0; int two = 2; diff --git a/tests/benchtest2.c b/tests/benchtest2.c index 10deca2..76df9a2 100644 --- a/tests/benchtest2.c +++ b/tests/benchtest2.c @@ -60,8 +60,13 @@ CRITICAL_SECTION cs1, cs2; pthread_mutexattr_t ma; long durationMilliSecs; long overHeadMilliSecs = 0; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif pthread_t worker; int running = 0; diff --git a/tests/benchtest3.c b/tests/benchtest3.c index 6ff3c90..faf0fdb 100644 --- a/tests/benchtest3.c +++ b/tests/benchtest3.c @@ -54,8 +54,13 @@ pthread_mutex_t mx; old_mutex_t ox; pthread_mutexattr_t ma; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif long durationMilliSecs; long overHeadMilliSecs = 0; diff --git a/tests/benchtest4.c b/tests/benchtest4.c index d64438d..53c529b 100644 --- a/tests/benchtest4.c +++ b/tests/benchtest4.c @@ -54,8 +54,13 @@ pthread_mutex_t mx; old_mutex_t ox; pthread_mutexattr_t ma; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif long durationMilliSecs; long overHeadMilliSecs = 0; diff --git a/tests/benchtest5.c b/tests/benchtest5.c index 0d5c360..83d59c1 100644 --- a/tests/benchtest5.c +++ b/tests/benchtest5.c @@ -53,8 +53,13 @@ sem_t sema; HANDLE w32sema; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif long durationMilliSecs; long overHeadMilliSecs = 0; int one = 1; diff --git a/tests/cancel3.c b/tests/cancel3.c index ff83c4b..8c7bd9f 100644 --- a/tests/cancel3.c +++ b/tests/cancel3.c @@ -96,7 +96,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread (void *arg) { - int result = ((int) PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); bag_t *bag = (bag_t *) arg; assert (bag == &threadbag[bag->threadnum]); @@ -116,7 +116,7 @@ mythread (void *arg) for (bag->count = 0; bag->count < 100; bag->count++) Sleep (100); - return (void *) (size_t)result; + return result; } int @@ -180,9 +180,9 @@ main () * a return value of PTHREAD_CANCELED confirms that async * cancelation succeeded. */ - assert (pthread_join (t[i], (void *) &result) == 0); + assert (pthread_join (t[i], &result) == 0); - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); + fail = (result != PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel4.c b/tests/cancel4.c index 28c5d2e..893f33b 100644 --- a/tests/cancel4.c +++ b/tests/cancel4.c @@ -98,7 +98,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread(void * arg) { - int result = ((int)PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); @@ -118,7 +118,7 @@ mythread(void * arg) for (bag->count = 0; bag->count < 20; bag->count++) Sleep(100); - return (void *) (size_t)result; + return result; } int @@ -180,9 +180,9 @@ main() * a return value of PTHREAD_CANCELED indicates that async * cancelation occurred. */ - assert(pthread_join(t[i], (void *) &result) == 0); + assert(pthread_join(t[i], &result) == 0); - fail = ((int)(size_t)result == (int) PTHREAD_CANCELED); + fail = (result == PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel5.c b/tests/cancel5.c index 17497dd..6c39516 100644 --- a/tests/cancel5.c +++ b/tests/cancel5.c @@ -96,7 +96,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread (void *arg) { - int result = ((int) PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); bag_t *bag = (bag_t *) arg; assert (bag == &threadbag[bag->threadnum]); @@ -116,7 +116,7 @@ mythread (void *arg) for (bag->count = 0; bag->count < 100; bag->count++) Sleep (100); - return (void *) (size_t)result; + return result; } int @@ -171,16 +171,16 @@ main () for (i = 1; i <= NUMTHREADS; i++) { int fail = 0; - void* result = (void*)0; + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); /* * The thread does not contain any cancelation points, so * a return value of PTHREAD_CANCELED confirms that async * cancelation succeeded. */ - assert (pthread_join (t[i], (void *) &result) == 0); + assert (pthread_join (t[i], &result) == 0); - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); + fail = (result != PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel6a.c b/tests/cancel6a.c index ca79d40..58063d5 100644 --- a/tests/cancel6a.c +++ b/tests/cancel6a.c @@ -85,7 +85,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread(void * arg) { - int result = ((int)PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); @@ -105,7 +105,7 @@ mythread(void * arg) for (bag->count = 0; bag->count < 100; bag->count++) Sleep(100); - return (void *) (size_t)result; + return result; } int @@ -168,9 +168,9 @@ main() * a return value of PTHREAD_CANCELED confirms that async * cancelation succeeded. */ - assert(pthread_join(t[i], (void *) &result) == 0); + assert(pthread_join(t[i], &result) == 0); - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); + fail = (result != PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel6d.c b/tests/cancel6d.c index e22a3c5..3fd296a 100644 --- a/tests/cancel6d.c +++ b/tests/cancel6d.c @@ -86,7 +86,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread(void * arg) { - int result = ((int)PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); @@ -109,7 +109,7 @@ mythread(void * arg) pthread_testcancel(); } - return (void *) (size_t)result; + return result; } int @@ -125,7 +125,7 @@ main() { threadbag[i].started = 0; threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); + assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t) &threadbag[i]) == 0); } /* @@ -167,9 +167,9 @@ main() int fail = 0; void* result = (void*)0; - assert(pthread_join(t[i], (void *) &result) == 0); + assert(pthread_join(t[i], &result) == 0); - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); + fail = (result != PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel7.c b/tests/cancel7.c index fde8dab..5f1390f 100644 --- a/tests/cancel7.c +++ b/tests/cancel7.c @@ -118,7 +118,9 @@ Win32thread(void * arg) pthread_testcancel(); } +#if ! defined (__MINGW32__) || defined (__MSVCRT__) return 0; +#endif } int @@ -188,13 +190,13 @@ main() /* * Can't get a result code. */ - result = (int) PTHREAD_CANCELED; + result = (int)(size_t)PTHREAD_CANCELED; #endif assert(threadbag[i].self.p != NULL); assert(pthread_kill(threadbag[i].self, 0) == ESRCH); - fail = (result != (int) PTHREAD_CANCELED); + fail = (result != (int)(size_t)PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel8.c b/tests/cancel8.c index 72b9287..7204d19 100644 --- a/tests/cancel8.c +++ b/tests/cancel8.c @@ -119,7 +119,9 @@ Win32thread(void * arg) pthread_cond_wait(&CV, &CVLock); pthread_cleanup_pop(1); +#if ! defined (__MINGW32__) || defined (__MSVCRT__) return 0; +#endif } int @@ -189,13 +191,13 @@ main() /* * Can't get a result code. */ - result = (int) PTHREAD_CANCELED; + result = (int)(size_t)PTHREAD_CANCELED; #endif assert(threadbag[i].self.p != NULL); assert(pthread_kill(threadbag[i].self, 0) == ESRCH); - fail = (result != (int) PTHREAD_CANCELED); + fail = (result != (int)(size_t)PTHREAD_CANCELED); if (fail) { diff --git a/tests/cancel9.c b/tests/cancel9.c index d4567ef..b009161 100644 --- a/tests/cancel9.c +++ b/tests/cancel9.c @@ -172,7 +172,7 @@ main () Sleep (100); assert (pthread_cancel (t) == 0); assert (pthread_join (t, &result) == 0); - assert ((int)(size_t)result == (int)PTHREAD_CANCELED && "test_sleep" != NULL); + assert (result == PTHREAD_CANCELED && "test_sleep" != NULL); printf ("Cancel waiting thread.\n"); assert (pthread_create (&t, NULL, test_wait, NULL) == 0); @@ -180,7 +180,7 @@ main () Sleep (100); assert (pthread_cancel (t) == 0); assert (pthread_join (t, &result) == 0); - assert ((int)(size_t)result == (int)PTHREAD_CANCELED && "test_wait"); + assert (result == PTHREAD_CANCELED && "test_wait"); printf ("Cancel blocked thread (blocked on network I/O).\n"); assert (pthread_create (&t, NULL, test_udp, NULL) == 0); @@ -188,7 +188,7 @@ main () Sleep (100); assert (pthread_cancel (t) == 0); assert (pthread_join (t, &result) == 0); - assert ((int)(size_t)result == (int)PTHREAD_CANCELED && "test_udp" != NULL); + assert (result == PTHREAD_CANCELED && "test_udp" != NULL); } else { diff --git a/tests/condvar2.c b/tests/condvar2.c index 9bd0aba..dd9851b 100644 --- a/tests/condvar2.c +++ b/tests/condvar2.c @@ -87,7 +87,11 @@ int main() { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); diff --git a/tests/condvar2_1.c b/tests/condvar2_1.c index 2cc563a..7d938f8 100644 --- a/tests/condvar2_1.c +++ b/tests/condvar2_1.c @@ -106,7 +106,11 @@ main() int i; pthread_t t[NUMTHREADS + 1]; void* result = (void*)0; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); @@ -125,7 +129,7 @@ main() for (i = 1; i <= NUMTHREADS; i++) { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); + assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); } assert(pthread_mutex_unlock(&mutex) == 0); diff --git a/tests/condvar3.c b/tests/condvar3.c index 47077b3..0a6c152 100644 --- a/tests/condvar3.c +++ b/tests/condvar3.c @@ -112,7 +112,11 @@ main() { pthread_t t[NUMTHREADS]; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert((t[0] = pthread_self()).p != NULL); diff --git a/tests/condvar3_1.c b/tests/condvar3_1.c index fe522ce..e747a01 100644 --- a/tests/condvar3_1.c +++ b/tests/condvar3_1.c @@ -127,7 +127,11 @@ main() int i; pthread_t t[NUMTHREADS + 1]; void* result = (void*)0; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); @@ -148,7 +152,7 @@ main() for (i = 1; i <= NUMTHREADS; i++) { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); + assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); } do { diff --git a/tests/condvar3_2.c b/tests/condvar3_2.c index cc21e9f..399faec 100644 --- a/tests/condvar3_2.c +++ b/tests/condvar3_2.c @@ -128,7 +128,11 @@ main() int i; pthread_t t[NUMTHREADS + 1]; void* result = (void*)0; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); @@ -145,7 +149,7 @@ main() for (i = 1; i <= NUMTHREADS; i++) { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); + assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); } assert(pthread_mutex_unlock(&mutex) == 0); diff --git a/tests/condvar3_3.c b/tests/condvar3_3.c index af95046..ae1ed70 100644 --- a/tests/condvar3_3.c +++ b/tests/condvar3_3.c @@ -87,7 +87,11 @@ int main() int rc; struct timespec abstime = { 0, 0 }; - struct _timeb currSysTime; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else + struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cnd, 0) == 0); diff --git a/tests/condvar4.c b/tests/condvar4.c index 42a8168..8d9fbe9 100644 --- a/tests/condvar4.c +++ b/tests/condvar4.c @@ -112,7 +112,11 @@ main() { pthread_t t[NUMTHREADS]; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar5.c b/tests/condvar5.c index c1cd3e5..acbc65a 100644 --- a/tests/condvar5.c +++ b/tests/condvar5.c @@ -111,7 +111,11 @@ main() { pthread_t t[NUMTHREADS]; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar6.c b/tests/condvar6.c index e7be0da..ed16e5d 100644 --- a/tests/condvar6.c +++ b/tests/condvar6.c @@ -144,7 +144,11 @@ main() int i; pthread_t t[NUMTHREADS + 1]; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar7.c b/tests/condvar7.c index 8df30cb..3975e2c 100644 --- a/tests/condvar7.c +++ b/tests/condvar7.c @@ -154,7 +154,11 @@ main() int i; pthread_t t[NUMTHREADS + 1]; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar8.c b/tests/condvar8.c index 564a3ea..96978f2 100644 --- a/tests/condvar8.c +++ b/tests/condvar8.c @@ -155,7 +155,11 @@ main() int first, last; pthread_t t[NUMTHREADS + 1]; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert((t[0] = pthread_self()).p != NULL); diff --git a/tests/condvar9.c b/tests/condvar9.c index 8adffb6..dfcd158 100644 --- a/tests/condvar9.c +++ b/tests/condvar9.c @@ -163,7 +163,11 @@ main() int canceledThreads = 0; pthread_t t[NUMTHREADS + 1]; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; assert((t[0] = pthread_self()).p != NULL); diff --git a/tests/delay2.c b/tests/delay2.c index cdc70a6..2551336 100644 --- a/tests/delay2.c +++ b/tests/delay2.c @@ -58,7 +58,7 @@ func(void * arg) #pragma inline_depth() #endif - return (void *) 1; + return (void *)(size_t)1; } int @@ -75,7 +75,7 @@ main(int argc, char * argv[]) assert(pthread_mutex_unlock(&mx) == 0); assert(pthread_join(t, (void *) &result) == 0); - assert((int)(size_t)result == (int) PTHREAD_CANCELED); + assert(result == (void*)PTHREAD_CANCELED); return 0; } diff --git a/tests/detach1.c b/tests/detach1.c index 165c8c1..89756c7 100644 --- a/tests/detach1.c +++ b/tests/detach1.c @@ -46,7 +46,7 @@ enum { void * func(void * arg) { - int i = (int) arg; + int i = (int)(size_t)arg; Sleep(i * 10); @@ -65,7 +65,7 @@ main(int argc, char * argv[]) /* Create a few threads and then exit. */ for (i = 0; i < NUMTHREADS; i++) { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); + assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); } /* Some threads will finish before they are detached, some after. */ diff --git a/tests/exception1.c b/tests/exception1.c index 4ccc24c..a18e078 100644 --- a/tests/exception1.c +++ b/tests/exception1.c @@ -86,7 +86,7 @@ void * exceptionedThread(void * arg) { int dummy = 0; - int result = ((int)PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); /* Set to async cancelable */ assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); @@ -110,7 +110,7 @@ exceptionedThread(void * arg) __except (EXCEPTION_EXECUTE_HANDLER) { /* Should get into here. */ - result = ((int)PTHREAD_CANCELED + 2); + result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); } #elif defined(__cplusplus) try @@ -129,7 +129,7 @@ exceptionedThread(void * arg) #endif { /* Should get into here. */ - result = ((int)PTHREAD_CANCELED + 2); + result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); } #endif @@ -139,7 +139,7 @@ exceptionedThread(void * arg) void * canceledThread(void * arg) { - int result = ((int)PTHREAD_CANCELED + 1); + void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); int count; /* Set to async cancelable */ @@ -161,7 +161,7 @@ canceledThread(void * arg) __except (EXCEPTION_EXECUTE_HANDLER) { /* Should NOT get into here. */ - result = ((int)PTHREAD_CANCELED + 2); + result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); } #elif defined(__cplusplus) try @@ -180,7 +180,7 @@ canceledThread(void * arg) #endif { /* Should NOT get into here. */ - result = ((int)PTHREAD_CANCELED + 2); + result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); } #endif @@ -229,14 +229,14 @@ main() void* result = (void*)0; /* Canceled thread */ - assert(pthread_join(ct[i], (void *) &result) == 0); - assert(!(fail = ((int)(size_t)result != (int) PTHREAD_CANCELED))); + assert(pthread_join(ct[i], &result) == 0); + assert(!(fail = (result != PTHREAD_CANCELED))); failed = (failed || fail); /* Exceptioned thread */ assert(pthread_join(et[i], (void *) &result) == 0); - assert(!(fail = ((int)(size_t)result != ((int) PTHREAD_CANCELED + 2)))); + assert(!(fail = (result != (void*)((int)(size_t)PTHREAD_CANCELED + 2)))); failed = (failed || fail); } diff --git a/tests/exit3.c b/tests/exit3.c index 574a92d..a8b12c8 100644 --- a/tests/exit3.c +++ b/tests/exit3.c @@ -58,7 +58,7 @@ main(int argc, char * argv[]) /* Create a few threads and then exit. */ for (i = 0; i < 4; i++) { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); + assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); } Sleep(1000); diff --git a/tests/exit4.c b/tests/exit4.c index e8cd88a..06dd8b1 100644 --- a/tests/exit4.c +++ b/tests/exit4.c @@ -111,7 +111,7 @@ Win32thread(void * arg) /* * Doesn't return and doesn't create an implicit POSIX handle. */ - pthread_exit((void *) result); + pthread_exit((void *)(size_t)result); return 0; } diff --git a/tests/exit5.c b/tests/exit5.c index 15e1bc9..ac98f99 100644 --- a/tests/exit5.c +++ b/tests/exit5.c @@ -115,7 +115,7 @@ Win32thread(void * arg) /* * Doesn't return. */ - pthread_exit((void *) result); + pthread_exit((void *)(size_t)result); return 0; } diff --git a/tests/join1.c b/tests/join1.c index b00026a..631b604 100644 --- a/tests/join1.c +++ b/tests/join1.c @@ -41,7 +41,7 @@ void * func(void * arg) { - int i = (int) arg; + int i = (int)(size_t)arg; Sleep(i * 100); @@ -61,7 +61,7 @@ main(int argc, char * argv[]) /* Create a few threads and then exit. */ for (i = 0; i < 4; i++) { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); + assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); } /* Some threads will finish before they are joined, some after. */ diff --git a/tests/join2.c b/tests/join2.c index 036daf5..82682a8 100644 --- a/tests/join2.c +++ b/tests/join2.c @@ -55,7 +55,7 @@ main(int argc, char * argv[]) /* Create a few threads and then exit. */ for (i = 0; i < 4; i++) { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); + assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); } for (i = 0; i < 4; i++) diff --git a/tests/join3.c b/tests/join3.c index dc73e99..acdc5fe 100644 --- a/tests/join3.c +++ b/tests/join3.c @@ -55,7 +55,7 @@ main(int argc, char * argv[]) /* Create a few threads and then exit. */ for (i = 0; i < 4; i++) { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); + assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); } /* diff --git a/tests/mutex4.c b/tests/mutex4.c index 547d9cb..b728722 100644 --- a/tests/mutex4.c +++ b/tests/mutex4.c @@ -49,7 +49,7 @@ static pthread_mutex_t mutex1; void * unlocker(void * arg) { - int expectedResult = (int) arg; + int expectedResult = (int)(size_t)arg; wasHere++; assert(pthread_mutex_unlock(&mutex1) == expectedResult); @@ -72,7 +72,7 @@ main() /* * NORMAL (fast) mutexes don't check ownership. */ - assert(pthread_create(&t, NULL, unlocker, (void *) 0) == 0); + assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)0) == 0); assert(pthread_join(t, NULL) == 0); assert(pthread_mutex_unlock(&mutex1) == EPERM); assert(wasHere == 2); diff --git a/tests/mutex8.c b/tests/mutex8.c index f019006..9798f5a 100644 --- a/tests/mutex8.c +++ b/tests/mutex8.c @@ -44,7 +44,11 @@ static pthread_mutex_t mutex; void * locker(void * arg) { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8e.c b/tests/mutex8e.c index 4720bc6..0e1cbd7 100644 --- a/tests/mutex8e.c +++ b/tests/mutex8e.c @@ -52,7 +52,11 @@ static pthread_mutexattr_t mxAttr; void * locker(void * arg) { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8n.c b/tests/mutex8n.c index 193107e..c7141e3 100644 --- a/tests/mutex8n.c +++ b/tests/mutex8n.c @@ -52,7 +52,11 @@ static pthread_mutexattr_t mxAttr; void * locker(void * arg) { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8r.c b/tests/mutex8r.c index e48df5b..58242fe 100644 --- a/tests/mutex8r.c +++ b/tests/mutex8r.c @@ -52,7 +52,11 @@ static pthread_mutexattr_t mxAttr; void * locker(void * arg) { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/once2.c b/tests/once2.c index 248ccb1..84e3f4b 100644 --- a/tests/once2.c +++ b/tests/once2.c @@ -70,11 +70,11 @@ myfunc(void) void * mythread(void * arg) { - assert(pthread_once(&once[(int) arg], myfunc) == 0); + assert(pthread_once(&once[(int)(size_t)arg], myfunc) == 0); EnterCriticalSection(&numThreads.cs); numThreads.i++; LeaveCriticalSection(&numThreads.cs); - return 0; + return (void*)(size_t)0; } int @@ -91,7 +91,7 @@ main() once[j] = o; for (i = 0; i < NUM_THREADS; i++) - assert(pthread_create(&t[i][j], NULL, mythread, (void *) j) == 0); + assert(pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j) == 0); } for (j = 0; j < NUM_ONCE; j++) diff --git a/tests/once3.c b/tests/once3.c index c706f80..e1886c1 100644 --- a/tests/once3.c +++ b/tests/once3.c @@ -86,11 +86,11 @@ mythread(void * arg) * eventually cancels only when it becomes the new once thread. */ assert(pthread_cancel(pthread_self()) == 0); - assert(pthread_once(&once[(int) arg], myfunc) == 0); + assert(pthread_once(&once[(int)(size_t)arg], myfunc) == 0); EnterCriticalSection(&numThreads.cs); numThreads.i++; LeaveCriticalSection(&numThreads.cs); - return 0; + return (void*)(size_t)0; } int @@ -108,7 +108,7 @@ main() for (i = 0; i < NUM_THREADS; i++) { - assert(pthread_create(&t[i][j], NULL, mythread, (void *) j) == 0); + assert(pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j) == 0); } } diff --git a/tests/reuse1.c b/tests/reuse1.c index 2b9cf57..1a7dff0 100644 --- a/tests/reuse1.c +++ b/tests/reuse1.c @@ -107,7 +107,7 @@ main() for (i = 1; i < NUMTHREADS; i++) { washere = 0; - assert(pthread_create(&t, &attr, func, (void *) i) == 0); + assert(pthread_create(&t, &attr, func, (void *)(size_t)i) == 0); pthread_join(t, &result); assert((int)(size_t) result == i); assert(washere == 1); diff --git a/tests/rwlock2_t.c b/tests/rwlock2_t.c index f49879e..af7ef05 100644 --- a/tests/rwlock2_t.c +++ b/tests/rwlock2_t.c @@ -50,7 +50,11 @@ int main() { struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock3_t.c b/tests/rwlock3_t.c index f77fccb..60798dd 100644 --- a/tests/rwlock3_t.c +++ b/tests/rwlock3_t.c @@ -63,7 +63,11 @@ main() { pthread_t t; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock4_t.c b/tests/rwlock4_t.c index 5df5c05..cccfd27 100644 --- a/tests/rwlock4_t.c +++ b/tests/rwlock4_t.c @@ -63,7 +63,11 @@ main() { pthread_t t; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock5_t.c b/tests/rwlock5_t.c index 4e6d644..96b4348 100644 --- a/tests/rwlock5_t.c +++ b/tests/rwlock5_t.c @@ -65,7 +65,11 @@ main() { pthread_t t; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock6.c b/tests/rwlock6.c index 3f305e8..8861823 100644 --- a/tests/rwlock6.c +++ b/tests/rwlock6.c @@ -57,7 +57,7 @@ void * wrfunc(void * arg) ba = bankAccount; assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *) ba); + return ((void *)(size_t)ba); } void * rdfunc(void * arg) @@ -68,7 +68,7 @@ void * rdfunc(void * arg) ba = bankAccount; assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *) ba); + return ((void *)(size_t)ba); } int diff --git a/tests/rwlock6_t.c b/tests/rwlock6_t.c index 6151d75..4af85d9 100644 --- a/tests/rwlock6_t.c +++ b/tests/rwlock6_t.c @@ -55,14 +55,18 @@ void * wrfunc(void * arg) bankAccount += 10; assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *) bankAccount); + return ((void *)(size_t)bankAccount); } void * rdfunc(void * arg) { int ba = -1; struct timespec abstime = { 0, 0 }; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); @@ -85,7 +89,7 @@ void * rdfunc(void * arg) assert(pthread_rwlock_unlock(&rwlock1) == 0); } - return ((void *) ba); + return ((void *)(size_t)ba); } int @@ -104,11 +108,11 @@ main() assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); Sleep(500); - assert(pthread_create(&rdt1, NULL, rdfunc, (void *) 1) == 0); + assert(pthread_create(&rdt1, NULL, rdfunc, (void *)(size_t)1) == 0); Sleep(500); assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); Sleep(500); - assert(pthread_create(&rdt2, NULL, rdfunc, (void *) 2) == 0); + assert(pthread_create(&rdt2, NULL, rdfunc, (void *)(size_t)2) == 0); assert(pthread_join(wrt1, (void *) &wr1Result) == 0); assert(pthread_join(rdt1, (void *) &rd1Result) == 0); diff --git a/tests/rwlock6_t2.c b/tests/rwlock6_t2.c index 8d658b4..28de466 100644 --- a/tests/rwlock6_t2.c +++ b/tests/rwlock6_t2.c @@ -60,7 +60,7 @@ void * wrfunc(void * arg) Sleep(2000); bankAccount += 10; assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *) bankAccount); + return ((void *)(size_t)bankAccount); } else if ((int) (size_t)arg == 2) { @@ -68,7 +68,7 @@ void * wrfunc(void * arg) return ((void *) 100); } - return ((void *) -1); + return ((void *)(size_t)-1); } void * rdfunc(void * arg) @@ -77,7 +77,7 @@ void * rdfunc(void * arg) assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == ETIMEDOUT); - return ((void *) ba); + return ((void *)(size_t)ba); } int @@ -89,7 +89,11 @@ main() void* wr1Result = (void*)0; void* wr2Result = (void*)0; void* rdResult = (void*)0; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); @@ -101,15 +105,15 @@ main() bankAccount = 0; - assert(pthread_create(&wrt1, NULL, wrfunc, (void *) 1) == 0); + assert(pthread_create(&wrt1, NULL, wrfunc, (void *)(size_t)1) == 0); Sleep(100); assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); Sleep(100); - assert(pthread_create(&wrt2, NULL, wrfunc, (void *) 2) == 0); + assert(pthread_create(&wrt2, NULL, wrfunc, (void *)(size_t)2) == 0); - assert(pthread_join(wrt1, (void *) &wr1Result) == 0); - assert(pthread_join(rdt, (void *) &rdResult) == 0); - assert(pthread_join(wrt2, (void *) &wr2Result) == 0); + assert(pthread_join(wrt1, &wr1Result) == 0); + assert(pthread_join(rdt, &rdResult) == 0); + assert(pthread_join(wrt2, &wr2Result) == 0); assert((int)(size_t)wr1Result == 10); assert((int)(size_t)rdResult == 0); diff --git a/tests/rwlock7.c b/tests/rwlock7.c index 1e8fdf0..33e87e2 100644 --- a/tests/rwlock7.c +++ b/tests/rwlock7.c @@ -108,8 +108,13 @@ main (int argc, char *argv[]) int data_updates = 0; int seed = 1; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime1; + struct __timeb64 currSysTime2; +#else struct _timeb currSysTime1; struct _timeb currSysTime2; +#endif /* * Initialize the shared data. @@ -135,7 +140,7 @@ main (int argc, char *argv[]) threads[count].seed = 1 + rand_r (&seed) % 71; assert(pthread_create (&threads[count].thread_id, - NULL, thread_routine, (void*)&threads[count]) == 0); + NULL, thread_routine, (void*)(size_t)&threads[count]) == 0); } /* @@ -190,8 +195,8 @@ main (int argc, char *argv[]) PTW32_FTIME(&currSysTime2); printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", - currSysTime1.time,currSysTime1.millitm, - currSysTime2.time,currSysTime2.millitm, + (long)currSysTime1.time,currSysTime1.millitm, + (long)currSysTime2.time,currSysTime2.millitm, ((long)((currSysTime2.time*1000+currSysTime2.millitm) - (currSysTime1.time*1000+currSysTime1.millitm)))); diff --git a/tests/rwlock8.c b/tests/rwlock8.c index 207646c..28552ba 100644 --- a/tests/rwlock8.c +++ b/tests/rwlock8.c @@ -114,8 +114,13 @@ main (int argc, char *argv[]) int data_updates = 0; int seed = 1; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime1; + struct __timeb64 currSysTime2; +#else struct _timeb currSysTime1; struct _timeb currSysTime2; +#endif /* * Initialize the shared data. @@ -141,7 +146,7 @@ main (int argc, char *argv[]) threads[count].seed = 1 + rand_r (&seed) % 71; assert(pthread_create (&threads[count].thread_id, - NULL, thread_routine, (void*)&threads[count]) == 0); + NULL, thread_routine, (void*)(size_t)&threads[count]) == 0); } /* @@ -196,8 +201,8 @@ main (int argc, char *argv[]) PTW32_FTIME(&currSysTime2); printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", - currSysTime1.time,currSysTime1.millitm, - currSysTime2.time,currSysTime2.millitm, + (long)currSysTime1.time,currSysTime1.millitm, + (long)currSysTime2.time,currSysTime2.millitm, ((long)((currSysTime2.time*1000+currSysTime2.millitm) - (currSysTime1.time*1000+currSysTime1.millitm)))); diff --git a/tests/sizes.c b/tests/sizes.c index 73c7261..554d0e8 100644 --- a/tests/sizes.c +++ b/tests/sizes.c @@ -8,24 +8,24 @@ main() { printf("Sizes of pthreads-win32 structs\n"); printf("-------------------------------\n"); - printf("%30s %4d\n", "pthread_t", sizeof(pthread_t)); - printf("%30s %4d\n", "ptw32_thread_t", sizeof(ptw32_thread_t)); - printf("%30s %4d\n", "pthread_attr_t_", sizeof(struct pthread_attr_t_)); - printf("%30s %4d\n", "sem_t_", sizeof(struct sem_t_)); - printf("%30s %4d\n", "pthread_mutex_t_", sizeof(struct pthread_mutex_t_)); - printf("%30s %4d\n", "pthread_mutexattr_t_", sizeof(struct pthread_mutexattr_t_)); - printf("%30s %4d\n", "pthread_spinlock_t_", sizeof(struct pthread_spinlock_t_)); - printf("%30s %4d\n", "pthread_barrier_t_", sizeof(struct pthread_barrier_t_)); - printf("%30s %4d\n", "pthread_barrierattr_t_", sizeof(struct pthread_barrierattr_t_)); - printf("%30s %4d\n", "pthread_key_t_", sizeof(struct pthread_key_t_)); - printf("%30s %4d\n", "pthread_cond_t_", sizeof(struct pthread_cond_t_)); - printf("%30s %4d\n", "pthread_condattr_t_", sizeof(struct pthread_condattr_t_)); - printf("%30s %4d\n", "pthread_rwlock_t_", sizeof(struct pthread_rwlock_t_)); - printf("%30s %4d\n", "pthread_rwlockattr_t_", sizeof(struct pthread_rwlockattr_t_)); - printf("%30s %4d\n", "pthread_once_t_", sizeof(struct pthread_once_t_)); - printf("%30s %4d\n", "ptw32_cleanup_t", sizeof(struct ptw32_cleanup_t)); - printf("%30s %4d\n", "ptw32_mcs_node_t_", sizeof(struct ptw32_mcs_node_t_)); - printf("%30s %4d\n", "sched_param", sizeof(struct sched_param)); + printf("%30s %4d\n", "pthread_t", (int)sizeof(pthread_t)); + printf("%30s %4d\n", "ptw32_thread_t", (int)sizeof(ptw32_thread_t)); + printf("%30s %4d\n", "pthread_attr_t_", (int)sizeof(struct pthread_attr_t_)); + printf("%30s %4d\n", "sem_t_", (int)sizeof(struct sem_t_)); + printf("%30s %4d\n", "pthread_mutex_t_", (int)sizeof(struct pthread_mutex_t_)); + printf("%30s %4d\n", "pthread_mutexattr_t_", (int)sizeof(struct pthread_mutexattr_t_)); + printf("%30s %4d\n", "pthread_spinlock_t_", (int)sizeof(struct pthread_spinlock_t_)); + printf("%30s %4d\n", "pthread_barrier_t_", (int)sizeof(struct pthread_barrier_t_)); + printf("%30s %4d\n", "pthread_barrierattr_t_", (int)sizeof(struct pthread_barrierattr_t_)); + printf("%30s %4d\n", "pthread_key_t_", (int)sizeof(struct pthread_key_t_)); + printf("%30s %4d\n", "pthread_cond_t_", (int)sizeof(struct pthread_cond_t_)); + printf("%30s %4d\n", "pthread_condattr_t_", (int)sizeof(struct pthread_condattr_t_)); + printf("%30s %4d\n", "pthread_rwlock_t_", (int)sizeof(struct pthread_rwlock_t_)); + printf("%30s %4d\n", "pthread_rwlockattr_t_", (int)sizeof(struct pthread_rwlockattr_t_)); + printf("%30s %4d\n", "pthread_once_t_", (int)sizeof(struct pthread_once_t_)); + printf("%30s %4d\n", "ptw32_cleanup_t", (int)sizeof(struct ptw32_cleanup_t)); + printf("%30s %4d\n", "ptw32_mcs_node_t_", (int)sizeof(struct ptw32_mcs_node_t_)); + printf("%30s %4d\n", "sched_param", (int)sizeof(struct sched_param)); printf("-------------------------------\n"); return 0; diff --git a/tests/spin3.c b/tests/spin3.c index 8c0dae6..fa16b35 100644 --- a/tests/spin3.c +++ b/tests/spin3.c @@ -46,7 +46,7 @@ static pthread_spinlock_t spin; void * unlocker(void * arg) { - int expectedResult = (int) arg; + int expectedResult = (int)(size_t)arg; wasHere++; assert(pthread_spin_unlock(&spin) == expectedResult); @@ -62,7 +62,7 @@ main() wasHere = 0; assert(pthread_spin_init(&spin, PTHREAD_PROCESS_PRIVATE) == 0); assert(pthread_spin_lock(&spin) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *) 0) == 0); + assert(pthread_create(&t, NULL, unlocker, (void*)0) == 0); assert(pthread_join(t, NULL) == 0); assert(pthread_spin_unlock(&spin) == EPERM); assert(pthread_spin_destroy(&spin) == 0); diff --git a/tests/spin4.c b/tests/spin4.c index 2139ffd..44527fe 100644 --- a/tests/spin4.c +++ b/tests/spin4.c @@ -41,8 +41,13 @@ #include pthread_spinlock_t lock = PTHREAD_SPINLOCK_INITIALIZER; -struct _timeb currSysTimeStart; -struct _timeb currSysTimeStop; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTimeStart; + struct __timeb64 currSysTimeStop; +#else + struct _timeb currSysTimeStart; + struct _timeb currSysTimeStop; +#endif #define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - (_TStart.time*1000+_TStart.millitm)) @@ -57,7 +62,7 @@ void * func(void * arg) assert(pthread_spin_unlock(&lock) == 0); PTW32_FTIME(&currSysTimeStop); - return (void *) (size_t)GetDurationMilliSecs(currSysTimeStart, currSysTimeStop); + return (void *)(size_t)GetDurationMilliSecs(currSysTimeStart, currSysTimeStop); } int @@ -66,7 +71,11 @@ main() void* result = (void*)0; pthread_t t; int CPUs; +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 sysTime; +#else struct _timeb sysTime; +#endif if ((CPUs = pthread_num_processors_np()) == 1) { @@ -92,7 +101,7 @@ main() assert(pthread_spin_unlock(&lock) == 0); - assert(pthread_join(t, (void *) &result) == 0); + assert(pthread_join(t, &result) == 0); assert((int)(size_t)result > 1000); assert(pthread_spin_destroy(&lock) == 0); diff --git a/tests/stress1.c b/tests/stress1.c index fb50124..e4dbbd2 100644 --- a/tests/stress1.c +++ b/tests/stress1.c @@ -111,7 +111,11 @@ enum { struct timespec * millisecondsFromNow (struct timespec * time, int millisecs) { +#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 + struct __timeb64 currSysTime; +#else struct _timeb currSysTime; +#endif int64_t nanosecs, secs; const int64_t NANOSEC_PER_MILLISEC = 1000000; const int64_t NANOSEC_PER_SEC = 1000000000; @@ -141,9 +145,9 @@ millisecondsFromNow (struct timespec * time, int millisecs) void * masterThread (void * arg) { - int dither = (int) arg; + int dither = (int)(size_t)arg; - timeout = (int) arg; + timeout = (int)(size_t)arg; pthread_barrier_wait(&startBarrier); @@ -239,7 +243,7 @@ main () assert(pthread_barrier_init(&readyBarrier, NULL, 3) == 0); assert(pthread_barrier_init(&holdBarrier, NULL, 3) == 0); - assert(pthread_create(&master, NULL, masterThread, (void *) timeout) == 0); + assert(pthread_create(&master, NULL, masterThread, (void *)(size_t)timeout) == 0); assert(pthread_create(&slave, NULL, slaveThread, NULL) == 0); allExit = FALSE; -- cgit v1.2.3