Replace all in_port_t with uint16_t to avoid compilation issues on different systems.

llvm-svn: 196586
This commit is contained in:
Greg Clayton 2013-12-06 17:46:35 +00:00
parent f7760a24e5
commit d629980ab3
9 changed files with 25 additions and 28 deletions

View File

@ -11,9 +11,7 @@
#define liblldb_ConnectionFileDescriptor_h_
// C Includes
#ifdef _WIN32
typedef unsigned short in_port_t;
#else
#ifndef _WIN32
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
@ -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<in_port_t> 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<uint16_t> 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

View File

@ -18,7 +18,6 @@
#include <winsock2.h>
#include <WS2tcpip.h>
typedef ADDRESS_FAMILY sa_family_t;
typedef USHORT in_port_t;
#else
#include <sys/socket.h>
#include <netdb.h>
@ -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.

View File

@ -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

View File

@ -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)
{

View File

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

View File

@ -258,7 +258,7 @@ protected:
lldb_private::Error
StartListenThread (const char *hostname = "localhost",
in_port_t port = 0);
uint16_t port = 0);
bool
JoinListenThread ();

View File

@ -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

View File

@ -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);

View File

@ -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])