mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #11761 from pvachon/master
Clean up bugs exposed on systems with high core counts
This commit is contained in:
@@ -29,6 +29,12 @@
|
||||
|
||||
#include <winpr/thread.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
@@ -911,11 +917,17 @@ HANDLE _GetCurrentThread(VOID)
|
||||
|
||||
DWORD GetCurrentThreadId(VOID)
|
||||
{
|
||||
#if defined(__FreeBSD__)
|
||||
return WINPR_CXX_COMPAT_CAST(DWORD, pthread_getthreadid_np());
|
||||
#elif defined(__linux__)
|
||||
return WINPR_CXX_COMPAT_CAST(DWORD, syscall(SYS_gettid));
|
||||
#else
|
||||
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. */
|
||||
uintptr_t ptid = WINPR_REINTERPRET_CAST(tid, pthread_t, uintptr_t);
|
||||
return ptid & UINT32_MAX;
|
||||
return (ptid & UINT32_MAX) ^ (ptid >> 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
||||
Reference in New Issue
Block a user