Skip to content
Snippets Groups Projects
Commit a9979f55 authored by Cheng Shao's avatar Cheng Shao Committed by Marge Bot
Browse files

testsuite: fix testwsdeque with recent clang

This patch fixes compilation of testwsdeque.c with recent versions of
clang, which will fail with the error below:

```
testwsdeque.c:95:33: error:
     warning: format specifies type 'long' but the argument has type 'void *' [-Wformat]
       95 |         barf("FAIL: %ld %d %d", p, n, val);
          |                     ~~~         ^

testwsdeque.c:95:39: error:
     warning: format specifies type 'int' but the argument has type 'StgWord' (aka 'unsigned long') [-Wformat]
       95 |         barf("FAIL: %ld %d %d", p, n, val);
          |                            ~~         ^~~
          |                            %lu

testwsdeque.c:133:42: error:
     error: incompatible function pointer types passing 'void (void *)' to parameter of type 'OSThreadProc *' (aka 'void *(*)(void *)') [-Wincompatible-function-pointer-types]
      133 |         createOSThread(&ids[n], "thief", thief, (void*)(StgWord)n);
          |                                          ^~~~~

/workspace/ghc/_build/stage1/lib/../lib/x86_64-linux-ghc-9.11.20240502/rts-1.0.2/include/rts/OSThreads.h:193:51: error:
     note: passing argument to parameter 'startProc' here
      193 |                                     OSThreadProc *startProc, void *param);
          |                                                   ^

2 warnings and 1 error generated.
```
parent ab840ce6
No related branches found
No related tags found
No related merge requests found
......@@ -34,16 +34,16 @@ void *
myStealWSDeque_ (WSDeque *q, uint32_t n)
{
void * stolen;
// Can't do this on someone else's spark pool:
// ASSERT_WSDEQUE_INVARIANTS(q);
// ASSERT_WSDEQUE_INVARIANTS(q);
// NB. these loads must be ordered, otherwise there is a race
// between steal and pop.
StgWord t = ACQUIRE_LOAD(&q->top);
SEQ_CST_FENCE();
StgWord b = ACQUIRE_LOAD(&q->bottom);
void *result = NULL;
if (t < b) {
/* Non-empty queue */
......@@ -59,11 +59,11 @@ void *
myStealWSDeque (WSDeque *q, uint32_t n)
{
void *stolen;
do {
do {
stolen = myStealWSDeque_(q,n);
} while (stolen == NULL && !looksEmptyWSDeque(q));
return stolen;
}
......@@ -89,15 +89,15 @@ void work(void *p, uint32_t n)
// debugBelch("work %ld %d\n", p, n);
val = *(StgWord *)p;
if (val != 0) {
fflush(stdout);
fflush(stderr);
barf("FAIL: %ld %d %d", p, n, val);
if (val != 0) {
fflush(stdout);
fflush(stderr);
barf("FAIL: %p %" FMT_Word32 " %" FMT_Word, p, n, val);
}
*(StgWord*)p = n+10;
}
void OSThreadProcAttr thief(void *info)
void* OSThreadProcAttr thief(void *info)
{
void *p;
StgWord n;
......@@ -114,6 +114,7 @@ void OSThreadProcAttr thief(void *info)
if (p != NULL) { work(p,n+1); count++; }
}
debugBelch("thread %ld finished, stole %d", n, count);
return NULL;
}
int main(int argc, char*argv[])
......@@ -124,13 +125,13 @@ int main(int argc, char*argv[])
q = newWSDeque(1024);
done = 0;
for (n=0; n < SCRATCH_SIZE; n++) {
scratch[n] = 0;
}
for (n=0; n < THREADS; n++) {
createOSThread(&ids[n], "thief", thief, (void*)(StgWord)n);
createOSThread(&ids[n], "thief", (OSThreadProc*)thief, (void*)(StgWord)n);
}
for (n=0; n < SCRATCH_SIZE; n++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment