Fixed __ANDROID_API__ < 21 build and FD_SET usage.

This commit is contained in:
Till Rathmann 2018-08-01 19:18:40 +02:00
parent df09fe48cf
commit 3b302315f9
2 changed files with 14 additions and 8 deletions

View File

@ -124,6 +124,7 @@ static int64_t SetupHwTimer()
static const char* GetProcessName()
{
const char* processName = "unknown";
#if defined _MSC_VER
static char buf[_MAX_PATH];
GetModuleFileNameA( nullptr, buf, _MAX_PATH );
@ -131,17 +132,16 @@ static const char* GetProcessName()
while( *ptr != '\0' ) ptr++;
while( ptr > buf && *ptr != '\\' && *ptr != '/' ) ptr--;
if( ptr > buf ) ptr++;
return ptr;
processName = ptr;
#elif defined __ANDROID__
# if __ANDROID_API__ >= 21
auto buf = getprogname();
if( buf ) return buf;
if( buf ) processName = buf;
# endif
#elif defined _GNU_SOURCE || defined __CYGWIN__
return program_invocation_short_name;
#else
return "unknown";
processName = program_invocation_short_name;
#endif
return processName;
}
enum { QueuePrealloc = 256 * 1024 };

View File

@ -25,6 +25,12 @@
namespace tracy
{
#ifdef _MSC_VER
typedef SOCKET socket_t;
#else
typedef int socket_t;
#endif
#ifdef _MSC_VER
struct __wsinit
{
@ -174,7 +180,7 @@ int Socket::Recv( void* _buf, int len, const timeval* tv )
fd_set fds;
FD_ZERO( &fds );
FD_SET( static_cast<unsigned int>(m_sock), &fds );
FD_SET( static_cast<socket_t>(m_sock), &fds );
#ifndef _WIN32
timeval _tv = *tv;
@ -231,7 +237,7 @@ bool Socket::HasData()
fd_set fds;
FD_ZERO( &fds );
FD_SET( static_cast<unsigned int>(m_sock), &fds );
FD_SET( static_cast<socket_t>(m_sock), &fds );
return select( m_sock+1, &fds, nullptr, nullptr, &tv ) > 0;
}
@ -287,7 +293,7 @@ Socket* ListenSocket::Accept()
fd_set fds;
FD_ZERO( &fds );
FD_SET( static_cast<unsigned int>(m_sock), &fds );
FD_SET( static_cast<socket_t>(m_sock), &fds );
select( m_sock+1, &fds, nullptr, nullptr, &tv );
if( FD_ISSET( m_sock, &fds ) )