[Git][ghc/ghc][master] testsuite: fix testwsdeque with recent clang
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Fri May 10 05:51:00 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
a9979f55 by Cheng Shao at 2024-05-10T01:49:43-04:00
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.
```
- - - - -
1 changed file:
- testsuite/tests/rts/testwsdeque.c
Changes:
=====================================
testsuite/tests/rts/testwsdeque.c
=====================================
@@ -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++) {
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9979f55d0f688fabd25ee318e44b9addd904988
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9979f55d0f688fabd25ee318e44b9addd904988
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240510/7c128c72/attachment-0001.html>
More information about the ghc-commits
mailing list