]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
f407d8191bb0c7177f86db6a09b848c96433eec7
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 92fcf75d6d3903e45492b041bf4ad07787d2e58a Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Mon, 27 Jan 2020 19:50:04 -0800
4 Subject: [PATCH] drd/tests/pth_detached3: Make pthread_detach() call portable
5 across platforms
6
7 pthread_t is opaque type therefore we can not apply simple arithmetic to
8 variables of pthread_t type this test needs to pass a invalid pthread_t
9 handle, typcasting to uintptr_t works too and is portable across glibc and
10 musl
11
12 Fixes
13 | pth_detached3.c:24:25: error: invalid use of undefined type 'struct __pthread'
14 | 24 | pthread_detach(thread + 8);
15 | | ^
16
17 [ bvanassche: reformatted patch description and fixed up line numbers ]
18
19 Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=92fcf75d6d3903e45492b041bf4ad07787d2e58a]
20 Signed-off-by: Khem Raj <raj.khem@gmail.com>
21 ---
22 drd/tests/pth_detached3.c | 3 ++-
23 drd/tests/pth_detached3.stderr.exp1 | 4 ++--
24 drd/tests/pth_detached3.stderr.exp2 | 4 ++--
25 3 files changed, 6 insertions(+), 5 deletions(-)
26
27 diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c
28 index c02eef1..efeb15b 100644
29 --- a/drd/tests/pth_detached3.c
30 +++ b/drd/tests/pth_detached3.c
31 @@ -4,6 +4,7 @@
32 #include <errno.h>
33 #include <pthread.h>
34 #include <stdio.h>
35 +#include <stdint.h>
36
37 static void* thread_func(void* arg)
38 {
39 @@ -21,7 +22,7 @@ int main(int argc, char** argv)
40 pthread_detach(thread);
41
42 /* Invoke pthread_detach() with an invalid thread ID. */
43 - pthread_detach(thread + 8);
44 + pthread_detach((pthread_t)((uintptr_t)thread + 8));
45
46 fprintf(stderr, "Finished.\n");
47
48 diff --git a/drd/tests/pth_detached3.stderr.exp1 b/drd/tests/pth_detached3.stderr.exp1
49 index 58412ec..8dd58ba 100644
50 --- a/drd/tests/pth_detached3.stderr.exp1
51 +++ b/drd/tests/pth_detached3.stderr.exp1
52 @@ -1,11 +1,11 @@
53
54 pthread_detach(): invalid thread ID 0x........
55 at 0x........: pthread_detach (drd_pthread_intercepts.c:?)
56 - by 0x........: main (pth_detached3.c:21)
57 + by 0x........: main (pth_detached3.c:22)
58
59 pthread_detach(): invalid thread ID 0x........
60 at 0x........: pthread_detach (drd_pthread_intercepts.c:?)
61 - by 0x........: main (pth_detached3.c:24)
62 + by 0x........: main (pth_detached3.c:25)
63
64 Finished.
65
66 diff --git a/drd/tests/pth_detached3.stderr.exp2 b/drd/tests/pth_detached3.stderr.exp2
67 index bdc5cf8..e82dee1 100644
68 --- a/drd/tests/pth_detached3.stderr.exp2
69 +++ b/drd/tests/pth_detached3.stderr.exp2
70 @@ -2,12 +2,12 @@
71 pthread_detach(): invalid thread ID 0x........
72 at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?)
73 by 0x........: pthread_detach (drd_pthread_intercepts.c:?)
74 - by 0x........: main (pth_detached3.c:21)
75 + by 0x........: main (pth_detached3.c:22)
76
77 pthread_detach(): invalid thread ID 0x........
78 at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?)
79 by 0x........: pthread_detach (drd_pthread_intercepts.c:?)
80 - by 0x........: main (pth_detached3.c:24)
81 + by 0x........: main (pth_detached3.c:25)
82
83 Finished.
84
85 --
86 2.9.3
87