[CRIU] [PATCH 16/22] compel: Move bit helpers from criu into compel

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 19 12:21:31 PDT 2016


They gonna be shared between compel and criu so
we export the headers as part of uapi.

Pavel complains that some share types and helpers
should live in some side library but I think we better
should move everything related to arch part into
compel first then if we sill think they are should
be shared on source code level we can easily grep
for UAPI_ prefix over compel code and extract things
needed instead of doing mess right now.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/Makefile                                              | 12 ++++++++++++
 compel/arch/aarch64/src/lib/include/compel/asm/bitops.h      |  6 ++++++
 compel/arch/aarch64/src/lib/include/compel/asm/bitsperlong.h |  6 ++++++
 compel/arch/arm/src/lib/include/compel/asm/bitops.h          |  6 ++++++
 compel/arch/arm/src/lib/include/compel/asm/bitsperlong.h     |  6 ++++++
 .../arch/ppc64/src/lib/include/compel}/asm/bitops.h          | 10 ++++------
 compel/arch/ppc64/src/lib/include/compel/asm/bitsperlong.h   |  6 ++++++
 .../arch/x86/src/lib/include/compel}/asm/bitops.h            |  8 ++++----
 compel/arch/x86/src/lib/include/compel/asm/bitsperlong.h     | 10 ++++++++++
 .../include/uapi/compel}/asm-generic/bitops.h                |  8 ++++----
 criu/arch/aarch64/include/asm/bitops.h                       |  7 -------
 criu/arch/aarch64/include/asm/bitsperlong.h                  |  6 ------
 criu/arch/aarch64/include/asm/types.h                        |  2 +-
 criu/arch/arm/include/asm/bitops.h                           |  7 -------
 criu/arch/arm/include/asm/bitsperlong.h                      |  6 ------
 criu/arch/arm/include/asm/types.h                            |  2 +-
 criu/arch/ppc64/include/asm/bitsperlong.h                    |  6 ------
 criu/arch/ppc64/include/asm/types.h                          |  2 +-
 criu/arch/x86/cpu.c                                          |  3 ++-
 criu/arch/x86/include/asm/bitsperlong.h                      | 10 ----------
 criu/arch/x86/include/asm/types.h                            |  2 +-
 criu/bitmap.c                                                |  2 +-
 criu/cr-restore.c                                            |  2 +-
 criu/pie/log-simple.c                                        |  3 +--
 criu/shmem.c                                                 |  2 +-
 25 files changed, 74 insertions(+), 66 deletions(-)
 create mode 100644 compel/arch/aarch64/src/lib/include/compel/asm/bitops.h
 create mode 100644 compel/arch/aarch64/src/lib/include/compel/asm/bitsperlong.h
 create mode 100644 compel/arch/arm/src/lib/include/compel/asm/bitops.h
 create mode 100644 compel/arch/arm/src/lib/include/compel/asm/bitsperlong.h
 rename {criu/arch/ppc64/include => compel/arch/ppc64/src/lib/include/compel}/asm/bitops.h (97%)
 create mode 100644 compel/arch/ppc64/src/lib/include/compel/asm/bitsperlong.h
 rename {criu/arch/x86/include => compel/arch/x86/src/lib/include/compel}/asm/bitops.h (94%)
 create mode 100644 compel/arch/x86/src/lib/include/compel/asm/bitsperlong.h
 rename {criu/include => compel/include/uapi/compel}/asm-generic/bitops.h (94%)
 delete mode 100644 criu/arch/aarch64/include/asm/bitops.h
 delete mode 100644 criu/arch/aarch64/include/asm/bitsperlong.h
 delete mode 100644 criu/arch/arm/include/asm/bitops.h
 delete mode 100644 criu/arch/arm/include/asm/bitsperlong.h
 delete mode 100644 criu/arch/ppc64/include/asm/bitsperlong.h
 delete mode 100644 criu/arch/x86/include/asm/bitsperlong.h

