From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH] linux-user: add string type in rtentry struct to be able to pass the device name
Date: Sat, 8 Dec 2012 16:20:16 +0100 [thread overview]
Message-ID: <1354980016-19116-1-git-send-email-laurent@vivier.eu> (raw)
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 64 ++++++++++++++++++++++++++++++++++++++++++++
linux-user/syscall_types.h | 4 ++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0415135..849fc7a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3691,6 +3691,70 @@ static IOCTLEntry ioctl_entries[] = {
{ 0, 0, },
};
+static void target_to_host_string (void *dst, const void *src)
+{
+#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
+ if (*(uint32_t*)src == 0) {
+ *(uint32_t*)dst = 0;
+ return;
+ }
+ *(uint32_t *)dst = (uint32_t)g2h(tswap32(*(uint32_t *)src));
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+ if (*(uint32_t*)src == 0) {
+ *(uint64_t*)dst = 0;
+ return;
+ }
+ *(uint64_t *)dst = (uint64_t)g2h(tswap32(*(uint32_t *)src));
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+ if (*(uint64_t*)src == 0) {
+ *(uint64_t*)dst = 0;
+ return;
+ }
+ *(uint64_t *)dst = (uint64_t)g2h(tswap64(*(uint64_t *)src));
+#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
+ if (*(uint64_t*)src == 0) {
+ *(uint32_t*)dst = 0;
+ return;
+ }
+ *(uint32_t *)dst = (uint32_t)g2h(tswap64(*(uint64_t *)src));
+#endif
+}
+
+static void host_to_target_string (void *dst, const void *src)
+{
+#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
+ if (*(uint32_t*)src == 0) {
+ *(uint32_t*)dst = 0;
+ return;
+ }
+ *(uint32_t *)dst = tswap32(h2g(*(uint32_t *)src));
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+ if (*(uint64_t*)src == 0) {
+ *(uint32_t*)dst = 0;
+ return;
+ }
+ *(uint32_t *)dst = tswap32(h2g(*(uint64_t *)src));
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+ if (*(uint64_t*)src == 0) {
+ *(uint64_t*)dst = 0;
+ return;
+ }
+ *(uint64_t *)dst = tswap64(h2g(*(uint64_t *)src));
+#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
+ if (*(uint32_t*)src == 0) {
+ *(uint64_t*)dst = 0;
+ return;
+ }
+ *(uint64_t *)dst = tswap64(h2g(*(uint32_t *)src));
+#endif
+}
+
+static const StructEntry struct_string_def = {
+ .convert = { host_to_target_string, target_to_host_string },
+ .size = { sizeof(target_long), sizeof(long) },
+ .align = { __alignof__(target_long), __alignof__(long) },
+};
+
/* ??? Implement proper locking for ioctls. */
/* do_ioctl() Must return target values and target errnos. */
static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 44b6a58..51fc023 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -14,9 +14,11 @@ STRUCT(serial_icounter_struct,
STRUCT(sockaddr,
TYPE_SHORT, MK_ARRAY(TYPE_CHAR, 14))
+STRUCT_SPECIAL(string)
+
STRUCT(rtentry,
TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr),
- TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID,
+ TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, MK_STRUCT(STRUCT_string),
TYPE_ULONG, TYPE_ULONG, TYPE_SHORT)
STRUCT(ifmap,
--
1.7.10.4
reply other threads:[~2012-12-08 15:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1354980016-19116-1-git-send-email-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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).