From: Julian Seward Date: Tue, 18 Oct 2005 02:15:39 +0000 (+0000) Subject: Fix socket stuff on ppc32, so that --log-socket actually works. X-Git-Tag: svn/VALGRIND_3_1_0~292 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd5eb80553516e23d55e0042bcdd72b769e201c2;p=thirdparty%2Fvalgrind.git Fix socket stuff on ppc32, so that --log-socket actually works. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4940 --- diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index 413bd11a3d..53559af68e 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -342,16 +342,24 @@ Int my_connect ( Int sockfd, struct vki_sockaddr_in* serv_addr, static UInt my_htonl ( UInt x ) { +# if defined(VG_BIGENDIAN) + return x; +# else return (((x >> 24) & 0xFF) << 0) | (((x >> 16) & 0xFF) << 8) | (((x >> 8) & 0xFF) << 16) | (((x >> 0) & 0xFF) << 24); +# endif } static UShort my_htons ( UShort x ) { +# if defined(VG_BIGENDIAN) + return x; +# else return (((x >> 8) & 0xFF) << 0) | (((x >> 0) & 0xFF) << 8); +# endif } @@ -388,16 +396,16 @@ Int VG_(connect_via_socket)( UChar* str ) /* create socket */ sd = my_socket(VKI_AF_INET, VKI_SOCK_STREAM, 0 /* IPPROTO_IP ? */); if (sd < 0) { - /* this shouldn't happen ... nevertheless */ - return -2; + /* this shouldn't happen ... nevertheless */ + return -2; } - + /* connect to server */ res = my_connect(sd, (struct vki_sockaddr_in *) &servAddr, sizeof(servAddr)); if (res < 0) { - /* connection failed */ - return -2; + /* connection failed */ + return -2; } return sd; @@ -501,7 +509,7 @@ Int VG_(write_socket)( Int sd, void *msg, Int count ) error is still returned. */ Int flags = VKI_MSG_NOSIGNAL; -#if defined(VGP_x86_linux) +#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux) SysRes res; UWord args[4]; args[0] = sd; @@ -516,11 +524,6 @@ Int VG_(write_socket)( Int sd, void *msg, Int count ) res = VG_(do_syscall6)(__NR_sendto, sd, (UWord)msg, count, flags, 0,0); return res.isError ? -1 : res.val; -#elif defined(VGP_ppc32_linux) - //CAB: TODO - I_die_here; - flags = 0; // stop compiler complaints - #else # error Unknown arch #endif