diff --git a/compel/Makefile b/compel/Makefile
index 2eb86ce90c89..a0aa0b5b47aa 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -29,6 +29,18 @@ lib-y			+= src/lib/compel.o
 #
 # This requires arch specific header to
 # be generated into uapi
+$(obj)/include/uapi/compel/asm/bitops.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/bitops.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+cleanup-y		+= $(obj)/include/uapi/compel/asm/bitops.h
+headers-y		+= $(obj)/include/uapi/compel/asm/bitops.h
+
+$(obj)/include/uapi/compel/asm/bitsperlong.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/bitsperlong.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+cleanup-y		+= $(obj)/include/uapi/compel/asm/bitsperlong.h
+headers-y		+= $(obj)/include/uapi/compel/asm/bitsperlong.h
+
 $(obj)/include/uapi/compel/asm/page.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/page.h
 	$(call msg-gen, $@)
 	$(Q) cp $^ $@
diff --git a/compel/arch/aarch64/src/lib/include/compel/asm/bitops.h b/compel/arch/aarch64/src/lib/include/compel/asm/bitops.h
new file mode 100644
index 000000000000..bdb9bdc449b0
--- /dev/null
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/bitops.h
@@ -0,0 +1,6 @@
+#ifndef UAPI_COMPEL_ASM_BITOPS_H__
+#define UAPI_COMPEL_ASM_BITOPS_H__
+
+#include <compel/asm-generic/bitops.h>
+
+#endif /* UAPI_COMPEL_ASM_BITOPS_H__ */
diff --git a/compel/arch/aarch64/src/lib/include/compel/asm/bitsperlong.h b/compel/arch/aarch64/src/lib/include/compel/asm/bitsperlong.h
new file mode 100644
index 000000000000..f6e85530e484
--- /dev/null
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/bitsperlong.h
@@ -0,0 +1,6 @@
+#ifndef UAPI_COMPEL_ASM_BITSPERLONG_H__
+#define UAPI_COMPEL_ASM_BITSPERLONG_H__
+
+#define BITS_PER_LONG 64
+
+#endif /* UAPI_COMPEL_ASM_BITSPERLONG_H__ */
diff --git a/compel/arch/arm/src/lib/include/compel/asm/bitops.h b/compel/arch/arm/src/lib/include/compel/asm/bitops.h
new file mode 100644
index 000000000000..bdb9bdc449b0
--- /dev/null
+++ b/compel/arch/arm/src/lib/include/compel/asm/bitops.h
@@ -0,0 +1,6 @@
+#ifndef UAPI_COMPEL_ASM_BITOPS_H__
+#define UAPI_COMPEL_ASM_BITOPS_H__
+
+#include <compel/asm-generic/bitops.h>
+
+#endif /* UAPI_COMPEL_ASM_BITOPS_H__ */
diff --git a/compel/arch/arm/src/lib/include/compel/asm/bitsperlong.h b/compel/arch/arm/src/lib/include/compel/asm/bitsperlong.h
new file mode 100644
index 000000000000..5ec5aa3df301
--- /dev/null
+++ b/compel/arch/arm/src/lib/include/compel/asm/bitsperlong.h
@@ -0,0 +1,6 @@
+#ifndef UAPI_COMPEL_ASM_BITSPERLONG_H__
+#define UAPI_COMPEL_ASM_BITSPERLONG_H__
+
+#define BITS_PER_LONG 32
+
+#endif /* UAPI_COMPEL_ASM_BITSPERLONG_H__ */
diff --git a/criu/arch/ppc64/include/asm/bitops.h b/compel/arch/ppc64/src/lib/include/compel/asm/bitops.h
similarity index 97%
rename from criu/arch/ppc64/include/asm/bitops.h
rename to compel/arch/ppc64/src/lib/include/compel/asm/bitops.h
index 910971981ca9..e7a64d30dc0c 100644
--- a/criu/arch/ppc64/include/asm/bitops.h
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/bitops.h
@@ -1,5 +1,5 @@
-#ifndef __CR_BITOPS_H__
-#define __CR_BITOPS_H__
+#ifndef UAPI_COMPEL_ASM_BITOPS_H__
+#define UAPI_COMPEL_ASM_BITOPS_H__
 /*
  * PowerPC atomic bit operations.
  *
@@ -38,9 +38,7 @@
  * Copied from the kernel file arch/powerpc/include/asm/bitops.h
  */
 
