Fix accessing the thread id on Android

This commit is contained in:
Arvid Gerstmann 2018-07-24 13:43:25 +02:00
parent f04e67779c
commit 69dac3f611

View File

@ -7,7 +7,9 @@
#endif
#ifdef __linux__
# ifndef __ANDROID__
# include <syscall.h>
# endif
# include <fcntl.h>
#endif
@ -148,7 +150,11 @@ const char* GetThreadName( uint64_t id )
# elif defined __linux__
int cs, fd;
char path[32];
# ifdef __ANDROID__
int tid = gettid();
# else
int tid = (int) syscall( SYS_gettid );
# endif
snprintf( path, sizeof( path ), "/proc/self/task/%d/comm", tid );
sprintf( buf, "%" PRIu64, id );
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &cs );