Skip to contentSkip to conversation

replace struct ucontext with ucontext_t type

PATCH In review Khem Raj 9 participants 13 messages Jun 28, 2017 – Jul 20, 2017

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 replace struct ucontext with ucontext_t type

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

Cc Kamil Rytarowski <[email protected]>
Cc Riku Voipio <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 linux-user/host/aarch64/hostdep.h |  2 +-
 linux-user/host/arm/hostdep.h     |  2 +-
 linux-user/host/i386/hostdep.h    |  2 +-
 linux-user/host/ppc64/hostdep.h   |  2 +-
 linux-user/host/s390x/hostdep.h   |  2 +-
 linux-user/host/x86_64/hostdep.h  |  2 +-
 linux-user/signal.c               | 10 +++++-----
 tests/tcg/test-i386.c             |  4 ++--
 user-exec.c                       | 18 +++++++++---------
 9 files changed, 22 insertions(+), 22 deletions(-)
linux-user/host/aarch64/hostdep.h +1 -1
index 64f75cef49..a8d41a21ad 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     __u64 *pcreg = &uc->uc_mcontext.pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/arm/hostdep.h +1 -1
index 5c1ae60120..9276fe6ceb 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/i386/hostdep.h +1 -1
index d834bd80ea..073be74d87 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/ppc64/hostdep.h +1 -1
index 0b0f5f7821..98979ad917 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/s390x/hostdep.h +1 -1
index 6f9da9c608..4f0171f36f 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/x86_64/hostdep.h +1 -1
index 3b4259633e..a4fefb5114 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/signal.c +5 -5
index 3d18d1b3ee..2c55a4f600 100644
@@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     *
     *   a0 = signal number
     *   a1 = pointer to siginfo_t
-    *   a2 = pointer to struct ucontext
+    *   a2 = pointer to ucontext_t
     *
     * $25 and PC point to the signal handler, $29 points to the
     * struct sigframe.
@@ -3733,7 +3733,7 @@ struct target_signal_frame {
 
 struct rt_signal_frame {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint32_t tramp[2];
 };
 
@@ -3949,7 +3949,7 @@ struct rt_signal_frame {
     siginfo_t *pinfo;
     void *puc;
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint16_t retcode[4];      /* Trampoline code. */
 };
 
@@ -4484,7 +4484,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
         tswap_siginfo(&frame->info, info);
     }
 
