Cygwin: testsuite: 64-bit fixes in pthread testcases

Fix warnings and 64-bit issues in pthread testcases.

See pthread-win32 commit 1183e5ac etc.
This commit is contained in:
Jon Turney 2022-08-31 14:53:45 +01:00
parent 01a0e3e491
commit 52983af631
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
17 changed files with 77 additions and 77 deletions

View File

@ -96,7 +96,7 @@ mythread(void * arg)
pthread_testcancel(); pthread_testcancel();
} }
return (void *) result; return (void *) (size_t)result;
} }
int int
@ -156,17 +156,17 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void *result = 0;
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result != (int) PTHREAD_CANCELED); fail = (result != PTHREAD_CANCELED);
if (fail) if (fail)
{ {
fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n", fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n",
i, i,
threadbag[i].started, threadbag[i].started,
result, result,
((result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED"); (((int)(size_t)result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED");
} }
failed |= fail; failed |= fail;
} }

View File

@ -61,7 +61,7 @@ static bag_t threadbag[NUMTHREADS + 1];
void * void *
mythread(void * arg) mythread(void * arg)
{ {
int result = ((int)PTHREAD_CANCELED + 1); void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
bag_t * bag = (bag_t *) arg; bag_t * bag = (bag_t *) arg;
assert(bag == &threadbag[bag->threadnum]); assert(bag == &threadbag[bag->threadnum]);
@ -81,7 +81,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++) for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100); Sleep(100);
return (void *) result; return result;
} }
int int
@ -136,16 +136,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void *result = 0;
/* /*
* The thread does not contain any cancelation points, so * The thread does not contain any cancelation points, so
* a return value of PTHREAD_CANCELED confirms that async * a return value of PTHREAD_CANCELED confirms that async
* cancelation succeeded. * cancelation succeeded.
*/ */
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result != (int) PTHREAD_CANCELED); fail = (result != PTHREAD_CANCELED);
if (fail) if (fail)
{ {

View File

@ -66,7 +66,7 @@ static bag_t threadbag[NUMTHREADS + 1];
void * void *
mythread(void * arg) mythread(void * arg)
{ {
int result = ((int)PTHREAD_CANCELED + 1); void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
bag_t * bag = (bag_t *) arg; bag_t * bag = (bag_t *) arg;
assert(bag == &threadbag[bag->threadnum]); assert(bag == &threadbag[bag->threadnum]);
@ -86,7 +86,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++) for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100); Sleep(100);
return (void *) result; return result;
} }
int int
@ -141,16 +141,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void* result = 0;
/* /*
* The thread does not contain any cancelation points, so * The thread does not contain any cancelation points, so
* a return value of PTHREAD_CANCELED indicates that async * a return value of PTHREAD_CANCELED indicates that async
* cancelation occurred. * cancelation occurred.
*/ */
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result == (int) PTHREAD_CANCELED); fail = (result == PTHREAD_CANCELED);
if (fail) if (fail)
{ {

View File

@ -62,7 +62,7 @@ static bag_t threadbag[NUMTHREADS + 1];
void * void *
mythread(void * arg) mythread(void * arg)
{ {
int result = ((int)PTHREAD_CANCELED + 1); void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
bag_t * bag = (bag_t *) arg; bag_t * bag = (bag_t *) arg;
assert(bag == &threadbag[bag->threadnum]); assert(bag == &threadbag[bag->threadnum]);
@ -82,7 +82,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++) for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100); Sleep(100);
return (void *) result; return result;
} }
int int
@ -96,7 +96,7 @@ main()
{ {
threadbag[i].started = 0; threadbag[i].started = 0;
threadbag[i].threadnum = i; threadbag[i].threadnum = i;
assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); assert(pthread_create(&t[i], NULL, mythread, &threadbag[i]) == 0);
} }
/* /*
@ -135,16 +135,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
/* /*
* The thread does not contain any cancelation points, so * The thread does not contain any cancelation points, so
* a return value of PTHREAD_CANCELED confirms that async * a return value of PTHREAD_CANCELED confirms that async
* cancelation succeeded. * cancelation succeeded.
*/ */
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result != (int) PTHREAD_CANCELED); fail = (result != PTHREAD_CANCELED);
if (fail) if (fail)
{ {

View File

@ -84,7 +84,7 @@ mythread(void * arg)
pthread_cleanup_pop(1); pthread_cleanup_pop(1);
return (void *) result; return (void *) (size_t) result;
} }
int int
@ -129,18 +129,18 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void* result = 0;
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result != 0); fail = ((int)(size_t)result != 0);
if (fail) if (fail)
{ {
fprintf(stderr, "Thread %d: started %d: result: %d\n", fprintf(stderr, "Thread %d: started %d: result: %d\n",
i, i,
threadbag[i].started, threadbag[i].started,
result); (int)(size_t)result);
} }
failed = (failed || fail); failed = (failed || fail);
} }

