qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] fix do_socket(): type conversion for all targets


From: Jin Guojie
Subject: [Qemu-devel] [PATCH] fix do_socket(): type conversion for all targets
Date: Tue, 7 Dec 2010 17:34:37 +0800

Signed-off-by: "Jin Guojie" <address@hidden>
Signed-off-by: "Yin Yixiao" <address@hidden>
Reviewed-by: "Gao Xiang" <address@hidden>

 A patch for do_socket() in Linux user mode.
 The original code only handles socket constants conversion for target MIPS.
 We encountered this problem when emulating X86 apps on MIPS machines.
 This patch extends the scope to all targets and fix the problem.
 For your review, any comment is strongly welcomed.

Jin Guojie
www.loongson.cn
---
 linux-user/socket.h  |   10 ++++++++++
 linux-user/syscall.c |    3 +--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/linux-user/socket.h b/linux-user/socket.h
index 93d4782..f24b44c 100644
--- a/linux-user/socket.h
+++ b/linux-user/socket.h
@@ -144,4 +144,14 @@

        #define TARGET_SO_PEERSEC              31

+       enum sock_type {
+              TARGET_SOCK_DGRAM       = 2,
+              TARGET_SOCK_STREAM      = 1,
+              TARGET_SOCK_RAW = 3,
+              TARGET_SOCK_RDM = 4,
+              TARGET_SOCK_SEQPACKET   = 5,
+              TARGET_SOCK_DCCP        = 6,
+              TARGET_SOCK_PACKET      = 10,
+       };
+
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c3e8706..544698a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1568,7 +1568,6 @@ static abi_long unlock_iovec(struct iovec *vec,
abi_ulong target_addr,
 /* do_socket() Must return target values and target errnos. */
 static abi_long do_socket(int domain, int type, int protocol)
 {
-#if defined(TARGET_MIPS)
     switch(type) {
     case TARGET_SOCK_DGRAM:
         type = SOCK_DGRAM;
@@ -1589,7 +1588,7 @@ static abi_long do_socket(int domain, int type,
int protocol)
         type = SOCK_PACKET;
         break;
     }
-#endif
+
     if (domain == PF_NETLINK)
         return -EAFNOSUPPORT; /* do not NETLINK socket connections possible */
     return get_errno(socket(domain, type, protocol));
-- 
1.5.2.3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]