-#include "compiler.h"
-
-#include "asm/bitsperlong.h"
+#include <compel/asm/bitsperlong.h>
 
 #define DIV_ROUND_UP(n,d)       (((n) + (d) - 1) / (d))
 #define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_LONG)
@@ -171,4 +169,4 @@ found_middle:
              i = find_next_bit(bitmask, sizeof(bitmask), i + 1))
 
 
-#endif /* __CR_BITOPS_H__ */
+#endif /* UAPI_COMPEL_ASM_BITOPS_H__ */
diff --git a/compel/arch/ppc64/src/lib/include/compel/asm/bitsperlong.h b/compel/arch/ppc64/src/lib/include/compel/asm/bitsperlong.h
new file mode 100644
index 000000000000..f6e85530e484
--- /dev/null
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/bitsperlong.h
@@ -0,0 +1,6 @@
+#ifndef UAPI_COMPEL_ASM_BITSPERLONG_H__
+#define UAPI_COMPEL_ASM_BITSPERLONG_H__
+
+#define BITS_PER_LONG 64
+
+#endif /* UAPI_COMPEL_ASM_BITSPERLONG_H__ */
diff --git a/criu/arch/x86/include/asm/bitops.h b/compel/arch/x86/src/lib/include/compel/asm/bitops.h
similarity index 94%
rename from criu/arch/x86/include/asm/bitops.h
rename to compel/arch/x86/src/lib/include/compel/asm/bitops.h
index 7d6283183953..79721326788e 100644
--- a/criu/arch/x86/include/asm/bitops.h
+++ b/compel/arch/x86/src/lib/include/compel/asm/bitops.h
@@ -1,7 +1,7 @@
-#ifndef __CR_BITOPS_H__
-#define __CR_BITOPS_H__
+#ifndef UAPI_COMPEL_ASM_BITOPS_H__
+#define UAPI_COMPEL_ASM_BITOPS_H__
 
-#include "asm/bitsperlong.h"
+#include <compel/asm/bitsperlong.h>
 
 #define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
 #define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_LONG)
@@ -110,4 +110,4 @@ found_middle:
 	     i < sizeof(bitmask);				\
 	     i = find_next_bit(bitmask, sizeof(bitmask), i + 1))
 
-#endif /* __CR_BITOPS_H__ */
+#endif /* UAPI_COMPEL_ASM_BITOPS_H__ */
diff --git a/compel/arch/x86/src/lib/include/compel/asm/bitsperlong.h b/compel/arch/x86/src/lib/include/compel/asm/bitsperlong.h
new file mode 100644
index 000000000000..be08540ff0ab
--- /dev/null
+++ b/compel/arch/x86/src/lib/include/compel/asm/bitsperlong.h
@@ -0,0 +1,10 @@
+#ifndef UAPI_COMPEL_ASM_BITSPERLONG_H__
+#define UAPI_COMPEL_ASM_BITSPERLONG_H__
+
+#ifdef CONFIG_X86_64
+# define BITS_PER_LONG 64
+#else
+# define BITS_PER_LONG 32
+#endif
+
+#endif /* UAPI_COMPEL_ASM_BITSPERLONG_H__ */
diff --git a/criu/include/asm-generic/bitops.h b/compel/include/uapi/compel/asm-generic/bitops.h
similarity index 94%
rename from criu/include/asm-generic/bitops.h
rename to compel/include/uapi/compel/asm-generic/bitops.h
index 190e1ab638c0..015e4928ccc3 100644
--- a/criu/include/asm-generic/bitops.h
+++ b/compel/include/uapi/compel/asm-generic/bitops.h
@@ -5,10 +5,10 @@
  * should include this file into the arch/$ARCH/include/asm/bitops.h
  */
 
