[CRIU] [PATCH 01/10] util: Move shmalloc to rst-malloc

Pavel Emelyanov xemul at virtuozzo.com
Fri May 20 09:52:14 PDT 2016


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/autofs.c             |  2 +-
 criu/files-reg.c          |  2 +-
 criu/files.c              |  2 +-
 criu/include/rst-malloc.h |  3 +++
 criu/include/util.h       |  3 ---
 criu/namespaces.c         |  2 +-
 criu/protobuf.c           |  2 +-
 criu/pstree.c             |  2 +-
 criu/rst-malloc.c         | 13 +++++++++++++
 criu/sk-inet.c            |  2 +-
 criu/stats.c              |  1 +
 criu/tty.c                |  2 +-
 criu/util.c               | 12 ------------
 13 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/criu/autofs.c b/criu/autofs.c
index f764d20..6b2fa7e 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -6,7 +6,7 @@
 
 #include "proc_parse.h"
 #include "autofs.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "mount.h"
 #include "pstree.h"
 #include "namespaces.h"
diff --git a/criu/files-reg.c b/criu/files-reg.c
index 167054a..f485e3f 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -22,7 +22,7 @@
 #include "files.h"
 #include "image.h"
 #include "list.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "fs-magic.h"
 #include "asm/atomic.h"
 #include "namespaces.h"
diff --git a/criu/files.c b/criu/files.c
index dfa3603..9a5174c 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -19,7 +19,7 @@
 #include "file-lock.h"
 #include "image.h"
 #include "list.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "util-pie.h"
 #include "lock.h"
 #include "sockets.h"
diff --git a/criu/include/rst-malloc.h b/criu/include/rst-malloc.h
index 001fa41..fafef2b 100644
--- a/criu/include/rst-malloc.h
+++ b/criu/include/rst-malloc.h
@@ -71,4 +71,7 @@ extern void rst_mem_align(int type);
 extern unsigned long rst_mem_lock(void);
 extern int rst_mem_remap(void *to);
 
+extern void *shmalloc(size_t bytes);
+extern void shfree_last(void *ptr);
+
 #endif /* __CR_RST_MALLOC__H__ */
diff --git a/criu/include/util.h b/criu/include/util.h
index 8efa1a8..808b66a 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -169,9 +169,6 @@ extern int is_anon_link_type(char *link, char *type);
 	 ((c) >= 'a' && (c) <= 'f')	||	\
 	 ((c) >= 'A' && (c) <= 'F'))
 
-extern void *shmalloc(size_t bytes);
-extern void shfree_last(void *ptr);
-
 #define CRS_CAN_FAIL	0x1 /* cmd can validly exit with non zero code */
 
 extern int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags);
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 37c151f..0830925 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -15,7 +15,7 @@
 #include <errno.h>
 
 #include "cr_options.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "imgset.h"
 #include "uts_ns.h"
 #include "ipc_ns.h"
diff --git a/criu/protobuf.c b/criu/protobuf.c
index ca2f198..adcfd4f 100644
--- a/criu/protobuf.c
+++ b/criu/protobuf.c
@@ -13,7 +13,7 @@
 #include "compiler.h"
 #include "asm/types.h"
 #include "log.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "string.h"
 #include "sockets.h"
 #include "cr_options.h"
diff --git a/criu/pstree.c b/criu/pstree.c
index efb5c72..c2fa748 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -6,7 +6,7 @@
 
 #include "cr_options.h"
 #include "pstree.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "lock.h"
 #include "namespaces.h"
 #include "files.h"
diff --git a/criu/rst-malloc.c b/criu/rst-malloc.c
index b6e0572..1117b4e 100644
--- a/criu/rst-malloc.c
+++ b/criu/rst-malloc.c
@@ -231,3 +231,16 @@ int rst_mem_remap(void *to)
 
 	return ret;
 }
+
+void *shmalloc(size_t bytes)
+{
+	rst_mem_align(RM_SHARED);
+	return rst_mem_alloc(bytes, RM_SHARED);
+}
+
+/* Only last chunk can be released */
+void shfree_last(void *ptr)
+{
+	rst_mem_free_last(RM_SHARED);
+}
+
diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 460e237..1898b9f 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -19,7 +19,7 @@
 #include "files.h"
 #include "image.h"
 #include "log.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "sockets.h"
 #include "sk-inet.h"
 
diff --git a/criu/stats.c b/criu/stats.c
index 6b636d4..12b7d05 100644
--- a/criu/stats.c
+++ b/criu/stats.c
@@ -2,6 +2,7 @@
 #include <fcntl.h>
 #include <sys/time.h>
 #include "asm/atomic.h"
+#include "rst-malloc.h"
 #include "protobuf.h"
 #include "stats.h"
 #include "image.h"
diff --git a/criu/tty.c b/criu/tty.c
index 66b4e6f..5c72fcc 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -21,7 +21,7 @@
 #include "imgset.h"
 #include "servicefd.h"
 #include "image.h"
-#include "util.h"
+#include "rst-malloc.h"
 #include "log.h"
 #include "list.h"
 #include "util-pie.h"
diff --git a/criu/util.c b/criu/util.c
index eab0ac2..b647c37 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -558,18 +558,6 @@ int is_anon_link_type(char *link, char *type)
 	return !strcmp(link, aux);
 }
 
-void *shmalloc(size_t bytes)
-{
-	rst_mem_align(RM_SHARED);
-	return rst_mem_alloc(bytes, RM_SHARED);
-}
-
-/* Only last chunk can be released */
-void shfree_last(void *ptr)
-{
-	rst_mem_free_last(RM_SHARED);
-}
-
 #define DUP_SAFE(fd, out)						\
 	({							\
 		int ret__;					\
-- 
2.5.0



More information about the CRIU mailing list