mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-10 07:48:19 +02:00
util/thread: Flush traces at thread exit
Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42013>
This commit is contained in:
parent
fd591a9eba
commit
4b8d296e05
1 changed files with 28 additions and 2 deletions
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "util/u_thread.h"
|
||||
#include "util/perf/u_perfetto.h"
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
|
|
@ -44,9 +45,34 @@ util_get_current_cpu(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
struct u_thread_param {
|
||||
int (*routine)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
static int
|
||||
thread_routine(void *arg)
|
||||
{
|
||||
struct u_thread_param *paramp = arg;
|
||||
struct u_thread_param param = *paramp;
|
||||
|
||||
free(paramp);
|
||||
|
||||
int ret = param.routine(param.arg);
|
||||
|
||||
util_perfetto_thread_flush();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int u_thread_create(thrd_t *thrd, int (*routine)(void *), void *param)
|
||||
{
|
||||
struct u_thread_param *paramp = malloc(sizeof(*paramp));
|
||||
int ret = thrd_error;
|
||||
|
||||
paramp->routine = routine;
|
||||
paramp->arg = param;
|
||||
|
||||
#if defined(HAVE_PTHREAD) && !DETECT_OS_FUCHIA
|
||||
sigset_t saved_set, new_set;
|
||||
|
||||
|
|
@ -59,10 +85,10 @@ int u_thread_create(thrd_t *thrd, int (*routine)(void *), void *param)
|
|||
*/
|
||||
sigdelset(&new_set, SIGSEGV);
|
||||
pthread_sigmask(SIG_BLOCK, &new_set, &saved_set);
|
||||
ret = thrd_create(thrd, routine, param);
|
||||
ret = thrd_create(thrd, thread_routine, paramp);
|
||||
pthread_sigmask(SIG_SETMASK, &saved_set, NULL);
|
||||
#else
|
||||
ret = thrd_create(thrd, routine, param);
|
||||
ret = thrd_create(thrd, thread_routine, paramp);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue