[CRIU] [PATCH 16/22] restore: add a function for constructing sigframe

Andrey Vagin avagin at openvz.org
Wed May 8 09:28:43 EDT 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 Makefile.crtools |  1 +
 sigframe.c       | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 sigframe.c

diff --git a/Makefile.crtools b/Makefile.crtools
index aa34611..a861dfd 100644
--- a/Makefile.crtools
+++ b/Makefile.crtools
@@ -46,6 +46,7 @@ obj-y	+= page-pipe.o
 obj-y	+= page-xfer.o
 obj-y	+= page-read.o
 obj-y	+= kerndat.o
+obj-y	+= sigframe.o
 
 ifneq ($(MAKECMDGOALS),clean)
 incdeps := y
diff --git a/sigframe.c b/sigframe.c
new file mode 100644
index 0000000..b511bf1
--- /dev/null
+++ b/sigframe.c
@@ -0,0 +1,33 @@
+#include <unistd.h>
+
+#include "restorer.h"
+#include "asm/restore.h"
+#include "asm/restorer.h"
+
+#include "protobuf/core.pb-c.h"
+
+static inline int construct_sigframe(struct rt_sigframe *sigframe,
+				     struct rt_sigframe *rsigframe,
+				     CoreEntry *core)
+{
+	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));
+	else if (core->thread_core->has_blk_sigset) {
+		memcpy(blk_sigset,
+			&core->thread_core->blk_sigset, sizeof(k_rtsigset_t));
+	} else
+		memset(blk_sigset, 0, sizeof(k_rtsigset_t));
+
+	if (sigreturn_prep_fpu_frame(&sigframe->fpu_state, core))
+		return -1;
+
+	if (restore_fpu(sigframe, &rsigframe->fpu_state))
+		return -1;
+
+	if (restore_gpregs(sigframe, CORE_THREAD_ARCH_INFO(core)->gpregs))
+		return -1;
+
+	return 0;
+}
-- 
1.8.2



More information about the CRIU mailing list