-#ifndef __CR_GENERIC_BITOPS_H__
-#define __CR_GENERIC_BITOPS_H__
+#ifndef UAPI_COMPEL_GENERIC_BITOPS_H__
+#define UAPI_COMPEL_GENERIC_BITOPS_H__
 
-#include "asm/bitsperlong.h"
+#include <compel/asm/bitsperlong.h>
 
 #define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
 #define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_LONG)
@@ -120,4 +120,4 @@ found_middle:
 	     i < sizeof(bitmask);				\
 	     i = find_next_bit(bitmask, sizeof(bitmask), i + 1))
 
-#endif /* __CR_GENERIC_BITOPS_H__ */
+#endif /* UAPI_COMPEL_GENERIC_BITOPS_H__ */
diff --git a/criu/arch/aarch64/include/asm/bitops.h b/criu/arch/aarch64/include/asm/bitops.h
deleted file mode 100644
index 5a750447f25f..000000000000
--- a/criu/arch/aarch64/include/asm/bitops.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __CR_ASM_BITOPS_H__
-#define __CR_ASM_BITOPS_H__
-
-#include "compiler.h"
-#include "asm-generic/bitops.h"
-
-#endif /* __CR_ASM_BITOPS_H__ */
diff --git a/criu/arch/aarch64/include/asm/bitsperlong.h b/criu/arch/aarch64/include/asm/bitsperlong.h
deleted file mode 100644
index d95727d193e8..000000000000
--- a/criu/arch/aarch64/include/asm/bitsperlong.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CR_BITSPERLONG_H__
-#define __CR_BITSPERLONG_H__
-
-#define BITS_PER_LONG 64
-
-#endif /* __CR_BITSPERLONG_H__ */
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index c1020a5eefa5..ee08bcc53829 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -7,10 +7,10 @@
 
 #include <compel/plugins/std/asm/syscall-types.h>
 #include <compel/asm/types.h>
+#include <compel/asm/bitops.h>
 
 #include "images/core.pb-c.h"
 
-#include "asm/bitops.h"
 #include "asm/int.h"
 
 #define core_is_compat(core)			false
diff --git a/criu/arch/arm/include/asm/bitops.h b/criu/arch/arm/include/asm/bitops.h
deleted file mode 100644
index 5a750447f25f..000000000000
--- a/criu/arch/arm/include/asm/bitops.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __CR_ASM_BITOPS_H__
-#define __CR_ASM_BITOPS_H__
-
-#include "compiler.h"
-#include "asm-generic/bitops.h"
-
-#endif /* __CR_ASM_BITOPS_H__ */
diff --git a/criu/arch/arm/include/asm/bitsperlong.h b/criu/arch/arm/include/asm/bitsperlong.h
deleted file mode 100644
index 43858b765320..000000000000
--- a/criu/arch/arm/include/asm/bitsperlong.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CR_BITSPERLONG_H__
-#define __CR_BITSPERLONG_H__
-
-#define BITS_PER_LONG 32
-
-#endif /* __CR_BITSPERLONG_H__ */
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 77c081dc4f60..784e4268d754 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -7,10 +7,10 @@
 #include <compel/plugins/std/asm/syscall-types.h>
 #include <compel/asm/types.h>
 #include <compel/asm/page.h>
+#include <compel/asm/bitops.h>
 
 #include "images/core.pb-c.h"
 
-#include "asm/bitops.h"
 #include "asm/int.h"
 
 #define core_is_compat(core)			false
diff --git a/criu/arch/ppc64/include/asm/bitsperlong.h b/criu/arch/ppc64/include/asm/bitsperlong.h
deleted file mode 100644
index d95727d193e8..000000000000
--- a/criu/arch/ppc64/include/asm/bitsperlong.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CR_BITSPERLONG_H__
-#define __CR_BITSPERLONG_H__
-
-#define BITS_PER_LONG 64
-
-#endif /* __CR_BITSPERLONG_H__ */
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index f74af930470e..cc7ba201b2f9 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -5,12 +5,12 @@
 #include <signal.h>
 #include "images/core.pb-c.h"
 
