mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
mapi/u_thread: Use GetCurrentThreadId
u_thread_self() expects thrd_current() to return a unique numeric ID
for the current thread, but this is not feasible on Windows.
Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit e8d85034da)
This commit is contained in:
parent
30274cf36c
commit
34e8881ac7
1 changed files with 18 additions and 0 deletions
|
|
@ -89,10 +89,28 @@ typedef mtx_t u_mutex;
|
||||||
#define u_mutex_lock(name) (void) mtx_lock(&(name))
|
#define u_mutex_lock(name) (void) mtx_lock(&(name))
|
||||||
#define u_mutex_unlock(name) (void) mtx_unlock(&(name))
|
#define u_mutex_unlock(name) (void) mtx_unlock(&(name))
|
||||||
|
|
||||||
|
|
||||||
static INLINE unsigned long
|
static INLINE unsigned long
|
||||||
u_thread_self(void)
|
u_thread_self(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* XXX: Callers of u_thread_self assume it is a lightweight function,
|
||||||
|
* returning a numeric value. But unfortunately C11's thrd_current() gives
|
||||||
|
* no such guarantees. In fact, it's pretty hard to have a compliant
|
||||||
|
* implementation of thrd_current() on Windows with such characteristics.
|
||||||
|
* So for now, we side-step this mess and use Windows thread primitives
|
||||||
|
* directly here.
|
||||||
|
*
|
||||||
|
* FIXME: On the other hand, u_thread_self() and _glthread_GetID() are bad
|
||||||
|
* abstractions. Even with pthreads, there is no guarantee that
|
||||||
|
* pthread_self() will return numeric IDs -- we should be using
|
||||||
|
* pthread_equal() instead of assuming we can compare thread ids...
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
return GetCurrentThreadId();
|
||||||
|
#else
|
||||||
return (unsigned long) (uintptr_t) thrd_current();
|
return (unsigned long) (uintptr_t) thrd_current();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue