1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-14 19:59:55 +03:00
aports/community/ghc/0003-testsuite-fix-testwsdeque-with-recent-clang.patch
2024-11-29 07:58:54 +00:00

129 lines
4 KiB
Diff

From 7a7812a48193c2908d6ab3e396ac8d972f6bd66f Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Fri, 3 May 2024 03:10:14 +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.
```
---
testsuite/tests/rts/testwsdeque.c | 35 ++++++++++++++++---------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/testsuite/tests/rts/testwsdeque.c b/testsuite/tests/rts/testwsdeque.c
index 8d3a88cf57..5467df98c4 100644
--- a/testsuite/tests/rts/testwsdeque.c
+++ b/testsuite/tests/rts/testwsdeque.c
@@ -34,21 +34,21 @@ void *
myStealWSDeque_ (WSDeque *q, uint32_t n)
{
void * stolen;
- StgWord b,t;
-
+ StgWord b,t;
+
// 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.
t = q->top;
load_load_barrier();
b = q->bottom;
-
+
// NB. b and t are unsigned; we need a signed value for the test
// below, because it is possible that t > b during a
// concurrent popWSQueue() operation.
- if ((long)b - (long)t <= 0 ) {
+ if ((long)b - (long)t <= 0 ) {
return NULL; /* already looks empty, abort */
}
// NB. the load of q->bottom must be ordered before the load of
@@ -81,11 +81,11 @@ void *
myStealWSDeque (WSDeque *q, uint32_t n)
{
void *stolen;
-
- do {
+
+ do {
stolen = myStealWSDeque_(q,n);
} while (stolen == NULL && !looksEmptyWSDeque(q));
-
+
return stolen;
}
@@ -111,15 +111,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;
@@ -136,6 +136,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[])
@@ -146,13 +147,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++) {