[CRIU] [PATCH] sigframe: move setup_sas & make it inliner

Dmitry Safonov dsafonov at virtuozzo.com
Thu Mar 17 12:13:09 PDT 2016


Impact: No functional changes, cleanup

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/arch/aarch64/include/asm/restorer.h |  2 +-
 criu/arch/arm/include/asm/restorer.h     |  2 +-
 criu/arch/ppc64/include/asm/restorer.h   |  2 +-
 criu/arch/x86/include/asm/restorer.h     |  2 +-
 criu/include/sigframe.h                  | 14 --------------
 criu/sigframe.c                          | 13 ++++++++++++-
 6 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/criu/arch/aarch64/include/asm/restorer.h b/criu/arch/aarch64/include/asm/restorer.h
index 66abe85..b96f83b 100644
--- a/criu/arch/aarch64/include/asm/restorer.h
+++ b/criu/arch/aarch64/include/asm/restorer.h
@@ -90,7 +90,7 @@ struct rt_sigframe {
 			: "sp", "x0", "memory")
 
 
-#define RT_SIGFRAME_UC(rt_sigframe) rt_sigframe->uc
+#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc)
 #define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.pc)
 #define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
 #define RT_SIGFRAME_FPU(rt_sigframe) ((struct aux_context*)&(rt_sigframe)->uc.uc_mcontext.__reserved)->fpsimd
diff --git a/criu/arch/arm/include/asm/restorer.h b/criu/arch/arm/include/asm/restorer.h
index d5c6ed8..af7ce20 100644
--- a/criu/arch/arm/include/asm/restorer.h
+++ b/criu/arch/arm/include/asm/restorer.h
@@ -123,7 +123,7 @@ struct rt_sigframe {
 		     : "memory")
 
 
-#define RT_SIGFRAME_UC(rt_sigframe) rt_sigframe->sig.uc
+#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->sig.uc)
 #define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->sig.uc.uc_mcontext.arm_ip
 #define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1
 #define RT_SIGFRAME_FPU(rt_sigframe) ((struct aux_sigframe *)&sigframe->sig.uc.uc_regspace)->vfp
diff --git a/criu/arch/ppc64/include/asm/restorer.h b/criu/arch/ppc64/include/asm/restorer.h
index e728f13..f6b9291 100644
--- a/criu/arch/ppc64/include/asm/restorer.h
+++ b/criu/arch/ppc64/include/asm/restorer.h
@@ -101,7 +101,7 @@ struct rt_sigframe {
 		  "r"(&thread_args[i])		/* %6 */		\
 		: "memory","0","3","4","5","6","7","14","15")
 
-#define RT_SIGFRAME_UC(rt_sigframe) rt_sigframe->uc
+#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc)
 #define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.gp_regs[PT_NIP])
 #define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
 #define RT_SIGFRAME_FPU(rt_sigframe) ((rt_sigframe)->uc.uc_mcontext)
diff --git a/criu/arch/x86/include/asm/restorer.h b/criu/arch/x86/include/asm/restorer.h
index 16a45d7..bf9ff59 100644
--- a/criu/arch/x86/include/asm/restorer.h
+++ b/criu/arch/x86/include/asm/restorer.h
@@ -159,7 +159,7 @@ struct rt_sigframe {
 		     : "memory")
 #endif /* CONFIG_X86_64 */
 
-#define RT_SIGFRAME_UC(rt_sigframe) rt_sigframe->uc
+#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc)
 #define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.rip
 #define RT_SIGFRAME_HAS_FPU(rt_sigframe) (rt_sigframe)->fpu_state.has_fpu
 #define RT_SIGFRAME_FPU(rt_sigframe) (rt_sigframe)->fpu_state
diff --git a/criu/include/sigframe.h b/criu/include/sigframe.h
index ed79869..2b1a102 100644
--- a/criu/include/sigframe.h
+++ b/criu/include/sigframe.h
@@ -49,18 +49,4 @@ extern int construct_sigframe(struct rt_sigframe *sigframe,
 			      struct rt_sigframe *rsigframe,
 			      CoreEntry *core);
 
-/*
- * FIXME Convert it to inline helper, which requires
- *	 to unweave types mess we've generated for
- *	 run-time data.
- */
-#define setup_sas(sigframe, sas)											\
-do {															\
-	if ((sas)) {													\
-		RT_SIGFRAME_UC((sigframe)).uc_stack.ss_sp	= (void *)decode_pointer((sas)->ss_sp);			\
-		RT_SIGFRAME_UC((sigframe)).uc_stack.ss_flags	= (int)(sas)->ss_flags;					\
-		RT_SIGFRAME_UC((sigframe)).uc_stack.ss_size	= (size_t)(sas)->ss_size;				\
-	}														\
-} while (0)
-
 #endif /* __CR_SIGFRAME_H__ */
diff --git a/criu/sigframe.c b/criu/sigframe.c
index fb1efdc..a99fb0b 100644
--- a/criu/sigframe.c
+++ b/criu/sigframe.c
@@ -6,11 +6,22 @@
 
 #include "images/core.pb-c.h"
 
+static inline void setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas)
+{
+	if (sas) {
+		struct rt_ucontext *uc	= RT_SIGFRAME_UC(sigframe);
+
+		uc->uc_stack.ss_sp	= (void *)decode_pointer((sas)->ss_sp);
+		uc->uc_stack.ss_flags	= (int)(sas)->ss_flags;
+		uc->uc_stack.ss_size	= (size_t)(sas)->ss_size;
+	}
+}
+
 int construct_sigframe(struct rt_sigframe *sigframe,
 				     struct rt_sigframe *rsigframe,
 				     CoreEntry *core)
 {
-	k_rtsigset_t *blk_sigset = (k_rtsigset_t*)&RT_SIGFRAME_UC(sigframe).uc_sigmask;
+	k_rtsigset_t *blk_sigset = &RT_SIGFRAME_UC(sigframe)->uc_sigmask;
 
 	if (core->tc)
 		memcpy(blk_sigset, &core->tc->blk_sigset, sizeof(k_rtsigset_t));
-- 
2.7.2



More information about the CRIU mailing list