Sanitiser common, using u64 type for GetTid on posix systems

Summary: Moving from ptr to u64 for GetTid posix implementation.
[FreeBSD] Moving from pthread_self to thr_self more appropriate to get thread ID.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D43998

llvm-svn: 326647
This commit is contained in:
Kamil Rytarowski 2018-03-03 11:50:58 +00:00
parent 0d58e0f613
commit d14a955c24
2 changed files with 5 additions and 7 deletions

View File

@ -178,12 +178,7 @@ typedef u32 operator_new_size_type;
# endif
#endif
#if SANITIZER_MAC
// On Darwin, thread IDs are 64-bit even on 32-bit systems.
typedef u64 tid_t;
#else
typedef uptr tid_t;
#endif
// ----------- ATTENTION -------------
// This header should NOT include any other headers to avoid portability issues.

View File

@ -84,6 +84,7 @@ extern "C" {
// FreeBSD 9.2 and 10.0.
#include <sys/umtx.h>
}
#include <sys/thr.h>
extern char **environ; // provided by crt1
#endif // SANITIZER_FREEBSD
@ -453,11 +454,13 @@ bool FileExists(const char *filename) {
tid_t GetTid() {
#if SANITIZER_FREEBSD
return (uptr)pthread_self();
long Tid;
thr_self(&Tid);
return Tid;
#elif SANITIZER_NETBSD
return _lwp_self();
#elif SANITIZER_SOLARIS
return (uptr)thr_self();
return thr_self();
#else
return internal_syscall(SYSCALL(gettid));
#endif