From 6d1ee58c0c98284f4b4fb0ea995062099c6be598 Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Fri, 3 May 2024 20:29:40 +0000 Subject: [PATCH] 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. ``` (cherry picked from commit a9979f55d0f688fabd25ee318e44b9addd904988) --- testsuite/tests/rts/testwsdeque.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/testsuite/tests/rts/testwsdeque.c b/testsuite/tests/rts/testwsdeque.c index 1c211ab80a0..dab68396f88 100644 --- a/testsuite/tests/rts/testwsdeque.c +++ b/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++) { -- GitLab