0001-Replace-struct-ucontext-with-ucontext_t-type.patch 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. From 04b33e21866412689f18b7ad6daf0a54d8f959a7 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 28 Jun 2017 13:44:52 -0700
  4. Subject: [PATCH] Replace 'struct ucontext' with 'ucontext_t' type
  5. glibc used to have:
  6. typedef struct ucontext { ... } ucontext_t;
  7. glibc now has:
  8. typedef struct ucontext_t { ... } ucontext_t;
  9. (See https://sourceware.org/bugzilla/show_bug.cgi?id=21457
  10. for detail and rationale for the glibc change)
  11. However, QEMU used "struct ucontext" in declarations. This is a
  12. private name and compatibility cannot be guaranteed. Switch to
  13. only using the standardized type name.
  14. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  15. Message-id: 20170628204452.41230-1-raj.khem@gmail.com
  16. Cc: Kamil Rytarowski <kamil@netbsd.org>
  17. Cc: Riku Voipio <riku.voipio@iki.fi>
  18. Cc: Laurent Vivier <laurent@vivier.eu>
  19. Cc: Paolo Bonzini <pbonzini@redhat.com>
  20. Reviewed-by: Eric Blake <eblake@redhat.com>
  21. [PMM: Rewrote commit message, based mostly on the one from
  22. Nathaniel McCallum]
  23. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  24. ---
  25. linux-user/host/aarch64/hostdep.h | 2 +-
  26. linux-user/host/arm/hostdep.h | 2 +-
  27. linux-user/host/i386/hostdep.h | 2 +-
  28. linux-user/host/ppc64/hostdep.h | 2 +-
  29. linux-user/host/s390x/hostdep.h | 2 +-
  30. linux-user/host/x86_64/hostdep.h | 2 +-
  31. linux-user/signal.c | 10 +++++-----
  32. tests/tcg/test-i386.c | 4 ++--
  33. user-exec.c | 18 +++++++++---------
  34. 9 files changed, 22 insertions(+), 22 deletions(-)
  35. diff --git a/linux-user/host/aarch64/hostdep.h b/linux-user/host/aarch64/hostdep.h
  36. index 64f75cef49..a8d41a21ad 100644
  37. --- a/linux-user/host/aarch64/hostdep.h
  38. +++ b/linux-user/host/aarch64/hostdep.h
  39. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  40. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  41. static inline void rewind_if_in_safe_syscall(void *puc)
  42. {
  43. - struct ucontext *uc = puc;
  44. + ucontext_t *uc = puc;
  45. __u64 *pcreg = &uc->uc_mcontext.pc;
  46. if (*pcreg > (uintptr_t)safe_syscall_start
  47. diff --git a/linux-user/host/arm/hostdep.h b/linux-user/host/arm/hostdep.h
  48. index 5c1ae60120..9276fe6ceb 100644
  49. --- a/linux-user/host/arm/hostdep.h
  50. +++ b/linux-user/host/arm/hostdep.h
  51. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  52. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  53. static inline void rewind_if_in_safe_syscall(void *puc)
  54. {
  55. - struct ucontext *uc = puc;
  56. + ucontext_t *uc = puc;
  57. unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
  58. if (*pcreg > (uintptr_t)safe_syscall_start
  59. diff --git a/linux-user/host/i386/hostdep.h b/linux-user/host/i386/hostdep.h
  60. index d834bd80ea..073be74d87 100644
  61. --- a/linux-user/host/i386/hostdep.h
  62. +++ b/linux-user/host/i386/hostdep.h
  63. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  64. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  65. static inline void rewind_if_in_safe_syscall(void *puc)
  66. {
  67. - struct ucontext *uc = puc;
  68. + ucontext_t *uc = puc;
  69. greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
  70. if (*pcreg > (uintptr_t)safe_syscall_start
  71. diff --git a/linux-user/host/ppc64/hostdep.h b/linux-user/host/ppc64/hostdep.h
  72. index 0b0f5f7821..98979ad917 100644
  73. --- a/linux-user/host/ppc64/hostdep.h
  74. +++ b/linux-user/host/ppc64/hostdep.h
  75. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  76. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  77. static inline void rewind_if_in_safe_syscall(void *puc)
  78. {
  79. - struct ucontext *uc = puc;
  80. + ucontext_t *uc = puc;
  81. unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
  82. if (*pcreg > (uintptr_t)safe_syscall_start
  83. diff --git a/linux-user/host/s390x/hostdep.h b/linux-user/host/s390x/hostdep.h
  84. index 6f9da9c608..4f0171f36f 100644
  85. --- a/linux-user/host/s390x/hostdep.h
  86. +++ b/linux-user/host/s390x/hostdep.h
  87. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  88. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  89. static inline void rewind_if_in_safe_syscall(void *puc)
  90. {
  91. - struct ucontext *uc = puc;
  92. + ucontext_t *uc = puc;
  93. unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
  94. if (*pcreg > (uintptr_t)safe_syscall_start
  95. diff --git a/linux-user/host/x86_64/hostdep.h b/linux-user/host/x86_64/hostdep.h
  96. index 3b4259633e..a4fefb5114 100644
  97. --- a/linux-user/host/x86_64/hostdep.h
  98. +++ b/linux-user/host/x86_64/hostdep.h
  99. @@ -24,7 +24,7 @@ extern char safe_syscall_end[];
  100. /* Adjust the signal context to rewind out of safe-syscall if we're in it */
  101. static inline void rewind_if_in_safe_syscall(void *puc)
  102. {
  103. - struct ucontext *uc = puc;
  104. + ucontext_t *uc = puc;
  105. greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
  106. if (*pcreg > (uintptr_t)safe_syscall_start
  107. diff --git a/linux-user/signal.c b/linux-user/signal.c
  108. index d68bd26013..cc0c3fcee9 100644
  109. --- a/linux-user/signal.c
  110. +++ b/linux-user/signal.c
  111. @@ -3346,7 +3346,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
  112. *
  113. * a0 = signal number
  114. * a1 = pointer to siginfo_t
  115. - * a2 = pointer to struct ucontext
  116. + * a2 = pointer to ucontext_t
  117. *
  118. * $25 and PC point to the signal handler, $29 points to the
  119. * struct sigframe.
  120. @@ -3764,7 +3764,7 @@ struct target_signal_frame {
  121. struct rt_signal_frame {
  122. siginfo_t info;
  123. - struct ucontext uc;
  124. + ucontext_t uc;
  125. uint32_t tramp[2];
  126. };
  127. @@ -3980,7 +3980,7 @@ struct rt_signal_frame {
  128. siginfo_t *pinfo;
  129. void *puc;
  130. siginfo_t info;
  131. - struct ucontext uc;
  132. + ucontext_t uc;
  133. uint16_t retcode[4]; /* Trampoline code. */
  134. };
  135. @@ -4515,7 +4515,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
  136. tswap_siginfo(&frame->info, info);
  137. }
  138. - /*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
  139. + /*err |= __clear_user(&frame->uc, offsetof(ucontext_t, uc_mcontext));*/
  140. __put_user(0, &frame->uc.tuc_flags);
  141. __put_user(0, &frame->uc.tuc_link);
  142. __put_user(target_sigaltstack_used.ss_sp,
  143. @@ -5007,7 +5007,7 @@ enum {
  144. struct target_ucontext {
  145. target_ulong tuc_flags;
  146. - target_ulong tuc_link; /* struct ucontext __user * */
  147. + target_ulong tuc_link; /* ucontext_t __user * */
  148. struct target_sigaltstack tuc_stack;
  149. #if !defined(TARGET_PPC64)
  150. int32_t tuc_pad[7];
  151. diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
  152. index 0f7b943b0c..9599204895 100644
  153. --- a/tests/tcg/test-i386.c
  154. +++ b/tests/tcg/test-i386.c
  155. @@ -1720,7 +1720,7 @@ int tab[2];
  156. void sig_handler(int sig, siginfo_t *info, void *puc)
  157. {
  158. - struct ucontext *uc = puc;
  159. + ucontext_t *uc = puc;
  160. printf("si_signo=%d si_errno=%d si_code=%d",
  161. info->si_signo, info->si_errno, info->si_code);
  162. @@ -1912,7 +1912,7 @@ void test_exceptions(void)
  163. /* specific precise single step test */
  164. void sig_trap_handler(int sig, siginfo_t *info, void *puc)
  165. {
  166. - struct ucontext *uc = puc;
  167. + ucontext_t *uc = puc;
  168. printf("EIP=" FMTLX "\n", (long)uc->uc_mcontext.gregs[REG_EIP]);
  169. }
  170. diff --git a/user-exec.c b/user-exec.c
  171. index a8f95fa1e1..2a975eaf69 100644
  172. --- a/user-exec.c
  173. +++ b/user-exec.c
  174. @@ -167,7 +167,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  175. #elif defined(__OpenBSD__)
  176. struct sigcontext *uc = puc;
  177. #else
  178. - struct ucontext *uc = puc;
  179. + ucontext_t *uc = puc;
  180. #endif
  181. unsigned long pc;
  182. int trapno;
  183. @@ -222,7 +222,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  184. #elif defined(__OpenBSD__)
  185. struct sigcontext *uc = puc;
  186. #else
  187. - struct ucontext *uc = puc;
  188. + ucontext_t *uc = puc;
  189. #endif
  190. pc = PC_sig(uc);
  191. @@ -289,7 +289,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  192. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  193. ucontext_t *uc = puc;
  194. #else
  195. - struct ucontext *uc = puc;
  196. + ucontext_t *uc = puc;
  197. #endif
  198. unsigned long pc;
  199. int is_write;
  200. @@ -316,7 +316,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  201. void *puc)
  202. {
  203. siginfo_t *info = pinfo;
  204. - struct ucontext *uc = puc;
  205. + ucontext_t *uc = puc;
  206. uint32_t *pc = uc->uc_mcontext.sc_pc;
  207. uint32_t insn = *pc;
  208. int is_write = 0;
  209. @@ -414,7 +414,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  210. #if defined(__NetBSD__)
  211. ucontext_t *uc = puc;
  212. #else
  213. - struct ucontext *uc = puc;
  214. + ucontext_t *uc = puc;
  215. #endif
  216. unsigned long pc;
  217. int is_write;
  218. @@ -441,7 +441,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  219. int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
  220. {
  221. siginfo_t *info = pinfo;
  222. - struct ucontext *uc = puc;
  223. + ucontext_t *uc = puc;
  224. uintptr_t pc = uc->uc_mcontext.pc;
  225. uint32_t insn = *(uint32_t *)pc;
  226. bool is_write;
  227. @@ -474,7 +474,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
  228. int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
  229. {
  230. siginfo_t *info = pinfo;
  231. - struct ucontext *uc = puc;
  232. + ucontext_t *uc = puc;
  233. unsigned long ip;
  234. int is_write = 0;
  235. @@ -505,7 +505,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  236. void *puc)
  237. {
  238. siginfo_t *info = pinfo;
  239. - struct ucontext *uc = puc;
  240. + ucontext_t *uc = puc;
  241. unsigned long pc;
  242. uint16_t *pinsn;
  243. int is_write = 0;
  244. @@ -558,7 +558,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
  245. void *puc)
  246. {
  247. siginfo_t *info = pinfo;
  248. - struct ucontext *uc = puc;
  249. + ucontext_t *uc = puc;
  250. greg_t pc = uc->uc_mcontext.pc;
  251. int is_write;
  252. --
  253. 2.14.2