From: Karim Taha <kariem.taha2.7@gmail.com>
To: qemu-devel@nongnu.org
Cc: imp@bsdimp.com, Sean Bruno <sbruno@FreeBSD.org>,
Kyle Evans <kevans@FreeBSD.org>,
Karim Taha <kariem.taha2.7@gmail.com>
Subject: [PATCH v4 03/11] Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Date: Fri, 21 Apr 2023 18:53:43 +0200 [thread overview]
Message-ID: <20230421165351.3177-4-kariem.taha2.7@gmail.com> (raw)
In-Reply-To: <20230421165351.3177-1-kariem.taha2.7@gmail.com>
From: Sean Bruno <sbruno@FreeBSD.org>
Target cmsghdr struct and flags.
Add the cmsghdr struct and alignment flags.
Co-authored-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Sean Bruno <sbruno@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
bsd-user/syscall_defs.h | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index f041245792..b594fafecc 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -275,6 +275,44 @@ struct target_cmsghdr {
int32_t cmsg_type;
};
+/*
+ * mips32 is the exception to the general rule of long-alignment; it
+ * unconditionally uses 64-bit alignment instead.
+ */
+#if defined(TARGET_MIPS) && TARGET_ABI_BITS == 32
+#define TARGET_ALIGNBYTES (sizeof(abi_llong) - 1)
+#else
+#define TARGET_ALIGNBYTES (sizeof(abi_long) - 1)
+#endif
+
+#define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
+ __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
+#define TARGET_CMSG_ALIGN(len) (((len) + TARGET_ALIGNBYTES) \
+ & (size_t) ~TARGET_ALIGNBYTES)
+#define TARGET_CMSG_DATA(cmsg) \
+ ((unsigned char *)(cmsg) + TARGET_CMSG_ALIGN(sizeof(struct target_cmsghdr)))
+#define TARGET_CMSG_SPACE(len) \
+ (TARGET_CMSG_ALIGN(sizeof(struct target_cmsghdr)) + TARGET_CMSG_ALIGN(len))
+#define TARGET_CMSG_LEN(len) \
+ (TARGET_CMSG_ALIGN(sizeof(struct target_cmsghdr)) + (len))
+
+static inline struct target_cmsghdr *
+__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
+ struct target_cmsghdr *__cmsg,
+ struct target_cmsghdr *__cmsg_start)
+{
+ struct target_cmsghdr *__ptr;
+
+ __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg +
+ TARGET_CMSG_ALIGN(tswap32(__cmsg->cmsg_len)));
+ if ((unsigned long)((char *)(__ptr + 1) - (char *)__cmsg_start) >
+ tswap32(__mhdr->msg_controllen)) {
+ /* No more entries. */
+ return (struct target_cmsghdr *)0;
+ }
+ return __ptr;
+}
+
/*
* netinet/in.h
*/
--
2.40.0
next prev parent reply other threads:[~2023-04-21 16:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 16:53 [PATCH v4 00/11] Contribution task implementations, for the 'FreeBSD user emulation improvements' project Karim Taha
2023-04-21 16:53 ` [PATCH v4 01/11] Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Karim Taha
2023-04-24 8:30 ` Daniel P. Berrangé
2023-04-21 16:53 ` [PATCH v4 02/11] " Karim Taha
2023-04-21 16:53 ` Karim Taha [this message]
2023-04-21 16:53 ` [PATCH v4 04/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 05/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 06/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 07/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 08/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 09/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 10/11] " Karim Taha
2023-04-21 16:53 ` [PATCH v4 11/11] " Karim Taha
2023-04-21 22:46 ` Warner Losh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230421165351.3177-4-kariem.taha2.7@gmail.com \
--to=kariem.taha2.7@gmail.com \
--cc=imp@bsdimp.com \
--cc=kevans@FreeBSD.org \
--cc=qemu-devel@nongnu.org \
--cc=sbruno@FreeBSD.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).