Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame^] | 1 | From 26c104adf6c5162572b7aa2fac89d0835b7f8f0b Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: Randy MacLeod <Randy.MacLeod@windriver.com> |
| 3 | Date: Tue, 16 Oct 2018 21:27:46 -0400 |
| 4 | Subject: [PATCH] context APIs are not available on musl |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 6 | Updated patch for valgrind-3.14 |
| 7 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 9 | Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame^] | 11 | Apply same patch to drd/tests/swapcontext.c |
| 12 | for valgrind-3.17. |
| 13 | |
| 14 | Upstream-Status: Submitted [https://bugs.kde.org/show_bug.cgi?id=434775] |
| 15 | |
| 16 | Signed-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 | |
| 22 | diff --git a/drd/tests/swapcontext.c b/drd/tests/swapcontext.c |
| 23 | index 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 56 | diff --git a/memcheck/tests/linux/stack_changes.c b/memcheck/tests/linux/stack_changes.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | index 7f97b90a5..a26cb4ae6 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 58 | --- 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | typedef ucontext_t mycontext; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 66 | |
| 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame^] | 91 | 2.17.1 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | |