[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr) |
Date: |
Tue, 23 Jan 2018 15:47:58 +0100 |
From: Peter Maydell <address@hidden>
The Linux struct cmsghdr is already guaranteed to be sufficiently
aligned that CMSG_ALIGN(sizeof struct cmsghdr) is always equal
to sizeof struct cmsghdr. Stop doing the unnecessary alignment
arithmetic for host and target cmsghdr.
This follows kernel commit 1ff8cebf49ed9e9ca2 and brings our
TARGET_CMSG_* macros back into line with the kernel ones,
as well as making them easier to understand.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 4 ++--
linux-user/syscall_defs.h | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a1b9772a85..39553c81b6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1692,7 +1692,7 @@ static inline abi_long target_to_host_cmsg(struct msghdr
*msgh,
void *target_data = TARGET_CMSG_DATA(target_cmsg);
int len = tswapal(target_cmsg->cmsg_len)
- - TARGET_CMSG_ALIGN(sizeof (struct target_cmsghdr));
+ - sizeof(struct target_cmsghdr);
space += CMSG_SPACE(len);
if (space > msgh->msg_controllen) {
@@ -1773,7 +1773,7 @@ static inline abi_long host_to_target_cmsg(struct
target_msghdr *target_msgh,
void *data = CMSG_DATA(cmsg);
void *target_data = TARGET_CMSG_DATA(target_cmsg);
- int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr));
+ int len = cmsg->cmsg_len - sizeof(struct cmsghdr);
int tgt_len, tgt_space;
/* We never copy a half-header but may copy half-data;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index bec3680b94..a35c52a60a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -303,9 +303,9 @@ struct target_cmsghdr {
__target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
& (size_t) ~(sizeof (abi_long) - 1))
-#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
- + TARGET_CMSG_ALIGN (sizeof (struct
target_cmsghdr)))
-#define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct
target_cmsghdr)) + (len))
+#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
+ TARGET_CMSG_ALIGN(len))
+#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
static __inline__ struct target_cmsghdr *
__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
--
2.14.3
- [Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 syscall, (continued)
- [Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 syscall, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 03/13] linux-user: Fix length calculations in host_to_target_cmsg(), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 08/13] linux-user: Add AT_SECURE auxval, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 09/13] linux-user: Add getcpu() support, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 10/13] linux-user: remove nmi.c and fw-path-provider.c, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 13/13] linux-user: implement renameat2, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 02/13] linux-user: wrap fork() in a start/end exclusive section, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr),
Laurent Vivier <=
- [Qemu-devel] [PULL 07/13] linux-user: Fix sched_get/setaffinity conversion, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 11/13] linux-user: Propagate siginfo_t through to handle_cpu_signal(), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 12/13] page_unprotect(): handle calls to pages that are PAGE_WRITE, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 06/13] linux-user/mmap.c: Avoid choosing NULL as start address, Laurent Vivier, 2018/01/23
- Re: [Qemu-devel] [PULL 00/13] Linux user for 2.12 patches, Peter Maydell, 2018/01/25