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

View File

@ -61,7 +61,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]);
@ -81,7 +81,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100);
return (void *) result;
return result;
}
int
@ -136,16 +136,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++)
{
int fail = 0;
int result = 0;
void *result = 0;
/*
* 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 = (result != (int) PTHREAD_CANCELED);
fail = (result != PTHREAD_CANCELED);
if (fail)
{

View File

@ -66,7 +66,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]);
@ -86,7 +86,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100);
return (void *) result;
return result;
}
int
@ -141,16 +141,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++)
{
int fail = 0;
int result = 0;
void* result = 0;
/*
* The thread does not contain any cancelation points, so
* 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 = (result == (int) PTHREAD_CANCELED);
fail = (result == PTHREAD_CANCELED);
if (fail)
{

View File

@ -62,7 +62,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]);
@ -82,7 +82,7 @@ mythread(void * arg)
for (bag->count = 0; bag->count < 100; bag->count++)
Sleep(100);
return (void *) result;
return result;
}
int
@ -96,7 +96,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, &threadbag[i]) == 0);
}
/*
@ -135,16 +135,16 @@ main()
for (i = 1; i <= NUMTHREADS; i++)
{
int fail = 0;
int result = 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 = (result != (int) PTHREAD_CANCELED);
fail = (result != PTHREAD_CANCELED);
if (fail)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,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);

View File

@ -47,7 +47,7 @@ void * func(void * arg)
struct sched_param param;
assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
return (void *) param.sched_priority;
return (void *) (size_t)param.sched_priority;
}
int
@ -91,7 +91,7 @@ main()
assert(pthread_attr_setschedparam(&attr, &param) == 0);
assert(pthread_create(&t, &attr, func, NULL) == 0);
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 *
func(void * arg)
{
int i = (int) arg;
int i = (int)(size_t)arg;
Sleep(i * 500);
@ -24,12 +24,12 @@ main(int argc, char * argv[])
{
pthread_t id[4];
int i;
int result;
void* result = (void*)-1;
/* 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. */
@ -37,9 +37,9 @@ main(int argc, char * argv[])
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__)
assert(result == i);
assert((int)(size_t)result == i);
#else
# warning pthread_join not fully supported in this configuration.
assert(result == 0);

View File

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

View File

@ -17,7 +17,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);

View File

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

View File

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

View File

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