View File

@ -87,7 +87,7 @@ mythread(void * arg)
pthread_cleanup_pop(0); pthread_cleanup_pop(0);
return (void *) result; return (void *) (size_t)result;
} }
int int
@ -132,9 +132,9 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
int fail = 0; int fail = 0;
int result = 0; void* result = 0;
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = (result != 0); fail = (result != 0);
@ -143,7 +143,7 @@ main()
fprintf(stderr, "Thread %d: started %d: result: %d\n", fprintf(stderr, "Thread %d: started %d: result: %d\n",
i, i,
threadbag[i].started, threadbag[i].started,
result); (int)(size_t)result);
} }
failed = (failed || fail); failed = (failed || fail);
} }

View File

@ -69,7 +69,7 @@ main()
{ {
int i; int i;
pthread_t t[NUMTHREADS + 1]; pthread_t t[NUMTHREADS + 1];
int result = 0; void* result = 0;
struct timeb currSysTime; struct timeb currSysTime;
const DWORD NANOSEC_PER_MILLISEC = 1000000; const DWORD NANOSEC_PER_MILLISEC = 1000000;
@ -89,19 +89,19 @@ main()
for (i = 1; i <= NUMTHREADS; i++) 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); assert(pthread_mutex_unlock(&mutex) == 0);
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert(result == i); assert((int)(size_t)result == i);
} }
result = pthread_cond_destroy(&cv); int result2 = pthread_cond_destroy(&cv);
assert(result == 0); assert(result2 == 0);
return 0; return 0;
} }

View File

@ -89,7 +89,7 @@ main()
{ {
int i; int i;
pthread_t t[NUMTHREADS + 1]; pthread_t t[NUMTHREADS + 1];
int result = 0; void* result = 0;
struct timeb currSysTime; struct timeb currSysTime;
const DWORD NANOSEC_PER_MILLISEC = 1000000; const DWORD NANOSEC_PER_MILLISEC = 1000000;
@ -110,7 +110,7 @@ main()
for (i = 1; i <= NUMTHREADS; i++) 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 { do {
@ -127,8 +127,8 @@ main()
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert(result == i); assert((int)(size_t)result == i);
} }
printf("awk = %d\n", awoken); printf("awk = %d\n", awoken);
@ -138,8 +138,8 @@ main()
assert(signaled == awoken); assert(signaled == awoken);
assert(timedout == NUMTHREADS - signaled); assert(timedout == NUMTHREADS - signaled);
result = pthread_cond_destroy(&cv); int result2 = pthread_cond_destroy(&cv);
assert(result == 0); assert(result2 == 0);
return 0; return 0;
} }

View File

