From e470da85f7b9426eea03d66086c2822bf29e9b05 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 3 Mar 2011 23:37:20 +0000 Subject: Some cleanups, mostly x86_64 compat plus interlocked macros --- tests/Bmakefile | 4 +--- tests/ChangeLog | 10 ++++++++++ tests/GNUmakefile | 3 +-- tests/Makefile | 10 ++++------ tests/SIZES.VC | 41 +++++++++++++++++++++-------------------- tests/SIZES.VCE | 40 +++++++++++++++++++++------------------- tests/benchtest1.c | 27 ++++++++++++++------------- tests/benchtest2.c | 8 ++++---- tests/benchtest3.c | 8 ++++---- tests/benchtest4.c | 8 ++++---- tests/benchtest5.c | 16 ++++++++-------- tests/condvar2.c | 2 +- tests/condvar2_1.c | 2 +- tests/condvar3.c | 2 +- tests/condvar3_1.c | 2 +- tests/condvar3_2.c | 4 ++-- tests/condvar3_3.c | 2 +- tests/condvar4.c | 4 ++-- tests/condvar5.c | 4 ++-- tests/condvar6.c | 2 +- tests/condvar7.c | 2 +- tests/condvar8.c | 2 +- tests/condvar9.c | 2 +- tests/mutex8.c | 2 +- tests/mutex8e.c | 2 +- tests/mutex8n.c | 2 +- tests/mutex8r.c | 2 +- tests/rwlock2_t.c | 2 +- tests/rwlock3_t.c | 2 +- tests/rwlock4_t.c | 2 +- tests/rwlock5_t.c | 2 +- tests/rwlock6_t.c | 2 +- tests/rwlock6_t2.c | 2 +- tests/rwlock7.c | 8 ++++---- tests/rwlock8.c | 8 ++++---- tests/spin4.c | 6 +++--- tests/stress1.c | 2 +- tests/test.h | 8 ++++++++ 38 files changed, 137 insertions(+), 120 deletions(-) (limited to 'tests') diff --git a/tests/Bmakefile b/tests/Bmakefile index 169f42c..c6cbc41 100644 --- a/tests/Bmakefile +++ b/tests/Bmakefile @@ -115,8 +115,7 @@ PASSES= loadfree.pass \ cancel9.pass create3.pass stress1.pass BENCHRESULTS = \ - benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench \ - benchtest6.bench + benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench help: @ $(ECHO) Run one of the following command lines: @@ -223,7 +222,6 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -benchtest6.bench: barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass diff --git a/tests/ChangeLog b/tests/ChangeLog index 1bdcc43..bf604f5 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,13 @@ +2011-03-04 Ross Johnson + + * condvar3_2.c: abstime.tv_sec operation warning fixed. + +2011-02-28 Ross Johnson + + * test.h: Define FTIME to be _ftime64_s or _ftime64 or _ftime + in that order of preference where supported. + * several: Replace calls to _ftime with the FTIME macro. + 2010-06-19 Ross Johnson * Makefile (STATICRESULTS): Add all tests into suite for static diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 5d61a6f..013351f 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -111,7 +111,7 @@ STRESSTESTS = \ stress1 BENCHTESTS = \ - benchtest1 benchtest2 benchtest3 benchtest4 benchtest5 benchtest6 + benchtest1 benchtest2 benchtest3 benchtest4 benchtest5 STATICTESTS = \ sizes \ @@ -213,7 +213,6 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -benchtest6.bench: barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass diff --git a/tests/Makefile b/tests/Makefile index 0042e02..aef83c2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -50,7 +50,7 @@ OPTIM = /O2 /Ob0 XXLIBS = ws2_32.lib # C++ Exceptions -VCEFLAGS = /GX /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX +VCEFLAGS = /EHsc /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX VCELIB = pthreadVCE$(DLL_VER).lib VCEDLL = pthreadVCE$(DLL_VER).dll # Structured Exceptions @@ -62,13 +62,13 @@ VCFLAGS = /D__CLEANUP_C VCLIB = pthreadVC$(DLL_VER).lib VCDLL = pthreadVC$(DLL_VER).dll # C++ Exceptions in application - using VC version of pthreads dll -VCXFLAGS = /GX /TP /D__CLEANUP_C +VCXFLAGS = /EHsc /TP /D__CLEANUP_C # Defaults CPLIB = $(VCLIB) CPDLL = $(VCDLL) -CFLAGS= $(OPTIM) /W3 /MD /nologo /Yd /Zi +CFLAGS= $(OPTIM) /W3 /MD /nologo /Z7 LFLAGS= /INCREMENTAL:NO INCLUDES=-I. BUILD_DIR=.. @@ -120,8 +120,7 @@ PASSES= sizes.pass loadfree.pass \ cancel9.pass create3.pass stress1.pass BENCHRESULTS = \ - benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench \ - benchtest6.bench + benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench STRESSRESULTS = \ stress1.stress @@ -310,7 +309,6 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -benchtest6.bench: barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass diff --git a/tests/SIZES.VC b/tests/SIZES.VC index ae09a84..603521b 100755 --- a/tests/SIZES.VC +++ b/tests/SIZES.VC @@ -1,20 +1,21 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t_ 124 - pthread_attr_t_ 28 - sem_t_ 4 - pthread_mutex_t_ 44 - pthread_mutexattr_t_ 8 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 24 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 8 - ptw32_cleanup_t 12 - sched_param 4 -------------------------------- - +Sizes of pthreads-win32 structs +------------------------------- + pthread_t 8 + ptw32_thread_t 140 + pthread_attr_t_ 28 + sem_t_ 12 + pthread_mutex_t_ 24 + pthread_mutexattr_t_ 8 + pthread_spinlock_t_ 8 + pthread_barrier_t_ 36 + pthread_barrierattr_t_ 4 + pthread_key_t_ 16 + pthread_cond_t_ 32 + pthread_condattr_t_ 4 + pthread_rwlock_t_ 28 + pthread_rwlockattr_t_ 4 + pthread_once_t_ 16 + ptw32_cleanup_t 12 + ptw32_mcs_node_t_ 16 + sched_param 4 +------------------------------- diff --git a/tests/SIZES.VCE b/tests/SIZES.VCE index edc6427..7048d3a 100644 --- a/tests/SIZES.VCE +++ b/tests/SIZES.VCE @@ -1,19 +1,21 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t_ 68 - pthread_attr_t_ 28 - sem_t_ 4 - pthread_mutex_t_ 44 - pthread_mutexattr_t_ 8 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 24 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 8 - ptw32_cleanup_t 12 - sched_param 4 -------------------------------- +Sizes of pthreads-win32 structs +------------------------------- + pthread_t 8 + ptw32_thread_t 76 + pthread_attr_t_ 28 + sem_t_ 12 + pthread_mutex_t_ 24 + pthread_mutexattr_t_ 8 + pthread_spinlock_t_ 8 + pthread_barrier_t_ 36 + pthread_barrierattr_t_ 4 + pthread_key_t_ 16 + pthread_cond_t_ 32 + pthread_condattr_t_ 4 + pthread_rwlock_t_ 28 + pthread_rwlockattr_t_ 4 + pthread_once_t_ 16 + ptw32_cleanup_t 12 + ptw32_mcs_node_t_ 16 + sched_param 4 +------------------------------- diff --git a/tests/benchtest1.c b/tests/benchtest1.c index 116dad0..21e8e64 100644 --- a/tests/benchtest1.c +++ b/tests/benchtest1.c @@ -57,21 +57,23 @@ struct _timeb currSysTimeStart; struct _timeb currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; +int two = 2; int one = 1; int zero = 0; +int iter; -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) +#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ + - (_TStart.time*1000+_TStart.millitm))) /* * Dummy use of j, otherwise the loop may be removed by the optimiser * when doing the overhead timing with an empty loop. */ #define TESTSTART \ - { int i, j = 0, k = 0; _ftime(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; + { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; #define TESTSTOP \ - }; _ftime(&currSysTimeStop); if (j + k == i) j++; } + }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } void @@ -83,8 +85,8 @@ runTest (char * testNameString, int mType) assert(pthread_mutex_init(&mx, &ma) == 0); TESTSTART - assert(pthread_mutex_lock(&mx) == zero); - assert(pthread_mutex_unlock(&mx) == zero); + assert((pthread_mutex_lock(&mx),1) == one); + assert((pthread_mutex_unlock(&mx),2) == two); TESTSTOP assert(pthread_mutex_destroy(&mx) == 0); @@ -118,10 +120,9 @@ main (int argc, char *argv[]) /* * Time the loop overhead so we can subtract it from the actual test times. */ - TESTSTART assert(1 == one); - assert(1 == one); + assert(2 == two); TESTSTOP durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; @@ -130,7 +131,7 @@ main (int argc, char *argv[]) TESTSTART assert((dummy_call(&i), 1) == one); - assert((dummy_call(&i), 1) == one); + assert((dummy_call(&i), 2) == two); TESTSTOP durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; @@ -138,12 +139,12 @@ main (int argc, char *argv[]) printf( "%-45s %15ld %15.3f\n", "Dummy call x 2", durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); + (float) (durationMilliSecs * 1E3 / ITERATIONS)); TESTSTART assert((interlocked_inc_with_conditionals(&i), 1) == one); - assert((interlocked_dec_with_conditionals(&i), 1) == one); + assert((interlocked_dec_with_conditionals(&i), 2) == two); TESTSTOP durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; @@ -156,7 +157,7 @@ main (int argc, char *argv[]) TESTSTART assert((InterlockedIncrement((LPLONG)&i), 1) == (LONG)one); - assert((InterlockedDecrement((LPLONG)&i), 1) == (LONG)one); + assert((InterlockedDecrement((LPLONG)&i), 2) == (LONG)two); TESTSTOP durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; @@ -171,7 +172,7 @@ main (int argc, char *argv[]) TESTSTART assert((EnterCriticalSection(&cs), 1) == one); - assert((LeaveCriticalSection(&cs), 1) == one); + assert((LeaveCriticalSection(&cs), 2) == two); TESTSTOP DeleteCriticalSection(&cs); diff --git a/tests/benchtest2.c b/tests/benchtest2.c index d92bb3c..10deca2 100644 --- a/tests/benchtest2.c +++ b/tests/benchtest2.c @@ -65,18 +65,18 @@ struct _timeb currSysTimeStop; pthread_t worker; int running = 0; -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) +#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ + - (_TStart.time*1000+_TStart.millitm))) /* * Dummy use of j, otherwise the loop may be removed by the optimiser * when doing the overhead timing with an empty loop. */ #define TESTSTART \ - { int i, j = 0, k = 0; _ftime(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; + { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; #define TESTSTOP \ - }; _ftime(&currSysTimeStop); if (j + k == i) j++; } + }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } void * diff --git a/tests/benchtest3.c b/tests/benchtest3.c index 023460d..6ff3c90 100644 --- a/tests/benchtest3.c +++ b/tests/benchtest3.c @@ -59,18 +59,18 @@ struct _timeb currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) +#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ + - (_TStart.time*1000+_TStart.millitm))) /* * Dummy use of j, otherwise the loop may be removed by the optimiser * when doing the overhead timing with an empty loop. */ #define TESTSTART \ - { int i, j = 0, k = 0; _ftime(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; + { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; #define TESTSTOP \ - }; _ftime(&currSysTimeStop); if (j + k == i) j++; } + }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } void * diff --git a/tests/benchtest4.c b/tests/benchtest4.c index 772d100..d64438d 100644 --- a/tests/benchtest4.c +++ b/tests/benchtest4.c @@ -59,18 +59,18 @@ struct _timeb currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) +#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ + - (_TStart.time*1000+_TStart.millitm))) /* * Dummy use of j, otherwise the loop may be removed by the optimiser * when doing the overhead timing with an empty loop. */ #define TESTSTART \ - { int i, j = 0, k = 0; _ftime(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; + { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; #define TESTSTOP \ - }; _ftime(&currSysTimeStop); if (j + k == i) j++; } + }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } void diff --git a/tests/benchtest5.c b/tests/benchtest5.c index 7700fde..0d5c360 100644 --- a/tests/benchtest5.c +++ b/tests/benchtest5.c @@ -60,18 +60,18 @@ long overHeadMilliSecs = 0; int one = 1; int zero = 0; -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) +#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ + - (_TStart.time*1000+_TStart.millitm))) /* * Dummy use of j, otherwise the loop may be removed by the optimiser * when doing the overhead timing with an empty loop. */ #define TESTSTART \ - { int i, j = 0, k = 0; _ftime(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; + { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; #define TESTSTOP \ - }; _ftime(&currSysTimeStop); if (j + k == i) j++; } + }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } void @@ -115,7 +115,7 @@ main (int argc, char *argv[]) */ assert((w32sema = CreateSemaphore(NULL, (long) 0, (long) ITERATIONS, NULL)) != 0); TESTSTART - assert(ReleaseSemaphore(w32sema, 1, NULL) != zero); + assert((ReleaseSemaphore(w32sema, 1, NULL),1) == one); TESTSTOP assert(CloseHandle(w32sema) != 0); @@ -124,7 +124,7 @@ main (int argc, char *argv[]) assert((w32sema = CreateSemaphore(NULL, (long) ITERATIONS, (long) ITERATIONS, NULL)) != 0); TESTSTART - assert(WaitForSingleObject(w32sema, INFINITE) == WAIT_OBJECT_0); + assert((WaitForSingleObject(w32sema, INFINITE),1) == one); TESTSTOP assert(CloseHandle(w32sema) != 0); @@ -133,7 +133,7 @@ main (int argc, char *argv[]) assert(sem_init(&sema, 0, 0) == 0); TESTSTART - assert(sem_post(&sema) == zero); + assert((sem_post(&sema),1) == one); TESTSTOP assert(sem_destroy(&sema) == 0); @@ -142,7 +142,7 @@ main (int argc, char *argv[]) assert(sem_init(&sema, 0, ITERATIONS) == 0); TESTSTART - assert(sem_wait(&sema) == zero); + assert((sem_wait(&sema),1) == one); TESTSTOP assert(sem_destroy(&sema) == 0); diff --git a/tests/condvar2.c b/tests/condvar2.c index 33f1d3f..793bb36 100644 --- a/tests/condvar2.c +++ b/tests/condvar2.c @@ -97,7 +97,7 @@ main() assert(pthread_mutex_lock(&mutex) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar2_1.c b/tests/condvar2_1.c index 92dddfd..bf08f44 100644 --- a/tests/condvar2_1.c +++ b/tests/condvar2_1.c @@ -114,7 +114,7 @@ main() assert(pthread_mutex_init(&mutex, NULL) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar3.c b/tests/condvar3.c index e3a23f5..8e7e6eb 100644 --- a/tests/condvar3.c +++ b/tests/condvar3.c @@ -124,7 +124,7 @@ main() assert(pthread_mutex_lock(&mutex) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar3_1.c b/tests/condvar3_1.c index 25a50e4..87671a4 100644 --- a/tests/condvar3_1.c +++ b/tests/condvar3_1.c @@ -137,7 +137,7 @@ main() assert(pthread_mutex_init(&mutex1, NULL) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar3_2.c b/tests/condvar3_2.c index 5ddcf57..33d800c 100644 --- a/tests/condvar3_2.c +++ b/tests/condvar3_2.c @@ -136,9 +136,9 @@ main() assert(pthread_mutex_init(&mutex, NULL) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); - abstime.tv_sec = abstime.tv_sec = currSysTime.time + 5; + abstime.tv_sec = abstime2.tv_sec = currSysTime.time + 5; abstime.tv_nsec = abstime2.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; assert(pthread_mutex_lock(&mutex) == 0); diff --git a/tests/condvar3_3.c b/tests/condvar3_3.c index fe67632..2a4495f 100644 --- a/tests/condvar3_3.c +++ b/tests/condvar3_3.c @@ -94,7 +94,7 @@ int main() assert(pthread_mutex_init(&mtx, 0) == 0); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar4.c b/tests/condvar4.c index 3babeea..c27aafb 100644 --- a/tests/condvar4.c +++ b/tests/condvar4.c @@ -128,7 +128,7 @@ main() assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; @@ -141,7 +141,7 @@ main() assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar5.c b/tests/condvar5.c index 4d51f39..7e6ab38 100644 --- a/tests/condvar5.c +++ b/tests/condvar5.c @@ -127,7 +127,7 @@ main() assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); /* get current system time */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; @@ -140,7 +140,7 @@ main() assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar6.c b/tests/condvar6.c index e63132c..70da6a7 100644 --- a/tests/condvar6.c +++ b/tests/condvar6.c @@ -157,7 +157,7 @@ main() assert(pthread_mutex_lock(&start_flag) == 0); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar7.c b/tests/condvar7.c index 6d89f2e..8df30cb 100644 --- a/tests/condvar7.c +++ b/tests/condvar7.c @@ -167,7 +167,7 @@ main() assert(pthread_mutex_lock(&start_flag) == 0); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar8.c b/tests/condvar8.c index e384a1c..53bfc52 100644 --- a/tests/condvar8.c +++ b/tests/condvar8.c @@ -164,7 +164,7 @@ main() assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/condvar9.c b/tests/condvar9.c index c751271..5443e8b 100644 --- a/tests/condvar9.c +++ b/tests/condvar9.c @@ -172,7 +172,7 @@ main() assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/mutex8.c b/tests/mutex8.c index 5ca9982..827fae0 100644 --- a/tests/mutex8.c +++ b/tests/mutex8.c @@ -47,7 +47,7 @@ void * locker(void * arg) struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/mutex8e.c b/tests/mutex8e.c index b99d24e..e358630 100644 --- a/tests/mutex8e.c +++ b/tests/mutex8e.c @@ -55,7 +55,7 @@ void * locker(void * arg) struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/mutex8n.c b/tests/mutex8n.c index 3cfdae6..1a96f2e 100644 --- a/tests/mutex8n.c +++ b/tests/mutex8n.c @@ -55,7 +55,7 @@ void * locker(void * arg) struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/mutex8r.c b/tests/mutex8r.c index d1328ca..1a76097 100644 --- a/tests/mutex8r.c +++ b/tests/mutex8r.c @@ -55,7 +55,7 @@ void * locker(void * arg) struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock2_t.c b/tests/rwlock2_t.c index 8e6ab6d..a34d351 100644 --- a/tests/rwlock2_t.c +++ b/tests/rwlock2_t.c @@ -53,7 +53,7 @@ main() struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock3_t.c b/tests/rwlock3_t.c index bc45abc..71aa02a 100644 --- a/tests/rwlock3_t.c +++ b/tests/rwlock3_t.c @@ -66,7 +66,7 @@ main() struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock4_t.c b/tests/rwlock4_t.c index 37ec34f..3eec003 100644 --- a/tests/rwlock4_t.c +++ b/tests/rwlock4_t.c @@ -66,7 +66,7 @@ main() struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock5_t.c b/tests/rwlock5_t.c index bf473a4..a3a9497 100644 --- a/tests/rwlock5_t.c +++ b/tests/rwlock5_t.c @@ -68,7 +68,7 @@ main() struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock6_t.c b/tests/rwlock6_t.c index aa38bf5..37a332a 100644 --- a/tests/rwlock6_t.c +++ b/tests/rwlock6_t.c @@ -65,7 +65,7 @@ void * rdfunc(void * arg) struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock6_t2.c b/tests/rwlock6_t2.c index 58bfc3d..1bce439 100644 --- a/tests/rwlock6_t2.c +++ b/tests/rwlock6_t2.c @@ -92,7 +92,7 @@ main() struct _timeb currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; diff --git a/tests/rwlock7.c b/tests/rwlock7.c index 91466e4..1e8fdf0 100644 --- a/tests/rwlock7.c +++ b/tests/rwlock7.c @@ -122,7 +122,7 @@ main (int argc, char *argv[]) assert(pthread_rwlock_init (&data[data_count].lock, NULL) == 0); } - _ftime(&currSysTime1); + PTW32_FTIME(&currSysTime1); /* * Create THREADS threads to access shared data. @@ -187,13 +187,13 @@ main (int argc, char *argv[]) printf ("%d thread updates, %d data updates\n", thread_updates, data_updates); - _ftime(&currSysTime2); + PTW32_FTIME(&currSysTime2); printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", currSysTime1.time,currSysTime1.millitm, currSysTime2.time,currSysTime2.millitm, - (currSysTime2.time*1000+currSysTime2.millitm) - - (currSysTime1.time*1000+currSysTime1.millitm)); + ((long)((currSysTime2.time*1000+currSysTime2.millitm) - + (currSysTime1.time*1000+currSysTime1.millitm)))); return 0; } diff --git a/tests/rwlock8.c b/tests/rwlock8.c index c83a775..207646c 100644 --- a/tests/rwlock8.c +++ b/tests/rwlock8.c @@ -128,7 +128,7 @@ main (int argc, char *argv[]) assert(pthread_rwlock_init (&data[data_count].lock, NULL) == 0); } - _ftime(&currSysTime1); + PTW32_FTIME(&currSysTime1); /* * Create THREADS threads to access shared data. @@ -193,13 +193,13 @@ main (int argc, char *argv[]) printf ("%d thread updates, %d data updates\n", thread_updates, data_updates); - _ftime(&currSysTime2); + PTW32_FTIME(&currSysTime2); printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", currSysTime1.time,currSysTime1.millitm, currSysTime2.time,currSysTime2.millitm, - (currSysTime2.time*1000+currSysTime2.millitm) - - (currSysTime1.time*1000+currSysTime1.millitm)); + ((long)((currSysTime2.time*1000+currSysTime2.millitm) - + (currSysTime1.time*1000+currSysTime1.millitm)))); return 0; } diff --git a/tests/spin4.c b/tests/spin4.c index 8386d09..93e8d90 100644 --- a/tests/spin4.c +++ b/tests/spin4.c @@ -51,11 +51,11 @@ static int washere = 0; void * func(void * arg) { - _ftime(&currSysTimeStart); + PTW32_FTIME(&currSysTimeStart); washere = 1; assert(pthread_spin_lock(&lock) == 0); assert(pthread_spin_unlock(&lock) == 0); - _ftime(&currSysTimeStop); + PTW32_FTIME(&currSysTimeStop); return (void *) GetDurationMilliSecs(currSysTimeStart, currSysTimeStop); } @@ -86,7 +86,7 @@ main() do { sched_yield(); - _ftime(&sysTime); + PTW32_FTIME(&sysTime); } while (GetDurationMilliSecs(currSysTimeStart, sysTime) <= 1000); diff --git a/tests/stress1.c b/tests/stress1.c index 3588361..fb50124 100644 --- a/tests/stress1.c +++ b/tests/stress1.c @@ -117,7 +117,7 @@ millisecondsFromNow (struct timespec * time, int millisecs) const int64_t NANOSEC_PER_SEC = 1000000000; /* get current system time and add millisecs */ - _ftime(&currSysTime); + PTW32_FTIME(&currSysTime); secs = (int64_t)(currSysTime.time) + (millisecs / 1000); nanosecs = ((int64_t) (millisecs%1000 + currSysTime.millitm)) * NANOSEC_PER_MILLISEC; diff --git a/tests/test.h b/tests/test.h index dc63eb4..a6c2b60 100644 --- a/tests/test.h +++ b/tests/test.h @@ -61,6 +61,14 @@ #define int64_t _int64 #endif +#ifdef _MSC_VER + #define PTW32_FTIME(x) _ftime64_s(x); +#elif defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0601 + #define PTW32_FTIME(x) _ftime64(x); +#else + #define PTW32_FTIME(x) _ftime(x); +#endif + const char * error_string[] = { "ZERO_or_EOK", -- cgit v1.2.3