-    /*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
+    /*err |= __clear_user(&frame->uc, offsetof(ucontext_t, uc_mcontext));*/
     __put_user(0, &frame->uc.tuc_flags);
     __put_user(0, &frame->uc.tuc_link);
     __put_user(target_sigaltstack_used.ss_sp,
@@ -4976,7 +4976,7 @@ enum {
 
 struct target_ucontext {
     target_ulong tuc_flags;
-    target_ulong tuc_link;    /* struct ucontext __user * */
+    target_ulong tuc_link;    /* ucontext_t __user * */
     struct target_sigaltstack tuc_stack;
 #if !defined(TARGET_PPC64)
     int32_t tuc_pad[7];
tests/tcg/test-i386.c +2 -2
index 0f7b943b0c..9599204895 100644
@@ -1720,7 +1720,7 @@ int tab[2];
 
 void sig_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 
     printf("si_signo=%d si_errno=%d si_code=%d",
            info->si_signo, info->si_errno, info->si_code);
@@ -1912,7 +1912,7 @@ void test_exceptions(void)
 /* specific precise single step test */
 void sig_trap_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     printf("EIP=" FMTLX "\n", (long)uc->uc_mcontext.gregs[REG_EIP]);
 }
 
user-exec.c +9 -9
index a8f95fa1e1..2a975eaf69 100644
@@ -167,7 +167,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int trapno;
@@ -222,7 +222,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
 
     pc = PC_sig(uc);
@@ -289,7 +289,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -316,7 +316,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                            void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uint32_t *pc = uc->uc_mcontext.sc_pc;
     uint32_t insn = *pc;
     int is_write = 0;
@@ -414,7 +414,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__NetBSD__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -441,7 +441,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uintptr_t pc = uc->uc_mcontext.pc;
     uint32_t insn = *(uint32_t *)pc;
     bool is_write;
@@ -474,7 +474,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long ip;
     int is_write = 0;
 
@@ -505,7 +505,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long pc;
     uint16_t *pinsn;
     int is_write = 0;
@@ -558,7 +558,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t pc = uc->uc_mcontext.pc;
     int is_write;
 
Signature · 1 line
2.13.2
#1 lore raw
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

I didn't find in glib git tree the commit dropping the struct tags for ucontext. Could you point it out?

Thanks,
Laurent

Quoted 252 lines
Cc Kamil Rytarowski <[email protected]>
Cc Riku Voipio <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 linux-user/host/aarch64/hostdep.h |  2 +-
 linux-user/host/arm/hostdep.h     |  2 +-
 linux-user/host/i386/hostdep.h    |  2 +-
 linux-user/host/ppc64/hostdep.h   |  2 +-
 linux-user/host/s390x/hostdep.h   |  2 +-
 linux-user/host/x86_64/hostdep.h  |  2 +-
 linux-user/signal.c               | 10 +++++-----
 tests/tcg/test-i386.c             |  4 ++--
 user-exec.c                       | 18 +++++++++---------
 9 files changed, 22 insertions(+), 22 deletions(-)
linux-user/host/aarch64/hostdep.h +1 -1
index 64f75cef49..a8d41a21ad 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     __u64 *pcreg = &uc->uc_mcontext.pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/arm/hostdep.h +1 -1
index 5c1ae60120..9276fe6ceb 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/i386/hostdep.h +1 -1
index d834bd80ea..073be74d87 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/ppc64/hostdep.h +1 -1
index 0b0f5f7821..98979ad917 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/s390x/hostdep.h +1 -1
index 6f9da9c608..4f0171f36f 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/x86_64/hostdep.h +1 -1
index 3b4259633e..a4fefb5114 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/signal.c +5 -5
index 3d18d1b3ee..2c55a4f600 100644
@@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     *
     *   a0 = signal number
     *   a1 = pointer to siginfo_t
-    *   a2 = pointer to struct ucontext
+    *   a2 = pointer to ucontext_t
     *
     * $25 and PC point to the signal handler, $29 points to the
     * struct sigframe.
@@ -3733,7 +3733,7 @@ struct target_signal_frame {
 
 struct rt_signal_frame {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint32_t tramp[2];
 };
 
@@ -3949,7 +3949,7 @@ struct rt_signal_frame {
     siginfo_t *pinfo;
     void *puc;
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint16_t retcode[4];      /* Trampoline code. */
 };
 
@@ -4484,7 +4484,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
         tswap_siginfo(&frame->info, info);
     }
 
-    /*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
+    /*err |= __clear_user(&frame->uc, offsetof(ucontext_t, uc_mcontext));*/
     __put_user(0, &frame->uc.tuc_flags);
     __put_user(0, &frame->uc.tuc_link);
     __put_user(target_sigaltstack_used.ss_sp,
@@ -4976,7 +4976,7 @@ enum {
 
 struct target_ucontext {
     target_ulong tuc_flags;
-    target_ulong tuc_link;    /* struct ucontext __user * */
+    target_ulong tuc_link;    /* ucontext_t __user * */
     struct target_sigaltstack tuc_stack;
 #if !defined(TARGET_PPC64)
     int32_t tuc_pad[7];
tests/tcg/test-i386.c +2 -2
index 0f7b943b0c..9599204895 100644
@@ -1720,7 +1720,7 @@ int tab[2];
 
 void sig_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 
     printf("si_signo=%d si_errno=%d si_code=%d",
            info->si_signo, info->si_errno, info->si_code);
@@ -1912,7 +1912,7 @@ void test_exceptions(void)
 /* specific precise single step test */
 void sig_trap_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     printf("EIP=" FMTLX "\n", (long)uc->uc_mcontext.gregs[REG_EIP]);
 }
 
user-exec.c +9 -9
index a8f95fa1e1..2a975eaf69 100644
@@ -167,7 +167,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int trapno;
@@ -222,7 +222,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
 
     pc = PC_sig(uc);
@@ -289,7 +289,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -316,7 +316,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                            void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uint32_t *pc = uc->uc_mcontext.sc_pc;
     uint32_t insn = *pc;
     int is_write = 0;
@@ -414,7 +414,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__NetBSD__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -441,7 +441,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uintptr_t pc = uc->uc_mcontext.pc;
     uint32_t insn = *(uint32_t *)pc;
     bool is_write;
@@ -474,7 +474,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long ip;
     int is_write = 0;
 
@@ -505,7 +505,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long pc;
     uint16_t *pinsn;
     int is_write = 0;
@@ -558,7 +558,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t pc = uc->uc_mcontext.pc;
     int is_write;
 
#3 lore raw
In reply to Khem Raj
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

thanks
-- PMM

author
#2 lore raw
In reply to Laurent Vivier
Quoted 8 lines · Laurent Vivier
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

I didn't find in glib git tree the commit dropping the struct tags for ucontext. Could you point it out?

see https://sourceware.org/git/?p=glibc.git;a=commit;h=251287734e89a52da3db682a8241eb6bccc050c9

its also documented in (upcoming ) release notes

https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27struct_ucontext.27

Quoted 256 lines

Thanks,
Laurent

Quoted 252 lines
Cc Kamil Rytarowski <[email protected]>
Cc Riku Voipio <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 linux-user/host/aarch64/hostdep.h |  2 +-
 linux-user/host/arm/hostdep.h     |  2 +-
 linux-user/host/i386/hostdep.h    |  2 +-
 linux-user/host/ppc64/hostdep.h   |  2 +-
 linux-user/host/s390x/hostdep.h   |  2 +-
 linux-user/host/x86_64/hostdep.h  |  2 +-
 linux-user/signal.c               | 10 +++++-----
 tests/tcg/test-i386.c             |  4 ++--
 user-exec.c                       | 18 +++++++++---------
 9 files changed, 22 insertions(+), 22 deletions(-)
linux-user/host/aarch64/hostdep.h +1 -1
index 64f75cef49..a8d41a21ad 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     __u64 *pcreg = &uc->uc_mcontext.pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/arm/hostdep.h +1 -1
index 5c1ae60120..9276fe6ceb 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/i386/hostdep.h +1 -1
index d834bd80ea..073be74d87 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/ppc64/hostdep.h +1 -1
index 0b0f5f7821..98979ad917 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/s390x/hostdep.h +1 -1
index 6f9da9c608..4f0171f36f 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/host/x86_64/hostdep.h +1 -1
index 3b4259633e..a4fefb5114 100644
@@ -24,7 +24,7 @@ extern char safe_syscall_end[];
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
 
     if (*pcreg > (uintptr_t)safe_syscall_start
linux-user/signal.c +5 -5
index 3d18d1b3ee..2c55a4f600 100644
@@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     *
     *   a0 = signal number
     *   a1 = pointer to siginfo_t
-    *   a2 = pointer to struct ucontext
+    *   a2 = pointer to ucontext_t
     *
     * $25 and PC point to the signal handler, $29 points to the
     * struct sigframe.
@@ -3733,7 +3733,7 @@ struct target_signal_frame {
 
 struct rt_signal_frame {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint32_t tramp[2];
 };
 
@@ -3949,7 +3949,7 @@ struct rt_signal_frame {
     siginfo_t *pinfo;
     void *puc;
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint16_t retcode[4];      /* Trampoline code. */
 };
 
@@ -4484,7 +4484,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
         tswap_siginfo(&frame->info, info);
     }
 
-    /*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
+    /*err |= __clear_user(&frame->uc, offsetof(ucontext_t, uc_mcontext));*/
     __put_user(0, &frame->uc.tuc_flags);
     __put_user(0, &frame->uc.tuc_link);
     __put_user(target_sigaltstack_used.ss_sp,
@@ -4976,7 +4976,7 @@ enum {
 
 struct target_ucontext {
     target_ulong tuc_flags;
-    target_ulong tuc_link;    /* struct ucontext __user * */
+    target_ulong tuc_link;    /* ucontext_t __user * */
     struct target_sigaltstack tuc_stack;
 #if !defined(TARGET_PPC64)
     int32_t tuc_pad[7];
tests/tcg/test-i386.c +2 -2
index 0f7b943b0c..9599204895 100644
@@ -1720,7 +1720,7 @@ int tab[2];
 
 void sig_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 
     printf("si_signo=%d si_errno=%d si_code=%d",
            info->si_signo, info->si_errno, info->si_code);
@@ -1912,7 +1912,7 @@ void test_exceptions(void)
 /* specific precise single step test */
 void sig_trap_handler(int sig, siginfo_t *info, void *puc)
 {
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     printf("EIP=" FMTLX "\n", (long)uc->uc_mcontext.gregs[REG_EIP]);
 }
 
user-exec.c +9 -9
index a8f95fa1e1..2a975eaf69 100644
@@ -167,7 +167,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int trapno;
@@ -222,7 +222,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #elif defined(__OpenBSD__)
     struct sigcontext *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
 
     pc = PC_sig(uc);
@@ -289,7 +289,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -316,7 +316,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                            void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uint32_t *pc = uc->uc_mcontext.sc_pc;
     uint32_t insn = *pc;
     int is_write = 0;
@@ -414,7 +414,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 #if defined(__NetBSD__)
     ucontext_t *uc = puc;
 #else
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
 #endif
     unsigned long pc;
     int is_write;
@@ -441,7 +441,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     uintptr_t pc = uc->uc_mcontext.pc;
     uint32_t insn = *(uint32_t *)pc;
     bool is_write;
@@ -474,7 +474,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long ip;
     int is_write = 0;
 
@@ -505,7 +505,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     unsigned long pc;
     uint16_t *pinsn;
     int is_write = 0;
@@ -558,7 +558,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
-    struct ucontext *uc = puc;
+    ucontext_t *uc = puc;
     greg_t pc = uc->uc_mcontext.pc;
     int is_write;
 
#4 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

I'd support that notion. However, SUSv2 documents ucontext_t, not struct ucontext. Using the former instead of the latter makes sense as a portability improvement, doesn't it?

#6 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

The glib commit message indicates it is intentional change, in order to get POSIX compliance:

https://sourceware.org/git/?p=glibc.git;a=commit;h=251287734e89a52da3db682a8241eb6bccc050c9

NB, other parts of QEMU like the coroutine code are already using the 'ucontext_t' typedef, so attaining consistency across files is good regardless of the glibc change.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw
In reply to Markus Armbruster
Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

Quoted 7 lines
Quoted 2 lines

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

I'd support that notion. However, SUSv2 documents ucontext_t, not struct ucontext. Using the former instead of the latter makes sense as a portability improvement, doesn't it?

NetBSD ships with ucontext_t, no 'struct ucontext' available. Technically there is 'struct __ucontext', but nobody is allowed to use it sanely.

#9 lore raw
In reply to Khem Raj
Quoted 21 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

Cc Kamil Rytarowski <[email protected]>
Cc Riku Voipio <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 linux-user/host/aarch64/hostdep.h |  2 +-
 linux-user/host/arm/hostdep.h     |  2 +-
 linux-user/host/i386/hostdep.h    |  2 +-
 linux-user/host/ppc64/hostdep.h   |  2 +-
 linux-user/host/s390x/hostdep.h   |  2 +-
 linux-user/host/x86_64/hostdep.h  |  2 +-
 linux-user/signal.c               | 10 +++++-----
 tests/tcg/test-i386.c             |  4 ++--
 user-exec.c                       | 18 +++++++++---------
 9 files changed, 22 insertions(+), 22 deletions(-)

...

Quoted 23 lines
linux-user/signal.c +2 -2
index 3d18d1b3ee..2c55a4f600 100644
@@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     *
     *   a0 = signal number
     *   a1 = pointer to siginfo_t
-    *   a2 = pointer to struct ucontext
+    *   a2 = pointer to ucontext_t
     *
     * $25 and PC point to the signal handler, $29 points to the
     * struct sigframe.
@@ -3733,7 +3733,7 @@ struct target_signal_frame {
 
 struct rt_signal_frame {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint32_t tramp[2];
 };
 

linux-user/signal.c struct rt_signal_frame { · line 3955

Quoted 8 lines
linux-user/signal.c +1 -1
@@ -3949,7 +3949,7 @@ struct rt_signal_frame {
     siginfo_t *pinfo;
     void *puc;
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint16_t retcode[4];      /* Trampoline code. */
 };
 

I think these two rt_signal_frame are unused and can be removed.

Thanks,
Laurent

#11 lore raw
In reply to Khem Raj
This series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.

Hi,

This series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.

Subject: [Qemu-devel] [PATCH] replace struct ucontext with ucontext_t type
Message-id: [email protected]
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/patchew/[email protected]' which can not be resolved as commit? Traceback (most recent call last):
File "/home/fam/bin/patchew", line 440, in test_one

    git_clone_repo(clone, r["repo"], r["head"], logf)

File "/home/fam/bin/patchew", line 53, in git_clone_repo
cwd=clone)
File "/usr/lib64/python3.5/subprocess.py", line 271, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'checkout', 'origin/patchew/[email protected]', '-b', 'test']' returned non-zero exit status 128

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#12 lore raw
Quoted 36 lines · On Thu, 07/06 16:49, [email protected] wrote:

Hi,

This series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.

Subject: [Qemu-devel] [PATCH] replace struct ucontext with ucontext_t type
Message-id: [email protected]
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/patchew/[email protected]' which can not be resolved as commit? Traceback (most recent call last):
File "/home/fam/bin/patchew", line 440, in test_one

    git_clone_repo(clone, r["repo"], r["head"], logf)

File "/home/fam/bin/patchew", line 53, in git_clone_repo
cwd=clone)
File "/usr/lib64/python3.5/subprocess.py", line 271, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'checkout', 'origin/patchew/[email protected]', '-b', 'test']' returned non-zero exit status 128

Quoted 3 lines

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

Ignore this please, patchew is recovering from a bad state.

Reviewed-by
#7 lore raw
In reply to Daniel P. Berrange
Quoted 9 lines · Daniel P. Berrange
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

Quoted 8 lines

The glib commit message indicates it is intentional change, in order to get POSIX compliance:

https://sourceware.org/git/?p=glibc.git;a=commit;h=251287734e89a52da3db682a8241eb6bccc050c9

NB, other parts of QEMU like the coroutine code are already using the 'ucontext_t' typedef, so attaining consistency across files is good regardless of the glibc change.

I agree. And since the issue has been reposted, I support the fix, although Nathaniel's repost may have the better commit message.
https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06005.html

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#10 lore raw
In reply to Laurent Vivier
Quoted 23 lines · Laurent Vivier

...

Quoted 22 lines
linux-user/signal.c +2 -2
index 3d18d1b3ee..2c55a4f600 100644
@@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     *
     *   a0 = signal number
     *   a1 = pointer to siginfo_t
-    *   a2 = pointer to struct ucontext
+    *   a2 = pointer to ucontext_t
     *
     * $25 and PC point to the signal handler, $29 points to the
     * struct sigframe.
@@ -3733,7 +3733,7 @@ struct target_signal_frame {
 
 struct rt_signal_frame {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint32_t tramp[2];
 };
 
Quoted 11 lines

linux-user/signal.c struct rt_signal_frame { · line 3955

Quoted 9 lines
linux-user/signal.c +1 -1
@@ -3949,7 +3949,7 @@ struct rt_signal_frame {
     siginfo_t *pinfo;
     void *puc;
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
     uint16_t retcode[4];      /* Trampoline code. */
 };
 

I think these two rt_signal_frame are unused and can be removed.

Sounds like a separate patch, though.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#8 lore raw
In reply to Eric Blake
Quoted 19 lines · Eric Blake
Quoted 9 lines · Daniel P. Berrange
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Khem Raj

The ucontext_t type had a tag struct ucontext until now but newer glibc will drop it so we need to adjust and use the exposed type instead

If true this seems like a bug in glibc to break existing working programs, and it should be fixed there...

Quoted 8 lines

The glib commit message indicates it is intentional change, in order to get POSIX compliance:

https://sourceware.org/git/?p=glibc.git;a=commit;h=251287734e89a52da3db682a8241eb6bccc050c9

NB, other parts of QEMU like the coroutine code are already using the 'ucontext_t' typedef, so attaining consistency across files is good regardless of the glibc change.

Quoted 5 lines

I agree. And since the issue has been reposted, I support the fix, although Nathaniel's repost may have the better commit message.
https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06005.html

Thanks; applied to master with an upgraded commit message.

-- PMM