On Mon, Mar 07, 2022 at 02:59:02PM -0800, Ian Lance Taylor wrote: > On Sun, Mar 6, 2022 at 11:11 PM <soe...@soeren-tempel.net> wrote: > > > > +#ifdef __PPC64__ > > + ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gp_regs[32]; > > +#else > > + ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[32]; > > +#endif > > Have you tested this in 32-bit mode? It does not look correct based > on the glibc definitions. Looking at glibc it seems that it ought to > be > > reg.sigpc = ((ucontext_t*)(context))->uc_mcontext.uc_regs->gregs[32];
Indeed, I think it has to use that conditional on __GLIBC__. I was thinking the union glibc has was an anon union, but no, it's named uc_mcontext despite not having type mcontext_t. Ideally glibc could fix this by doing: union { union __ctx(uc_regs_ptr) { struct __ctx(pt_regs) *__ctx(regs); mcontext_t *__ctx(uc_regs); } uc_mcontext; mcontext_t *__ctx(uc_regs); }; so that there would be a common API for accessing it that doesn't conflict with the properties the standard mandates. Rich