From e516576e75527fb763e800e61dd024461141ec14 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 2 Jul 2011 02:18:43 +0000 Subject: See the ChangeLogs --- tests/ChangeLog | 6 ++++++ tests/Makefile | 6 ++++-- tests/benchtest1.c | 9 ++------- tests/benchtest2.c | 9 ++------- tests/benchtest3.c | 9 ++------- tests/benchtest4.c | 9 ++------- tests/benchtest5.c | 9 ++------- tests/condvar2.c | 6 +----- tests/condvar2_1.c | 6 +----- tests/condvar3.c | 6 +----- tests/condvar3_1.c | 6 +----- tests/condvar3_2.c | 6 +----- tests/condvar3_3.c | 6 +----- tests/condvar4.c | 6 +----- tests/condvar5.c | 6 +----- tests/condvar6.c | 6 +----- tests/condvar7.c | 8 ++------ tests/condvar8.c | 6 +----- tests/condvar9.c | 6 +----- tests/mutex8.c | 6 +----- tests/mutex8e.c | 6 +----- tests/mutex8n.c | 6 +----- tests/mutex8r.c | 6 +----- tests/openmp1.c | 40 ++++++++++++++++++++-------------------- tests/rwlock2_t.c | 6 +----- tests/rwlock3_t.c | 6 +----- tests/rwlock4_t.c | 6 +----- tests/rwlock5_t.c | 6 +----- tests/rwlock6_t.c | 6 +----- tests/rwlock6_t2.c | 6 +----- tests/rwlock7.c | 9 ++------- tests/rwlock8.c | 9 ++------- tests/semaphore1.c | 32 ++++++++++---------------------- tests/spin4.c | 9 ++------- tests/stress1.c | 6 +----- tests/test.h | 14 +++++++++----- 36 files changed, 89 insertions(+), 221 deletions(-) (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 342c0c8..803b4dc 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2011-07-02 Daniel Richard G. + + * *.[ch]: Cleanups around timeb struct, mainly centralising + macro definitions in test.h. + * Makefile: Fix annoying nmake warning. + 2011-06-30 Ross Johnson * sequence1.c: Fix loop overrun. diff --git a/tests/Makefile b/tests/Makefile index 4164e1e..cb4cacb 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -81,7 +81,9 @@ EHFLAGS = # If a test case returns a non-zero exit code to the shell, make will # stop. -PASSES= sizes.pass loadfree.pass \ +PASSES = sizes.pass $(REGULAR_PASSES) + +REGULAR_PASSES = loadfree.pass \ self1.pass mutex5.pass \ mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \ semaphore1.pass semaphore2.pass semaphore3.pass \ @@ -213,7 +215,7 @@ sizes.pass: sizes.exe @ $(ECHO) ...... Passed @ $(TOUCH) $*.pass -$(PASSES): $*.exe +$(REGULAR_PASSES): $*.exe @ $(ECHO) ... Running $(TEST) test: $*.exe @ .\$*.exe @ $(ECHO) ...... Passed diff --git a/tests/benchtest1.c b/tests/benchtest1.c index 4184719..191f986 100644 --- a/tests/benchtest1.c +++ b/tests/benchtest1.c @@ -53,13 +53,8 @@ pthread_mutex_t mx; pthread_mutexattr_t ma; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; int two = 2; diff --git a/tests/benchtest2.c b/tests/benchtest2.c index 28e1cfe..10f3d0e 100644 --- a/tests/benchtest2.c +++ b/tests/benchtest2.c @@ -60,13 +60,8 @@ CRITICAL_SECTION cs1, cs2; pthread_mutexattr_t ma; long durationMilliSecs; long overHeadMilliSecs = 0; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; pthread_t worker; int running = 0; diff --git a/tests/benchtest3.c b/tests/benchtest3.c index 1b6e823..7d03ed8 100644 --- a/tests/benchtest3.c +++ b/tests/benchtest3.c @@ -54,13 +54,8 @@ pthread_mutex_t mx; old_mutex_t ox; pthread_mutexattr_t ma; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; diff --git a/tests/benchtest4.c b/tests/benchtest4.c index d64cd4a..d7cf47c 100644 --- a/tests/benchtest4.c +++ b/tests/benchtest4.c @@ -54,13 +54,8 @@ pthread_mutex_t mx; old_mutex_t ox; pthread_mutexattr_t ma; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; diff --git a/tests/benchtest5.c b/tests/benchtest5.c index 83d59c1..d262baf 100644 --- a/tests/benchtest5.c +++ b/tests/benchtest5.c @@ -53,13 +53,8 @@ sem_t sema; HANDLE w32sema; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; long durationMilliSecs; long overHeadMilliSecs = 0; int one = 1; diff --git a/tests/condvar2.c b/tests/condvar2.c index dd9851b..6e2fa52 100644 --- a/tests/condvar2.c +++ b/tests/condvar2.c @@ -87,11 +87,7 @@ int main() { struct timespec abstime = { 0, 0 }; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif + PTW32_STRUCT_TIMEB currSysTime; 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 7607abd..3486d21 100644 --- a/tests/condvar2_1.c +++ b/tests/condvar2_1.c @@ -106,11 +106,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); diff --git a/tests/condvar3.c b/tests/condvar3.c index 0a6c152..056334b 100644 --- a/tests/condvar3.c +++ b/tests/condvar3.c @@ -112,11 +112,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; 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 bc539d5..33baeb1 100644 --- a/tests/condvar3_1.c +++ b/tests/condvar3_1.c @@ -127,11 +127,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); diff --git a/tests/condvar3_2.c b/tests/condvar3_2.c index 192b842..4c35801 100644 --- a/tests/condvar3_2.c +++ b/tests/condvar3_2.c @@ -128,11 +128,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cv, NULL) == 0); diff --git a/tests/condvar3_3.c b/tests/condvar3_3.c index ae1ed70..f842440 100644 --- a/tests/condvar3_3.c +++ b/tests/condvar3_3.c @@ -87,11 +87,7 @@ int main() int rc; struct timespec abstime = { 0, 0 }; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert(pthread_cond_init(&cnd, 0) == 0); diff --git a/tests/condvar4.c b/tests/condvar4.c index 8d9fbe9..3f6879b 100644 --- a/tests/condvar4.c +++ b/tests/condvar4.c @@ -112,11 +112,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar5.c b/tests/condvar5.c index acbc65a..73083a5 100644 --- a/tests/condvar5.c +++ b/tests/condvar5.c @@ -111,11 +111,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar6.c b/tests/condvar6.c index ed16e5d..9d0b75d 100644 --- a/tests/condvar6.c +++ b/tests/condvar6.c @@ -144,11 +144,7 @@ main() int i; pthread_t t[NUMTHREADS + 1]; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; diff --git a/tests/condvar7.c b/tests/condvar7.c index 3975e2c..0647e7d 100644 --- a/tests/condvar7.c +++ b/tests/condvar7.c @@ -154,11 +154,7 @@ main() int i; pthread_t t[NUMTHREADS + 1]; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; cvthing.shared = 0; @@ -173,7 +169,7 @@ main() PTW32_FTIME(&currSysTime); - abstime.tv_sec = currSysTime.time; + abstime.tv_sec = (time_t)currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; abstime.tv_sec += 10; diff --git a/tests/condvar8.c b/tests/condvar8.c index 96978f2..7c2579d 100644 --- a/tests/condvar8.c +++ b/tests/condvar8.c @@ -155,11 +155,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert((t[0] = pthread_self()).p != NULL); diff --git a/tests/condvar9.c b/tests/condvar9.c index dfcd158..62d044b 100644 --- a/tests/condvar9.c +++ b/tests/condvar9.c @@ -163,11 +163,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; assert((t[0] = pthread_self()).p != NULL); diff --git a/tests/mutex8.c b/tests/mutex8.c index 9798f5a..f263678 100644 --- a/tests/mutex8.c +++ b/tests/mutex8.c @@ -44,11 +44,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8e.c b/tests/mutex8e.c index 58d7d1e..a360566 100644 --- a/tests/mutex8e.c +++ b/tests/mutex8e.c @@ -52,11 +52,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8n.c b/tests/mutex8n.c index deb9215..0c6d97d 100644 --- a/tests/mutex8n.c +++ b/tests/mutex8n.c @@ -52,11 +52,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/mutex8r.c b/tests/mutex8r.c index fe686c5..434b9af 100644 --- a/tests/mutex8r.c +++ b/tests/mutex8r.c @@ -52,11 +52,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/openmp1.c b/tests/openmp1.c index 4c23d79..ee36e75 100755 --- a/tests/openmp1.c +++ b/tests/openmp1.c @@ -1,7 +1,7 @@ #include #include #ifdef _OPENMP - #include +# include #endif #include @@ -20,17 +20,17 @@ void *_thread(void* Id) { int i; int x[Size]; - #ifdef _OPENMP - #pragma omp parallel for - #endif +#ifdef _OPENMP +# pragma omp parallel for +#endif for ( i = 0; i < Size; i++ ) { - #ifdef _OPENMP +#ifdef _OPENMP if (Verbose && i%1000==0) { int tid = omp_get_thread_num(); - #pragma omp critical +# pragma omp critical printf("thread %d : tid %d handles %d\n",(int)Id,tid,i); } - #endif +#endif x[i] = i; } @@ -40,9 +40,9 @@ void *_thread(void* Id) { Sum += x[i]; } if (Verbose) { - #ifdef _OPENMP - #pragma omp critical - #endif +#ifdef _OPENMP +# pragma omp critical +#endif printf("Id %d : %s : %d(should be %d)\n",(int)Id, __FUNCTION__, Sum,ShouldSum); } if (Sum == ShouldSum) ThreadOK[(int)Id] = 1; @@ -53,16 +53,16 @@ void *_thread(void* Id) { void MainThread() { int i; - #ifdef _OPENMP - #pragma omp parallel for - #endif +#ifdef _OPENMP +# pragma omp parallel for +#endif for ( i = 0; i < 4; i++ ) { - #ifdef _OPENMP +#ifdef _OPENMP int tid = omp_get_thread_num(); - #pragma omp critical +# pragma omp critical printf("Main : tid %d\n",tid); _thread((void *)tid); - #endif +#endif } return; } @@ -117,11 +117,11 @@ int main(int argc, char *argv[]) { } printf("Joined thread2\n"); } -#endif +#endif // SPAWN_THREADS short OK = 0; // Check that we have OpenMP before declaring things OK formally. - #ifdef _OPENMP +#ifdef _OPENMP OK = 1; { short i; @@ -129,9 +129,9 @@ int main(int argc, char *argv[]) { } if (OK) printf("OMP : All looks good\n"); else printf("OMP : Error\n"); - #else +#else printf("OpenMP seems not enabled ...\n"); - #endif +#endif return OK?0:1; } diff --git a/tests/rwlock2_t.c b/tests/rwlock2_t.c index af7ef05..4267ddb 100644 --- a/tests/rwlock2_t.c +++ b/tests/rwlock2_t.c @@ -50,11 +50,7 @@ int main() { struct timespec abstime = { 0, 0 }; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock3_t.c b/tests/rwlock3_t.c index 60798dd..6419de1 100644 --- a/tests/rwlock3_t.c +++ b/tests/rwlock3_t.c @@ -63,11 +63,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock4_t.c b/tests/rwlock4_t.c index cccfd27..58b3602 100644 --- a/tests/rwlock4_t.c +++ b/tests/rwlock4_t.c @@ -63,11 +63,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock5_t.c b/tests/rwlock5_t.c index 96b4348..4a94658 100644 --- a/tests/rwlock5_t.c +++ b/tests/rwlock5_t.c @@ -65,11 +65,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock6_t.c b/tests/rwlock6_t.c index 6c45b0a..71cbe22 100644 --- a/tests/rwlock6_t.c +++ b/tests/rwlock6_t.c @@ -62,11 +62,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock6_t2.c b/tests/rwlock6_t2.c index 28de466..b8b0df9 100644 --- a/tests/rwlock6_t2.c +++ b/tests/rwlock6_t2.c @@ -89,11 +89,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); diff --git a/tests/rwlock7.c b/tests/rwlock7.c index 33e87e2..69d1a73 100644 --- a/tests/rwlock7.c +++ b/tests/rwlock7.c @@ -108,13 +108,8 @@ 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 + PTW32_STRUCT_TIMEB currSysTime1; + PTW32_STRUCT_TIMEB currSysTime2; /* * Initialize the shared data. diff --git a/tests/rwlock8.c b/tests/rwlock8.c index 28552ba..99c357a 100644 --- a/tests/rwlock8.c +++ b/tests/rwlock8.c @@ -114,13 +114,8 @@ 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 + PTW32_STRUCT_TIMEB currSysTime1; + PTW32_STRUCT_TIMEB currSysTime2; /* * Initialize the shared data. diff --git a/tests/semaphore1.c b/tests/semaphore1.c index 0f2eb77..8fc91ee 100644 --- a/tests/semaphore1.c +++ b/tests/semaphore1.c @@ -86,8 +86,11 @@ thr(void * arg) if ( result == -1 ) { int err = errno; - printf("thread: sem_trywait 1: expecting error %s: got %s\n", - error_string[EAGAIN], error_string[err]); fflush(stdout); + if (err != EAGAIN) + { + printf("thread: sem_trywait 1: expecting error %s: got %s\n", + error_string[EAGAIN], error_string[err]); fflush(stdout); + } assert(err == EAGAIN); } else @@ -99,15 +102,6 @@ thr(void * arg) assert((result = sem_trywait(&s)) == 0); - if ( result == -1 ) - { - perror("thread: sem_trywait 2"); - } - else - { - printf("thread: ok 2\n"); - } - assert(sem_post(&s) == 0); return NULL; @@ -133,8 +127,11 @@ main() if (result2 == -1) { int err = errno; - printf("main: sem_trywait 1: expecting error %s: got %s\n", - error_string[EAGAIN], error_string[err]); fflush(stdout); + if (err != EAGAIN) + { + printf("main: sem_trywait 1: expecting error %s: got %s\n", + error_string[EAGAIN], error_string[err]); fflush(stdout); + } assert(err == EAGAIN); } else @@ -146,15 +143,6 @@ main() assert((result2 = sem_trywait(&s)) == 0); - if ( result2 == -1 ) - { - perror("main: sem_trywait 2"); - } - else - { - printf("main: ok 2\n"); - } - assert(sem_post(&s) == 0); return 0; diff --git a/tests/spin4.c b/tests/spin4.c index 44527fe..bf1227d 100644 --- a/tests/spin4.c +++ b/tests/spin4.c @@ -41,13 +41,8 @@ #include pthread_spinlock_t lock = PTHREAD_SPINLOCK_INITIALIZER; -#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 - struct __timeb64 currSysTimeStart; - struct __timeb64 currSysTimeStop; -#else - struct _timeb currSysTimeStart; - struct _timeb currSysTimeStop; -#endif +PTW32_STRUCT_TIMEB currSysTimeStart; +PTW32_STRUCT_TIMEB currSysTimeStop; #define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - (_TStart.time*1000+_TStart.millitm)) diff --git a/tests/stress1.c b/tests/stress1.c index e4dbbd2..7c787dc 100644 --- a/tests/stress1.c +++ b/tests/stress1.c @@ -111,11 +111,7 @@ 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 + PTW32_STRUCT_TIMEB currSysTime; int64_t nanosecs, secs; const int64_t NANOSEC_PER_MILLISEC = 1000000; const int64_t NANOSEC_PER_SEC = 1000000000; diff --git a/tests/test.h b/tests/test.h index 639ee55..042e87b 100644 --- a/tests/test.h +++ b/tests/test.h @@ -61,12 +61,16 @@ #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); +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define PTW32_FTIME(x) _ftime64_s(x) +# define PTW32_STRUCT_TIMEB struct __timeb64 +#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ + ( defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0601 ) +# define PTW32_FTIME(x) _ftime64(x) +# define PTW32_STRUCT_TIMEB struct __timeb64 #else - #define PTW32_FTIME(x) _ftime(x); +# define PTW32_FTIME(x) _ftime(x) +# define PTW32_STRUCT_TIMEB struct _timeb #endif -- cgit v1.2.3