blob: 7f0e38cb955c9b8b7f9fcb0062c1f84ad33b13f0 [file] [log] [blame]
Andrew Geisslerc926e172021-05-07 16:11:35 -05001From 26c104adf6c5162572b7aa2fac89d0835b7f8f0b Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Randy MacLeod <Randy.MacLeod@windriver.com>
3Date: Tue, 16 Oct 2018 21:27:46 -0400
4Subject: [PATCH] context APIs are not available on musl
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006Updated patch for valgrind-3.14
7
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008Signed-off-by: Khem Raj <raj.khem@gmail.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08009Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010
Andrew Geisslerc926e172021-05-07 16:11:35 -050011Apply same patch to drd/tests/swapcontext.c
12for valgrind-3.17.
13
14Upstream-Status: Submitted [https://bugs.kde.org/show_bug.cgi?id=434775]
15
16Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
17---
18 drd/tests/swapcontext.c | 6 ++++++
19 memcheck/tests/linux/stack_changes.c | 7 ++++++-
20 2 files changed, 12 insertions(+), 1 deletion(-)
21
22diff --git a/drd/tests/swapcontext.c b/drd/tests/swapcontext.c
23index 622c70bc5..5e72bb0f3 100644
24--- a/drd/tests/swapcontext.c
25+++ b/drd/tests/swapcontext.c
26@@ -20,6 +20,7 @@
27
28 #define STACKSIZE (PTHREAD_STACK_MIN + 4096)
29
30+#ifdef __GLIBC__
31 typedef struct thread_local {
32 ucontext_t uc[3];
33 size_t nrsw;
34@@ -67,9 +68,11 @@ void *worker(void *data)
35 swapcontext(&tlocal->uc[0], &tlocal->uc[1]);
36 return NULL;
37 }
38+#endif
39
40 int main(int argc, char *argv[])
41 {
42+#ifdef __GLIBC__
43 enum { NR = 32 };
44 thread_local_t tlocal[NR];
45 pthread_t thread[NR];
46@@ -94,6 +97,9 @@ int main(int argc, char *argv[])
47
48 for (i = 0; i < NR; i++)
49 pthread_join(thread[i], NULL);
50+#else
51+ printf("libc context call APIs e.g. getcontext() are deprecated by posix\n");
52+#endif
53
54 return 0;
55 }
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056diff --git a/memcheck/tests/linux/stack_changes.c b/memcheck/tests/linux/stack_changes.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057index 7f97b90a5..a26cb4ae6 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050058--- a/memcheck/tests/linux/stack_changes.c
59+++ b/memcheck/tests/linux/stack_changes.c
60@@ -10,6 +10,7 @@
61 // This test is checking the libc context calls (setcontext, etc.) and
62 // checks that Valgrind notices their stack changes properly.
63
64+#ifdef __GLIBC__
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080065 typedef ucontext_t mycontext;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050066
67 mycontext ctx1, ctx2, oldc;
68@@ -51,9 +52,11 @@ int init_context(mycontext *uc)
69
70 return ret;
71 }
72+#endif
73
74 int main(int argc, char **argv)
75 {
76+#ifdef __GLIBC__
77 int c1 = init_context(&ctx1);
78 int c2 = init_context(&ctx2);
79
80@@ -66,6 +69,8 @@ int main(int argc, char **argv)
81 //free(ctx1.uc_stack.ss_sp);
82 VALGRIND_STACK_DEREGISTER(c2);
83 //free(ctx2.uc_stack.ss_sp);
84-
85+#else
86+ printf("libc context call APIs e.g. getcontext() are deprecated by posix\n");
87+#endif
88 return 0;
89 }
90--
Andrew Geisslerc926e172021-05-07 16:11:35 -0500912.17.1
Brad Bishopd7bf8c12018-02-25 22:55:05 -050092