mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
a/os: Add a function to set thread name.
This commit is contained in:
parent
147624348f
commit
1e307e8e9f
|
@ -123,6 +123,7 @@ else()
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
target_link_libraries(xrt-pthreads INTERFACE Threads::Threads)
|
target_link_libraries(xrt-pthreads INTERFACE Threads::Threads)
|
||||||
|
target_compile_definitions(xrt-pthreads INTERFACE _GNU_SOURCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PKGCONFIG_FOUND AND NOT ANDROID)
|
if(PKGCONFIG_FOUND AND NOT ANDROID)
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#define OS_THREAD_HAVE_SETNAME
|
||||||
#elif defined(XRT_OS_WINDOWS)
|
#elif defined(XRT_OS_WINDOWS)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#define OS_THREAD_HAVE_SETNAME
|
||||||
#else
|
#else
|
||||||
#error "OS not supported"
|
#error "OS not supported"
|
||||||
#endif
|
#endif
|
||||||
|
@ -201,6 +203,21 @@ static inline void
|
||||||
os_thread_destroy(struct os_thread *ost)
|
os_thread_destroy(struct os_thread *ost)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a best effort to name our thread.
|
||||||
|
*
|
||||||
|
* @public @memberof os_thread
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
os_thread_name(struct os_thread *ost, const char *name)
|
||||||
|
{
|
||||||
|
#ifdef OS_THREAD_HAVE_SETNAME
|
||||||
|
pthread_setname_np(ost->thread, name);
|
||||||
|
#else
|
||||||
|
(void)ost;
|
||||||
|
(void)name;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -517,6 +534,21 @@ os_thread_helper_signal_locked(struct os_thread_helper *oth)
|
||||||
pthread_cond_signal(&oth->cond);
|
pthread_cond_signal(&oth->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a best effort to name our thread.
|
||||||
|
*
|
||||||
|
* @public @memberof os_thread_helper
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
os_thread_helper_name(struct os_thread_helper *oth, const char *name)
|
||||||
|
{
|
||||||
|
#ifdef OS_THREAD_HAVE_SETNAME
|
||||||
|
pthread_setname_np(oth->thread, name);
|
||||||
|
#else
|
||||||
|
(void)oth;
|
||||||
|
(void)name;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @}
|
* @}
|
||||||
|
|
Loading…
Reference in a new issue