mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] powerpc: make ucontext_t API match glibc
@ 2018-02-21 20:19 Matthias Schiffer
  2018-02-22 18:28 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Schiffer @ 2018-02-21 20:19 UTC (permalink / raw)
  To: musl

In glibc, ucontext_t's uc_mcontext contains the uc_regs field, pointing at
the actual mcontext_t at the end of the structure. Bring our definition in
line with what glibc does to allow builing libunwind.
---

Note that this fixes only one of the two problems arising when building
libunwind on PPC with musl. The other is that libunwind needs register
definitions from Linux's asm/ptrace.h, which is pulled in through
sys/user.h in glibc. As asm/ptrace.h contains a conflicting pt_regs
definition, I've patched this into libunwind itself now in my OpenWrt tree:

https://git.openwrt.org/?p=openwrt/staging/neoraider.git;a=blob;f=package/libs/libunwind/patches/004-ppc-registers-musl.patch


 arch/powerpc/bits/signal.h  | 7 ++++---
 arch/powerpc/pthread_arch.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/bits/signal.h b/arch/powerpc/bits/signal.h
index 06efb11cf271..f842f5b82985 100644
--- a/arch/powerpc/bits/signal.h
+++ b/arch/powerpc/bits/signal.h
@@ -64,10 +64,11 @@ typedef struct __ucontext {
 	struct __ucontext *uc_link;
 	stack_t uc_stack;
 	int uc_pad[7];
-	mcontext_t *uc_regs;
+	struct {
+		mcontext_t *uc_regs;
+	} uc_mcontext;
 	sigset_t uc_sigmask;
-        int             uc_pad2[3];
-	mcontext_t uc_mcontext;
+	char uc_pad2[12 + sizeof(mcontext_t)];
 } ucontext_t;
 
 #define SA_NOCLDSTOP  1U
diff --git a/arch/powerpc/pthread_arch.h b/arch/powerpc/pthread_arch.h
index 7c5c4fadb211..8791ec5deb56 100644
--- a/arch/powerpc/pthread_arch.h
+++ b/arch/powerpc/pthread_arch.h
@@ -17,6 +17,6 @@ static inline struct pthread *__pthread_self()
 
 // the kernel calls the ip "nip", it's the first saved value after the 32
 // GPRs.
-#define MC_PC gregs[32]
+#define MC_PC uc_regs->gregs[32]
 
 #define CANARY canary_at_end
-- 
2.16.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-22 21:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 20:19 [PATCH] powerpc: make ucontext_t API match glibc Matthias Schiffer
2018-02-22 18:28 ` Rich Felker
2018-02-22 21:19   ` A. Wilcox

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).