[CRIU] [PATCH 15/38] compel: Drop using custom uX and sX types but switch to stdint
Cyrill Gorcunov
gorcunov at openvz.org
Tue Oct 11 09:04:05 PDT 2016
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
compel/arch/arm/plugins/std/syscalls/syscall.def | 4 +--
.../ppc64/plugins/std/syscalls/syscall-ppc64.tbl | 4 +--
compel/arch/x86/plugins/std/syscalls/syscall32.c | 24 +++++++--------
.../arch/x86/plugins/std/syscalls/syscall_32.tbl | 8 ++---
.../arch/x86/plugins/std/syscalls/syscall_64.tbl | 4 +--
compel/include/asm-generic/int.h | 1 -
compel/plugins/include/uapi/std/syscall-types.h | 13 ++++----
compel/plugins/std/std.c | 1 -
compel/src/lib/handle-elf.c | 36 ++++++++++------------
9 files changed, 45 insertions(+), 50 deletions(-)
delete mode 120000 compel/include/asm-generic/int.h
diff --git a/compel/arch/arm/plugins/std/syscalls/syscall.def b/compel/arch/arm/plugins/std/syscalls/syscall.def
index e5adbdc48e75..c4e390ac590d 100644
--- a/compel/arch/arm/plugins/std/syscalls/syscall.def
+++ b/compel/arch/arm/plugins/std/syscalls/syscall.def
@@ -77,7 +77,7 @@ setrlimit 164 75 (int resource, struct krlimit *rlim)
mount 40 21 (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
umount2 39 52 (char *name, int flags)
gettid 178 224 (void)
-futex 98 240 (u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
+futex 98 240 (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
set_tid_address 96 256 (int *tid_addr)
restart_syscall 128 0 (void)
timer_create 107 257 (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
@@ -94,7 +94,7 @@ rt_tgsigqueueinfo 240 363 (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
vmsplice 75 343 (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
timerfd_settime 86 353 (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
fanotify_init 262 367 (unsigned int flags, unsigned int event_f_flags)
-fanotify_mark 263 368 (int fanotify_fd, unsigned int flags, u64 mask, int dfd, const char *pathname)
+fanotify_mark 263 368 (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
open_by_handle_at 265 371 (int mountdirfd, struct file_handle *handle, int flags)
setns 268 375 (int fd, int nstype)
kcmp 272 378 (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
diff --git a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
index d7033aa39b62..e94277c1df2f 100644
--- a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
+++ b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
@@ -74,7 +74,7 @@ __NR_setrlimit 75 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 21 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 52 sys_umount2 (char *name, int flags)
__NR_gettid 207 sys_gettid (void)
-__NR_futex 221 sys_futex (u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
+__NR_futex 221 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_tid_address 232 sys_set_tid_address (int *tid_addr)
__NR_restart_syscall 0 sys_restart_syscall (void)
__NR_sys_timer_create 240 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
@@ -93,7 +93,7 @@ __NR_timerfd_settime 311 sys_timerfd_settime (int ufd, int flags, const struct
__NR_signalfd4 313 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_rt_tgsigqueueinfo 322 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 323 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
-__NR_fanotify_mark 324 sys_fanotify_mark (int fanotify_fd, unsigned int flags, u64 mask, int dfd, const char *pathname)
+__NR_fanotify_mark 324 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 346 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 350 sys_setns (int fd, int nstype)
__NR_kcmp 354 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall32.c b/compel/arch/x86/plugins/std/syscalls/syscall32.c
index 88af59330adf..e172cacfff13 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall32.c
+++ b/compel/arch/x86/plugins/std/syscalls/syscall32.c
@@ -14,61 +14,61 @@
long sys_socket(int domain, int type, int protocol)
{
- u32 a[] = { (u32)domain, (u32)type, (u32)protocol };
+ uint32_t a[] = { (uint32_t)domain, (uint32_t)type, (uint32_t)protocol };
return sys_socketcall(SYS_SOCKET, (unsigned long *)a);
}
long sys_connect(int sockfd, struct sockaddr *addr, int addrlen)
{
- u32 a[] = {(u32)sockfd, (u32)addr, (u32)addrlen};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen};
return sys_socketcall(SYS_CONNECT, (unsigned long *)a);
}
long sys_sendto(int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
{
- u32 a[] = {(u32)sockfd, (u32)buff, (u32)len, (u32)flags, (u32)addr, (u32)addr_len};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)buff, (uint32_t)len, (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len};
return sys_socketcall(SYS_SENDTO, (unsigned long *)a);
}
long sys_recvfrom(int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
{
- u32 a[] = {(u32)sockfd, (u32)ubuf, (u32)size, (u32)flags, (u32)addr, (u32)addr_len};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)ubuf, (uint32_t)size, (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len};
return sys_socketcall(SYS_RECVFROM, (unsigned long *)a);
}
long sys_sendmsg(int sockfd, const struct msghdr *msg, int flags)
{
- u32 a[] = {(u32)sockfd, (u32)msg, (u32)flags};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags};
return sys_socketcall(SYS_SENDMSG, (unsigned long *)a);
}
long sys_recvmsg(int sockfd, struct msghdr *msg, int flags)
{
- u32 a[] = {(u32)sockfd, (u32)msg, (u32)flags};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags};
return sys_socketcall(SYS_RECVMSG, (unsigned long *)a);
}
long sys_shutdown(int sockfd, int how)
{
- u32 a[] = {(u32)sockfd, (u32)how};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)how};
return sys_socketcall(SYS_SHUTDOWN, (unsigned long *)a);
}
long sys_bind(int sockfd, const struct sockaddr *addr, int addrlen)
{
- u32 a[] = {(u32)sockfd, (u32)addr, (u32)addrlen};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen};
return sys_socketcall(SYS_BIND, (unsigned long *)a);
}
long sys_setsockopt(int sockfd, int level, int optname, const void *optval, unsigned int optlen)
{
- u32 a[] = {(u32)sockfd, (u32)level, (u32)optname, (u32)optval, (u32)optlen};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen};
return sys_socketcall(SYS_SETSOCKOPT, (unsigned long *)a);
}
long sys_getsockopt(int sockfd, int level, int optname, const void *optval, unsigned int *optlen)
{
- u32 a[] = {(u32)sockfd, (u32)level, (u32)optname, (u32)optval, (u32)optlen};
+ uint32_t a[] = {(uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen};
return sys_socketcall(SYS_GETSOCKOPT, (unsigned long *)a);
}
@@ -79,7 +79,7 @@ long sys_shmat(int shmid, void *shmaddr, int shmflag)
return sys_ipc(SHMAT, shmid, shmflag, 0, shmaddr, 0);
}
-long sys_pread(unsigned int fd, char *ubuf, u32 count, u64 pos)
+long sys_pread(unsigned int fd, char *ubuf, uint32_t count, uint64_t pos)
{
- return sys_pread64(fd, ubuf, count, (u32)(pos & 0xffffffffu), (u32)(pos >> 32));
+ return sys_pread64(fd, ubuf, count, (uint32_t)(pos & 0xffffffffu), (uint32_t)(pos >> 32));
}
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
index 7c4867c1b3f5..355de71ad389 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
@@ -11,7 +11,7 @@ __NR_write 4 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 5 sys_open (const char *filename, int flags, unsigned int mode)
__NR_close 6 sys_close (int fd)
__NR_unlink 10 sys_unlink (char *pathname)
-__NR_lseek 19 sys_lseek (int fd, s32 offset, unsigned int origin)
+__NR_lseek 19 sys_lseek (int fd, int32_t offset, unsigned int origin)
__NR_getpid 20 sys_getpid (void)
__NR_mount 21 sys_mount (const char *dev_name, const char *dir_name, const char *type, unsigned long flags, const void *data)
__NR_ptrace 26 sys_ptrace (long request, pid_t pid, void *addr, void *data)
@@ -45,7 +45,7 @@ __NR_rt_sigreturn 173 sys_rt_sigreturn (void)
__NR_rt_sigaction 174 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 175 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *oset, size_t sigsetsize)
__NR_rt_sigqueueinfo 178 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *uinfo)
-__NR_pread64 180 sys_pread64 (unsigned int fd, char *ubuf, u32 count, u32 poslo, u32 poshi)
+__NR_pread64 180 sys_pread64 (unsigned int fd, char *ubuf, uint32_t count, uint32_t poslo, uint32_t poshi)
__NR_capget 184 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 185 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_sigaltstack 186 sys_sigaltstack (const void *uss_ptr, void *uoss_ptr)
@@ -61,7 +61,7 @@ __NR_setfsgid32 216 sys_setfsgid (int fsgid)
__NR_mincore 218 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 219 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_gettid 224 sys_gettid (void)
-__NR_futex 240 sys_futex (u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
+__NR_futex 240 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_thread_area 243 sys_set_thread_area (user_desc_t *info)
__NR_get_thread_area 244 sys_get_thread_area (user_desc_t *info)
__NR_io_setup 245 sys_io_setup (unsigned nr_reqs, aio_context_t *ctx32p)
@@ -85,7 +85,7 @@ __NR_signalfd 321 sys_signalfd (int ufd, const k_rtsigset_t *sigmask, size_t
__NR_timerfd_settime 325 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_rt_tgsigqueueinfo 335 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo)
__NR_fanotify_init 338 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
-__NR_fanotify_mark 339 sys_fanotify_mark (int fanotify_fd, unsigned int flag, u32 mask, int dfd, const char *pathname)
+__NR_fanotify_mark 339 sys_fanotify_mark (int fanotify_fd, unsigned int flag, uint32_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 342 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 346 sys_setns (int fd, int nstype)
__NR_kcmp 349 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
index 285874938b38..dade3a02629c 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
@@ -71,7 +71,7 @@ __NR_setrlimit 160 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 165 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 166 sys_umount2 (char *name, int flags)
__NR_gettid 186 sys_gettid (void)
-__NR_futex 202 sys_futex (u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
+__NR_futex 202 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_thread_area 205 sys_set_thread_area (user_desc_t *info)
__NR_io_setup 206 sys_io_setup (unsigned nr_events, aio_context_t *ctx)
__NR_io_getevents 208 sys_io_getevents (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
@@ -97,7 +97,7 @@ __NR_timerfd_settime 286 sys_timerfd_settime (int ufd, int flags, const struct
__NR_signalfd4 289 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_rt_tgsigqueueinfo 297 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 300 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
-__NR_fanotify_mark 301 sys_fanotify_mark (int fanotify_fd, unsigned int flags, u64 mask, int dfd, const char *pathname)
+__NR_fanotify_mark 301 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 304 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 308 sys_setns (int fd, int nstype)
__NR_kcmp 312 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
diff --git a/compel/include/asm-generic/int.h b/compel/include/asm-generic/int.h
deleted file mode 120000
index 40be48fa5d8e..000000000000
--- a/compel/include/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/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h
index c311ed76c299..cc3bb4e90f12 100644
--- a/compel/plugins/include/uapi/std/syscall-types.h
+++ b/compel/plugins/include/uapi/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;
- int pid;
+ 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 a1f14ce3a3dd..705629f479a5 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/plugins.h"
#include "uapi/plugin-std.h"
diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index 87683aa7898a..22934fba05ed 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -13,8 +13,6 @@
#include "uapi/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