diff mbox

fix do_socket(): type conversion for all targets

Message ID AANLkTimWOA4_t3yW3Z2jzKy2=Q9zveKAVfUoGQj2XrXd@mail.gmail.com
State New
Headers show

Commit Message

Jin Guojie Dec. 7, 2010, 9:34 a.m. UTC
Signed-off-by: "Jin Guojie" <jinguojie@loongson.cn>
Signed-off-by: "Yin Yixiao" <yinyixiao@ict.ac.cn>
Reviewed-by: "Gao Xiang" <gaoxiang@ict.ac.cn>

 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(-)

         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));
diff mbox

Patch

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: