[CRIU] [PATCH 08/22] compel: Get rid of int.h

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


Use native intX helpers, syscall-types.h is a part of uapi.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/include/compel/asm-generic/int.h            |  1 -
 .../uapi/compel/plugins/std/syscall-types.h        | 11 +++----
 compel/plugins/std/std.c                           |  1 -
 compel/src/lib/handle-elf.c                        | 36 ++++++++++------------
 4 files changed, 22 insertions(+), 27 deletions(-)
 delete mode 120000 compel/include/compel/asm-generic/int.h

diff --git a/compel/include/compel/asm-generic/int.h b/compel/include/compel/asm-generic/int.h
deleted file mode 120000
index cd5176e289e2..000000000000
--- a/compel/include/compel/asm-generic/int.h
+++ /dev/null
@@ -1 +0,0 @@
-../../../../criu/include/asm-generic/int.h
\ No newline at end of file
diff --git a/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h b/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
index 883b54011a86..f3f7c8f2c065 100644
--- a/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
+++ b/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
@@ -9,22 +9,21 @@
 #include <arpa/inet.h>
 #include <sys/time.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <signal.h>
 #include <sched.h>
 #include <fcntl.h>
 #include <time.h>
 
-#include "asm-generic/int.h"
-
 struct cap_header {
-	u32 version;
+	uint32_t	version;
 	int pid;
 };
 
 struct cap_data {
-	u32 eff;
-	u32 prm;
-	u32 inh;
+	uint32_t	eff;
+	uint32_t	prm;
+	uint32_t	inh;
 };
 
 struct robust_list_head;
diff --git a/compel/plugins/std/std.c b/compel/plugins/std/std.c
index 493f47efc905..6e2a77c595b5 100644
--- a/compel/plugins/std/std.c
+++ b/compel/plugins/std/std.c
@@ -1,6 +1,5 @@
 #include <sys/types.h>
 
-#include "asm-generic/int.h"
 #include "uapi/compel/plugins.h"
 #include "uapi/compel/plugins/plugin-std.h"
 
diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index cd3d78b31894..aeb4c18d6b8b 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -13,8 +13,6 @@
 
 #include "uapi/compel/compel.h"
 
-#include "asm-generic/int.h"
-
 #include "handle-elf.h"
 #include "piegen.h"
 #include "log.h"
@@ -148,7 +146,7 @@ int __handle_elf(void *mem, size_t size)
 
 	size_t i, k, nr_gotpcrel = 0;
 #ifdef ELF_PPC64
-	s64 toc_offset = 0;
+	int64_t toc_offset = 0;
 #endif
 	int ret = -EINVAL;
 
@@ -285,8 +283,8 @@ int __handle_elf(void *mem, size_t size)
 			 (unsigned)sh->sh_info, &secstrings[sh->sh_name]);
 
 		for (k = 0; k < sh->sh_size / sh->sh_entsize; k++) {
-			s64 __maybe_unused addend64, __maybe_unused value64;
-			s32 __maybe_unused addend32, __maybe_unused value32;
+			int64_t __maybe_unused addend64, __maybe_unused value64;
+			int32_t __maybe_unused addend32, __maybe_unused value32;
 			unsigned long place;
 			const char *name;
 			void *where;
@@ -332,11 +330,11 @@ int __handle_elf(void *mem, size_t size)
 			}
 
 			if (sh->sh_type == SHT_REL) {
-				addend32 = *(s32 *)where;
-				addend64 = *(s64 *)where;
+				addend32 = *(int32_t *)where;
+				addend64 = *(int64_t *)where;
 			} else {
-				addend32 = (s32)r->rela.r_addend;
-				addend64 = (s64)r->rela.r_addend;
+				addend32 = (int32_t)r->rela.r_addend;
+				addend64 = (int64_t)r->rela.r_addend;
 			}
 
 			place = sh_rel->sh_addr + r->rel.r_offset;
@@ -345,8 +343,8 @@ int __handle_elf(void *mem, size_t size)
 				 (unsigned long)sym->st_value, addend32, (long)addend64, (long)place, name);
 
 			if (sym->st_shndx == SHN_ABS) {
-				value32 = (s32)sym->st_value;
-				value64 = (s64)sym->st_value;
+				value32 = (int32_t)sym->st_value;
+				value64 = (int64_t)sym->st_value;
 			} else {
 				Elf_Shdr *sh_src;
 
@@ -358,8 +356,8 @@ int __handle_elf(void *mem, size_t size)
 				sh_src = sec_hdrs[sym->st_shndx];
 				ptr_func_exit(sh_src);
 
-				value32 = (s32)sh_src->sh_addr + (s32)sym->st_value;
-				value64 = (s64)sh_src->sh_addr + (s64)sym->st_value;
+				value32 = (int32_t)sh_src->sh_addr + (int32_t)sym->st_value;
+				value64 = (int64_t)sh_src->sh_addr + (int64_t)sym->st_value;
 			}
 
 #ifdef ELF_PPC64
@@ -499,18 +497,18 @@ int __handle_elf(void *mem, size_t size)
 				       (unsigned int)place, (long)addend64, (long)value64);
 				break;
 			case R_X86_64_PC32: /* Symbol + Addend - Place (4 bytes) */
-				pr_debug("\t\t\t\tR_X86_64_PC32     at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (s32)place);
+				pr_debug("\t\t\t\tR_X86_64_PC32     at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
 				/*
 				 * R_X86_64_PC32 are relative, patch them inplace.
 				 */
-				*((s32 *)where) = value32 + addend32 - place;
+				*((int32_t *)where) = value32 + addend32 - place;
 				break;
 			case R_X86_64_PLT32: /* ProcLinkage + Addend - Place (4 bytes) */
-				pr_debug("\t\t\t\tR_X86_64_PLT32    at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (s32)place);
+				pr_debug("\t\t\t\tR_X86_64_PLT32    at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
 				/*
 				 * R_X86_64_PLT32 are relative, patch them inplace.
 				 */
-				*((s32 *)where) = value32 + addend32 - place;
+				*((int32_t *)where) = value32 + addend32 - place;
 				break;
 			case R_X86_64_GOTPCREL: /* SymbolOffsetInGot + GOT + Addend - Place  (4 bytes) */
 				pr_debug("\t\t\t\tR_X86_64_GOTPCREL at 0x%-4lx val 0x%x\n", place, value32);
@@ -529,11 +527,11 @@ int __handle_elf(void *mem, size_t size)
 				       (unsigned int)place, addend32, value32);
 				break;
 			case R_386_PC32: /* Symbol + Addend - Place */
-				pr_debug("\t\t\t\tR_386_PC32 at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (s32)place);
+				pr_debug("\t\t\t\tR_386_PC32 at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
 				/*
 				 * R_386_PC32 are relative, patch them inplace.
 				 */
-				*((s32 *)where) = value32 + addend32 - place;
+				*((int32_t *)where) = value32 + addend32 - place;
 				break;
 #endif
 
-- 
2.7.4



More information about the CRIU mailing list