Message ID | 20200128035004.2440732-1-raj.khem@gmail.com |
---|---|
State | New |
Headers | show |
Series | [Valgrind-developers,v2] tests: Make pthread_detatch call portable across platforms | expand |
On 2020-01-27 19:50, Khem Raj wrote: > pthread_t is opaque type therefore we can not apply simple arithmetic to variables of pthread_t type > this test needs to pass a invalid pthread_t handle, typcasting to uintptr_t works too and is portable > across glibc and musl > > Fixes > | pth_detached3.c:24:25: error: invalid use of undefined type 'struct __pthread' > | 24 | pthread_detach(thread + 8); > | | ^ > --- > v2: Use uintptr_t instead of long This patch has been applied with some small changes. Please take a look at commit 92fcf75d6d39. Thanks, Bart. _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers
diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c index c02eef11a..efeb15b72 100644 --- a/drd/tests/pth_detached3.c +++ b/drd/tests/pth_detached3.c @@ -4,6 +4,7 @@ #include <errno.h> #include <pthread.h> #include <stdio.h> +#include <stdint.h> static void* thread_func(void* arg) { @@ -21,7 +22,7 @@ int main(int argc, char** argv) pthread_detach(thread); /* Invoke pthread_detach() with an invalid thread ID. */ - pthread_detach(thread + 8); + pthread_detach((pthread_t)((uintptr_t)thread + 8)); fprintf(stderr, "Finished.\n");