mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Switch macOS to use fallback for thread ID
macOS uses a 64-bit thread ID, so rather than truncate this in GetCurrentThreadId, use pthread_self's result and mix it with the MSBs of the pointer to reduce the probability of a collision.
This commit is contained in:
@@ -29,11 +29,10 @@
|
||||
|
||||
#include <winpr/thread.h>
|
||||
|
||||
#if defined(__MACOSX__) || defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
@@ -918,14 +917,13 @@ HANDLE _GetCurrentThread(VOID)
|
||||
|
||||
DWORD GetCurrentThreadId(VOID)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__MACOSX__)
|
||||
#if defined(__FreeBSD__)
|
||||
int tid = pthread_getthreadid_np();
|
||||
return tid;
|
||||
#elif defined(__linux__)
|
||||
pid_t tid = syscall(SYS_gettid);
|
||||
return tid;
|
||||
#else
|
||||
#warning Using possibly broken GetCurrentThreadId
|
||||
pthread_t tid = pthread_self();
|
||||
/* Since pthread_t can be 64-bits on some systems, take just the */
|
||||
/* lower 32-bits of it for the thread ID returned by this function. */
|
||||
|
||||
Reference in New Issue
Block a user