From d629980ab3995fc5b47b6321e3ea490886cd446e Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 6 Dec 2013 17:46:35 +0000 Subject: [PATCH] Replace all in_port_t with uint16_t to avoid compilation issues on different systems. llvm-svn: 196586 --- lldb/include/lldb/Core/ConnectionFileDescriptor.h | 14 ++++++-------- lldb/include/lldb/Host/SocketAddress.h | 9 ++++----- lldb/source/Core/ConnectionFileDescriptor.cpp | 10 +++++----- lldb/source/Host/common/SocketAddress.cpp | 8 ++++---- .../Process/gdb-remote/GDBRemoteCommunication.cpp | 2 +- .../Process/gdb-remote/GDBRemoteCommunication.h | 2 +- lldb/tools/debugserver/source/RNBSocket.cpp | 2 +- lldb/tools/debugserver/source/RNBSocket.h | 4 ++-- lldb/tools/debugserver/source/debugserver.cpp | 2 +- 9 files changed, 25 insertions(+), 28 deletions(-) diff --git a/lldb/include/lldb/Core/ConnectionFileDescriptor.h b/lldb/include/lldb/Core/ConnectionFileDescriptor.h index 01cc40a37de0..15598c9b1335 100644 --- a/lldb/include/lldb/Core/ConnectionFileDescriptor.h +++ b/lldb/include/lldb/Core/ConnectionFileDescriptor.h @@ -11,9 +11,7 @@ #define liblldb_ConnectionFileDescriptor_h_ // C Includes -#ifdef _WIN32 -typedef unsigned short in_port_t; -#else +#ifndef _WIN32 #include #include #include @@ -68,15 +66,15 @@ public: // If the read file descriptor is a socket, then return // the port number that is being used by the socket. - in_port_t + uint16_t GetReadPort () const; // If the write file descriptor is a socket, then return // the port number that is being used by the socket. - in_port_t + uint16_t GetWritePort () const; - in_port_t + uint16_t GetBoundPort (uint32_t timeout_sec); protected: @@ -124,12 +122,12 @@ protected: int m_pipe_read; // A pipe that we select on the reading end of along with int m_pipe_write; // m_fd_recv so we can force ourselves out of the select. Mutex m_mutex; - Predicate m_port_predicate; // Used when binding to port zero to wait for the thread that creates the socket, binds and listens to resolve the port number + Predicate m_port_predicate; // Used when binding to port zero to wait for the thread that creates the socket, binds and listens to resolve the port number bool m_should_close_fd; // True if this class should close the file descriptor when it goes away. bool m_shutting_down; // This marks that we are shutting down so if we get woken up from BytesAvailable // to disconnect, we won't try to read again. - static in_port_t + static uint16_t GetSocketPort (int fd); static int diff --git a/lldb/include/lldb/Host/SocketAddress.h b/lldb/include/lldb/Host/SocketAddress.h index 02d24a33e9c1..4dc62102103a 100644 --- a/lldb/include/lldb/Host/SocketAddress.h +++ b/lldb/include/lldb/Host/SocketAddress.h @@ -18,7 +18,6 @@ #include #include typedef ADDRESS_FAMILY sa_family_t; -typedef USHORT in_port_t; #else #include #include @@ -103,7 +102,7 @@ public: //------------------------------------------------------------------ // Get the port if the socket address for the family has a port //------------------------------------------------------------------ - in_port_t + uint16_t GetPort () const; //------------------------------------------------------------------ @@ -111,7 +110,7 @@ public: // The family must be set correctly prior to calling this function. //------------------------------------------------------------------ bool - SetPort (in_port_t port); + SetPort (uint16_t port); //------------------------------------------------------------------ // Set the socket address according to the first match from a call @@ -135,11 +134,11 @@ public: //------------------------------------------------------------------ bool SetToLocalhost (sa_family_t family, - in_port_t port); + uint16_t port); bool SetToAnyAddress (sa_family_t family, - in_port_t port); + uint16_t port); //------------------------------------------------------------------ // Returns true if there is a valid socket address in this object. diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp index d711ef8e185a..3fb43cfa02c5 100644 --- a/lldb/source/Core/ConnectionFileDescriptor.cpp +++ b/lldb/source/Core/ConnectionFileDescriptor.cpp @@ -1675,7 +1675,7 @@ ConnectionFileDescriptor::SetSocketReceiveTimeout (uint32_t timeout_usec) return false; } -in_port_t +uint16_t ConnectionFileDescriptor::GetSocketPort (int fd) { // We bound to port zero, so we need to figure out which port we actually bound to @@ -1691,7 +1691,7 @@ ConnectionFileDescriptor::GetSocketPort (int fd) // If the read file descriptor is a socket, then return // the port number that is being used by the socket. -in_port_t +uint16_t ConnectionFileDescriptor::GetReadPort () const { return ConnectionFileDescriptor::GetSocketPort (m_fd_recv); @@ -1699,16 +1699,16 @@ ConnectionFileDescriptor::GetReadPort () const // If the write file descriptor is a socket, then return // the port number that is being used by the socket. -in_port_t +uint16_t ConnectionFileDescriptor::GetWritePort () const { return ConnectionFileDescriptor::GetSocketPort (m_fd_send); } -in_port_t +uint16_t ConnectionFileDescriptor::GetBoundPort (uint32_t timeout_sec) { - in_port_t bound_port = 0; + uint16_t bound_port = 0; if (timeout_sec == UINT32_MAX) m_port_predicate.WaitForValueNotEqualTo (0, bound_port); else diff --git a/lldb/source/Host/common/SocketAddress.cpp b/lldb/source/Host/common/SocketAddress.cpp index f5a58a6d208e..5d6243e0961f 100644 --- a/lldb/source/Host/common/SocketAddress.cpp +++ b/lldb/source/Host/common/SocketAddress.cpp @@ -123,7 +123,7 @@ SocketAddress::SetFamily (sa_family_t family) #endif } -in_port_t +uint16_t SocketAddress::GetPort () const { switch (GetFamily()) @@ -135,7 +135,7 @@ SocketAddress::GetPort () const } bool -SocketAddress::SetPort (in_port_t port) +SocketAddress::SetPort (uint16_t port) { switch (GetFamily()) { @@ -233,7 +233,7 @@ SocketAddress::getaddrinfo (const char *host, bool -SocketAddress::SetToLocalhost (sa_family_t family, in_port_t port) +SocketAddress::SetToLocalhost (sa_family_t family, uint16_t port) { switch (family) { @@ -261,7 +261,7 @@ SocketAddress::SetToLocalhost (sa_family_t family, in_port_t port) } bool -SocketAddress::SetToAnyAddress (sa_family_t family, in_port_t port) +SocketAddress::SetToAnyAddress (sa_family_t family, uint16_t port) { switch (family) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 04de58bcd4c3..5966ccadffcc 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -542,7 +542,7 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri } Error -GDBRemoteCommunication::StartListenThread (const char *hostname, in_port_t port) +GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port) { Error error; if (IS_VALID_LLDB_HOST_THREAD(m_listen_thread)) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index a21679e51dc7..fb1955e3f749 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -258,7 +258,7 @@ protected: lldb_private::Error StartListenThread (const char *hostname = "localhost", - in_port_t port = 0); + uint16_t port = 0); bool JoinListenThread (); diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp index 448db2575a82..7772d6829b62 100644 --- a/lldb/tools/debugserver/source/RNBSocket.cpp +++ b/lldb/tools/debugserver/source/RNBSocket.cpp @@ -67,7 +67,7 @@ ResolveIPV4HostName (const char *hostname, in_addr_t &addr) } rnb_err_t -RNBSocket::Listen (const char *listen_host, in_port_t port, PortBoundCallback callback, const void *callback_baton) +RNBSocket::Listen (const char *listen_host, uint16_t port, PortBoundCallback callback, const void *callback_baton) { //DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s called", (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__); // Disconnect without saving errno diff --git a/lldb/tools/debugserver/source/RNBSocket.h b/lldb/tools/debugserver/source/RNBSocket.h index 2467bb77bb43..32f4ebeed2a4 100644 --- a/lldb/tools/debugserver/source/RNBSocket.h +++ b/lldb/tools/debugserver/source/RNBSocket.h @@ -27,7 +27,7 @@ class RNBSocket { public: - typedef void (*PortBoundCallback) (const void *baton, in_port_t port); + typedef void (*PortBoundCallback) (const void *baton, uint16_t port); RNBSocket () : m_fd (-1), @@ -44,7 +44,7 @@ public: } rnb_err_t Listen (const char *listen_host, - in_port_t port, + uint16_t port, PortBoundCallback callback, const void *callback_baton); rnb_err_t Connect (const char *host, uint16_t port); diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 42469ce89e31..1b516e63e0d6 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -626,7 +626,7 @@ RNBRunLoopPlatform (RNBRemote *remote) } static void -PortWasBoundCallbackNamedPipe (const void *baton, in_port_t port) +PortWasBoundCallbackNamedPipe (const void *baton, uint16_t port) { const char *named_pipe = (const char *)baton; if (named_pipe && named_pipe[0])