[CRIU] [PATCH 1/2] asm: move ksigfillset to non-arch header

Andrei Vagin avagin at openvz.org
Fri Sep 16 02:18:38 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

ksigfillset is the same for all architectures and
here is no reasons to duplicate the same code many times.

In addition, this patch addes ksigemptyset and ksigaddset.
They will be used in the next patch.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/arch/aarch64/include/asm/types.h |  7 -------
 criu/arch/arm/include/asm/types.h     |  7 -------
 criu/arch/ppc64/include/asm/types.h   |  7 -------
 criu/arch/x86/include/asm/types.h     |  7 -------
 criu/include/signal.h                 | 24 ++++++++++++++++++++++++
 criu/parasite-syscall.c               |  1 +
 criu/pie/restorer.c                   |  1 +
 7 files changed, 26 insertions(+), 28 deletions(-)
 create mode 100644 criu/include/signal.h

diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 51c0a31..078a8f2 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -29,13 +29,6 @@ typedef struct {
 	unsigned long sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
-static inline void ksigfillset(k_rtsigset_t *set)
-{
-	int i;
-	for (i = 0; i < _KNSIG_WORDS; i++)
-		set->sig[i] = (unsigned long)-1;
-}
-
 #define SA_RESTORER	0x00000000
 
 typedef struct {
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 90beb96..aafc4bb 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -30,13 +30,6 @@ typedef struct {
 	unsigned long sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
-static inline void ksigfillset(k_rtsigset_t *set)
-{
-	int i;
-	for (i = 0; i < _KNSIG_WORDS; i++)
-		set->sig[i] = (unsigned long)-1;
-}
-
 #define SA_RESTORER	0x04000000
 
 typedef struct {
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index 8b34681..82a09e0 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -30,13 +30,6 @@ typedef struct {
         uint64_t sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
-static inline void ksigfillset(k_rtsigset_t *set)
-{
-        int i;
-        for (i = 0; i < _KNSIG_WORDS; i++)
-                set->sig[i] = (unsigned long)-1;
-}
-
 /* Copied from the Linux kernel arch/powerpc/include/uapi/asm/signal.h */
 #define SA_RESTORER     0x04000000U
 
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index 3bb02f3..7b38c50 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -32,13 +32,6 @@ typedef struct {
 	u64 sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
-static inline void ksigfillset(k_rtsigset_t *set)
-{
-	int i;
-	for (i = 0; i < _KNSIG_WORDS; i++)
-		set->sig[i] = (unsigned long)-1;
-}
-
 #define SA_RESTORER	0x04000000
 
 typedef struct {
diff --git a/criu/include/signal.h b/criu/include/signal.h
new file mode 100644
index 0000000..6180658
--- /dev/null
+++ b/criu/include/signal.h
@@ -0,0 +1,24 @@
+#ifndef __CR_SIGNAL_H__
+#define __CR_SIGNAL_H__
+#include "asm/types.h"
+
+static inline void ksigfillset(k_rtsigset_t *set)
+{
+	int i;
+	for (i = 0; i < _KNSIG_WORDS; i++)
+		set->sig[i] = (unsigned long)-1;
+}
+
+static inline void ksigemptyset(k_rtsigset_t *set)
+{
+	int i;
+	for (i = 0; i < _KNSIG_WORDS; i++)
+		set->sig[i] = 0;
+}
+
+static inline void ksigaddset(k_rtsigset_t *set, int _sig)
+{
+	int sig = _sig - 1;
+	set->sig[sig / _NSIG_BPW] = 1 << (sig % _NSIG_BPW);
+}
+#endif
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index fb1c245..ad33098 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -30,6 +30,7 @@
 #include "aio.h"
 #include "fault-injection.h"
 #include "syscall-codes.h"
+#include "signal.h"
 
 #include <string.h>
 #include <stdlib.h>
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index d84d316..4a96c7e 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -23,6 +23,7 @@
 #include "asm/string.h"
 #include "asm/types.h"
 #include "syscall.h"
+#include "signal.h"
 #include "config.h"
 #include "prctl.h"
 #include "log.h"
-- 
2.7.4



More information about the CRIU mailing list