@ -66,7 +66,7 @@ mythread(void * arg)
abstime2.tv_sec = abstime.tv_sec; abstime2.tv_sec = abstime.tv_sec;
if ((int) arg % 3 == 0) if ((int) (size_t)arg % 3 == 0)
{ {
abstime2.tv_sec += 2; abstime2.tv_sec += 2;
} }
@ -91,7 +91,7 @@ main()
{ {
int i; int i;
pthread_t t[NUMTHREADS + 1]; pthread_t t[NUMTHREADS + 1];
int result = 0; void* result = 0;
struct timeb currSysTime; struct timeb currSysTime;
const DWORD NANOSEC_PER_MILLISEC = 1000000; const DWORD NANOSEC_PER_MILLISEC = 1000000;
@ -109,15 +109,15 @@ main()
for (i = 1; i <= NUMTHREADS; i++) 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); assert(pthread_mutex_unlock(&mutex) == 0);
for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void **) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert(result == i); assert((int)(size_t)result == i);
/* /*
* Approximately 2/3rds of the threads are expected to time out. * Approximately 2/3rds of the threads are expected to time out.
* Signal the remainder after some threads have woken up and exited * Signal the remainder after some threads have woken up and exited
@ -132,8 +132,8 @@ main()
assert(awoken == NUMTHREADS - timedout); assert(awoken == NUMTHREADS - timedout);
result = pthread_cond_destroy(&cv); int result2 = pthread_cond_destroy(&cv);
assert(result == 0); assert(result2 == 0);
return 0; return 0;
} }

View File

@ -24,7 +24,7 @@ main(int argc, char * argv[])
/* Create a few threads and then exit. */ /* Create a few threads and then exit. */
for (i = 0; i < 4; i++) 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); Sleep(1000);

View File

@ -47,7 +47,7 @@ void * func(void * arg)
struct sched_param param; struct sched_param param;
assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0); assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
return (void *) param.sched_priority; return (void *) (size_t)param.sched_priority;
} }
int int
@ -91,7 +91,7 @@ main()
assert(pthread_attr_setschedparam(&attr, &param) == 0); assert(pthread_attr_setschedparam(&attr, &param) == 0);
assert(pthread_create(&t, &attr, func, NULL) == 0); assert(pthread_create(&t, &attr, func, NULL) == 0);
pthread_join(t, &result); pthread_join(t, &result);
assert((int) result == mainParam.sched_priority); assert((int)(size_t) result == mainParam.sched_priority);
} }
} }

View File

