gallium/auxiliary: Remove the need of _MTX_INITIALIZER_NP by using simple_mtx_t/SIMPLE_MTX_INITIALIZER

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19154>
This commit is contained in:
Yonggang Luo
2022-09-06 23:02:41 +08:00
committed by Marge Bot
parent ccf6dfedbc
commit 81ef38f484
2 changed files with 20 additions and 18 deletions
+14 -13
View File
@@ -51,6 +51,7 @@
#include "pipe/p_compiler.h"
#include "os/os_thread.h"
#include "util/os_time.h"
#include "util/simple_mtx.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
@@ -65,7 +66,7 @@
static bool close_stream = false;
static FILE *stream = NULL;
static mtx_t call_mutex = _MTX_INITIALIZER_NP;
static simple_mtx_t call_mutex = SIMPLE_MTX_INITIALIZER;
static long unsigned call_no = 0;
static bool dumping = false;
static long nir_count = 0;
@@ -85,7 +86,7 @@ trace_dump_check_trigger(void)
if (!trigger_filename)
return;
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
if (trigger_active) {
trigger_active = false;
} else {
@@ -98,7 +99,7 @@ trace_dump_check_trigger(void)
}
}
}
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
}
bool
@@ -304,12 +305,12 @@ bool trace_dump_trace_enabled(void)
void trace_dump_call_lock(void)
{
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
}
void trace_dump_call_unlock(void)
{
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
}
/*
@@ -333,24 +334,24 @@ bool trace_dumping_enabled_locked(void)
void trace_dumping_start(void)
{
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
trace_dumping_start_locked();
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
}
void trace_dumping_stop(void)
{
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
trace_dumping_stop_locked();
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
}
bool trace_dumping_enabled(void)
{
bool ret;
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
ret = trace_dumping_enabled_locked();
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
return ret;
}
@@ -397,14 +398,14 @@ void trace_dump_call_end_locked(void)
void trace_dump_call_begin(const char *klass, const char *method)
{
mtx_lock(&call_mutex);
simple_mtx_lock(&call_mutex);
trace_dump_call_begin_locked(klass, method);
}
void trace_dump_call_end(void)
{
trace_dump_call_end_locked();
mtx_unlock(&call_mutex);
simple_mtx_unlock(&call_mutex);
}
void trace_dump_arg_begin(const char *name)
+6 -5
View File
@@ -39,6 +39,7 @@
#ifdef DEBUG
#include "pipe/p_compiler.h"
#include "util/simple_mtx.h"
#include "util/u_debug_stack.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
@@ -86,7 +87,7 @@ struct debug_flush_ctx {
struct list_head head;
};
static mtx_t list_mutex = _MTX_INITIALIZER_NP;
static simple_mtx_t list_mutex = SIMPLE_MTX_INITIALIZER;
static struct list_head ctx_list = {&ctx_list, &ctx_list};
static struct debug_stack_frame *
@@ -165,9 +166,9 @@ debug_flush_ctx_create(UNUSED boolean catch_reference_of_mapped,
goto out_no_ref_hash;
fctx->bt_depth = bt_depth;
mtx_lock(&list_mutex);
simple_mtx_lock(&list_mutex);
list_addtail(&fctx->head, &ctx_list);
mtx_unlock(&list_mutex);
simple_mtx_unlock(&list_mutex);
return fctx;
@@ -247,7 +248,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
if (!persistent) {
struct debug_flush_ctx *fctx;
mtx_lock(&list_mutex);
simple_mtx_lock(&list_mutex);
LIST_FOR_EACH_ENTRY(fctx, &ctx_list, head) {
struct debug_flush_item *item =
util_hash_table_get(fctx->ref_hash, fbuf);
@@ -259,7 +260,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
FALSE, FALSE, item->ref_frame);
}
}
mtx_unlock(&list_mutex);
simple_mtx_unlock(&list_mutex);
}
}