-#include "asm/bitops.h"
 #include "asm/int.h"
 
 #include <compel/plugins/std/asm/syscall-types.h>
 #include <compel/asm/types.h>
 #include <compel/asm/page.h>
+#include <compel/asm/bitops.h>
 
 typedef UserPpc64RegsEntry UserRegsEntry;
 
diff --git a/criu/arch/x86/cpu.c b/criu/arch/x86/cpu.c
index 97d76f20527c..df77f30c9505 100644
--- a/criu/arch/x86/cpu.c
+++ b/criu/arch/x86/cpu.c
@@ -6,7 +6,8 @@
 
 #include <sys/types.h>
 
-#include "asm/bitops.h"
+#include <compel/asm/bitops.h>
+
 #include "asm/types.h"
 #include "asm/cpu.h"
 
diff --git a/criu/arch/x86/include/asm/bitsperlong.h b/criu/arch/x86/include/asm/bitsperlong.h
deleted file mode 100644
index 7e0a71e8d71d..000000000000
--- a/criu/arch/x86/include/asm/bitsperlong.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __CR_BITSPERLONG_H__
-#define __CR_BITSPERLONG_H__
-
-#ifdef CONFIG_X86_64
-# define BITS_PER_LONG 64
-#else
-# define BITS_PER_LONG 32
-#endif
-
-#endif /* __CR_BITSPERLONG_H__ */
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index 1f04b12b9c11..3b350f4d66c0 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -6,8 +6,8 @@
 
 #include <compel/plugins/std/asm/syscall-types.h>
 #include <compel/asm/types.h>
+#include <compel/asm/bitops.h>
 
-#include "asm/bitops.h"
 #include "asm/int.h"
 
 #include "bug.h"
diff --git a/criu/bitmap.c b/criu/bitmap.c
index 65a501e728cb..d9a7bf7d003b 100644
--- a/criu/bitmap.c
+++ b/criu/bitmap.c
@@ -1,4 +1,4 @@
-#include "asm/bitsperlong.h"
+#include <compel/asm/bitsperlong.h>
 
 #define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
 
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 8e097245a145..c527a4af204c 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -25,6 +25,7 @@
 #include <sys/sendfile.h>
 
 #include <compel/plugins/std/syscall-codes.h>
+#include <compel/asm/bitops.h>
 
 #include "ptrace.h"
 #include "compiler.h"
@@ -94,7 +95,6 @@
 
 #include "asm/restore.h"
 #include "asm/atomic.h"
-#include "asm/bitops.h"
 #include "asm/parasite-syscall.h"
 
 #include "cr-errno.h"
diff --git a/criu/pie/log-simple.c b/criu/pie/log-simple.c
index 88f4c7c2d86f..217207d02c21 100644
--- a/criu/pie/log-simple.c
+++ b/criu/pie/log-simple.c
@@ -1,8 +1,7 @@
 #include <stdarg.h>
 
 #include <compel/plugins/std/syscall.h>
-
-#include "asm/bitsperlong.h"
+#include <compel/asm/bitsperlong.h>
 
 #include "log.h"
 
diff --git a/criu/shmem.c b/criu/shmem.c
index 9ba25c9d1406..90bef921ce3d 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -5,6 +5,7 @@
 #include <stdbool.h>
 
 #include <compel/plugins/std/syscall-codes.h>
+#include <compel/asm/bitops.h>
 
 #include "list.h"
 #include "pid.h"
@@ -18,7 +19,6 @@
 #include "vma.h"
 #include "mem.h"
 #include "config.h"
-#include "asm/bitops.h"
 #include "criu-log.h"
 
 #include "protobuf.h"
-- 
2.7.4



More information about the CRIU mailing list