@ -9,7 +9,7 @@
void * void *
func(void * arg) func(void * arg)
{ {
int i = (int) arg; int i = (int)(size_t)arg;
Sleep(i * 500); Sleep(i * 500);
@ -24,12 +24,12 @@ main(int argc, char * argv[])
{ {
pthread_t id[4]; pthread_t id[4];
int i; int i;
int result; void* result = (void*)-1;
/* Create a few threads and then exit. */ /* Create a few threads and then exit. */
for (i = 0; i < 4; i++) 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. */ /* Some threads will finish before they are joined, some after. */
@ -37,9 +37,9 @@ main(int argc, char * argv[])
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
assert(pthread_join(id[i], (void **) &result) == 0); assert(pthread_join(id[i], &result) == 0);
#if ! defined (__MINGW32__) || defined (__MSVCRT__) #if ! defined (__MINGW32__) || defined (__MSVCRT__)
assert(result == i); assert((int)(size_t)result == i);
#else #else
# warning pthread_join not fully supported in this configuration. # warning pthread_join not fully supported in this configuration.
assert(result == 0); assert(result == 0);

View File

@ -18,21 +18,21 @@ main(int argc, char * argv[])
{ {
pthread_t id[4]; pthread_t id[4];
int i; int i;
int result; void* result = (void*)-1;
/* Create a few threads and then exit. */ /* Create a few threads and then exit. */
for (i = 0; i < 4; i++) 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++) for (i = 0; i < 4; i++)
{ {
assert(pthread_join(id[i], (void **) &result) == 0); assert(pthread_join(id[i], &result) == 0);
#if ! defined (__MINGW32__) || defined (__MSVCRT__) #if ! defined (__MINGW32__) || defined (__MSVCRT__)
/* CRTDLL _beginthread doesn't support return value, so /* CRTDLL _beginthread doesn't support return value, so
the assertion is guaranteed to fail. */ the assertion is guaranteed to fail. */
assert(result == i); assert((int)(size_t)result == i);
#endif #endif
} }

View File

@ -17,7 +17,7 @@ static pthread_mutex_t mutex1;
void * unlocker(void * arg) void * unlocker(void * arg)
{ {
int expectedResult = (int) arg; int expectedResult = (int)(size_t)arg;
wasHere++; wasHere++;
assert(pthread_mutex_unlock(&mutex1) == expectedResult); assert(pthread_mutex_unlock(&mutex1) == expectedResult);

View File

@ -48,7 +48,7 @@ void * func(void * arg)
assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0); assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
assert(policy == SCHED_OTHER); assert(policy == SCHED_OTHER);
return (void *) param.sched_priority; return (void *)(size_t)param.sched_priority;
} }
int int
@ -71,7 +71,7 @@ main()
assert(pthread_attr_setschedparam(&attr, &param) == 0); assert(pthread_attr_setschedparam(&attr, &param) == 0);
assert(pthread_create(&t, &attr, func, NULL) == 0); assert(pthread_create(&t, &attr, func, NULL) == 0);
pthread_join(t, &result); pthread_join(t, &result);
assert((int) result == param.sched_priority); assert((int)(size_t) result == param.sched_priority);
} }
return 0; return 0;

View File

@ -52,7 +52,7 @@ void * func(void * arg)
assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0); assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
assert(pthread_mutex_unlock(&startMx) == 0); assert(pthread_mutex_unlock(&startMx) == 0);
assert(policy == SCHED_OTHER); assert(policy == SCHED_OTHER);
return (void *) param.sched_priority; return (void *) (size_t)param.sched_priority;
} }
int int
@ -73,7 +73,7 @@ main()
assert(pthread_setschedparam(t, SCHED_OTHER, &param) == 0); assert(pthread_setschedparam(t, SCHED_OTHER, &param) == 0);
assert(pthread_mutex_unlock(&startMx) == 0); assert(pthread_mutex_unlock(&startMx) == 0);
pthread_join(t, &result); pthread_join(t, &result);
assert((int) result == param.sched_priority); assert((int)(size_t)result == param.sched_priority);
} }
return 0; return 0;

View File

@ -25,7 +25,7 @@ void * wrfunc(void * arg)
ba = bankAccount; ba = bankAccount;
assert(pthread_rwlock_unlock(&rwlock1) == 0); assert(pthread_rwlock_unlock(&rwlock1) == 0);
return ((void *) ba); return ((void *)(size_t)ba);
} }
void * rdfunc(void * arg) void * rdfunc(void * arg)
@ -36,7 +36,7 @@ void * rdfunc(void * arg)
ba = bankAccount; ba = bankAccount;
assert(pthread_rwlock_unlock(&rwlock1) == 0); assert(pthread_rwlock_unlock(&rwlock1) == 0);
return ((void *) ba); return ((void *)(size_t)ba);
} }
int int
@ -45,9 +45,9 @@ main()
pthread_t wrt1; pthread_t wrt1;
pthread_t wrt2; pthread_t wrt2;
pthread_t rdt; pthread_t rdt;
int wr1Result = 0; void* wr1Result = 0;
int wr2Result = 0; void* wr2Result = 0;
int rdResult = 0; void* rdResult = 0;
bankAccount = 0; bankAccount = 0;
@ -57,13 +57,13 @@ main()
Sleep(500); Sleep(500);
assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0);
assert(pthread_join(wrt1, (void **) &wr1Result) == 0); assert(pthread_join(wrt1, &wr1Result) == 0);
assert(pthread_join(rdt, (void **) &rdResult) == 0); assert(pthread_join(rdt, &rdResult) == 0);
assert(pthread_join(wrt2, (void **) &wr2Result) == 0); assert(pthread_join(wrt2, &wr2Result) == 0);
assert(wr1Result == 10); assert((int)(size_t)wr1Result == 10);
assert(rdResult == 20); assert((int)(size_t)rdResult == 20);
assert(wr2Result == 20); assert((int)(size_t)wr2Result == 20);
return 0; return 0;
} }