From a26d5b4b69d892e854750a08673a9ba29257ece4 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 6 Sep 2022 22:09:05 +0800 Subject: [PATCH] util: Remove the need of _MTX_INITIALIZER_NP by using simple_mtx_t/SIMPLE_MTX_INITIALIZER in u_debug_symbol.c Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/util/u_debug_symbol.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/util/u_debug_symbol.c b/src/util/u_debug_symbol.c index a006910..21b738d 100644 --- a/src/util/u_debug_symbol.c +++ b/src/util/u_debug_symbol.c @@ -34,6 +34,7 @@ #include "pipe/p_compiler.h" #include "os/os_thread.h" +#include "util/simple_mtx.h" #include "util/u_string.h" #include "util/u_debug.h" @@ -250,26 +251,13 @@ debug_symbol_print(const void *addr) } static struct hash_table* symbols_hash; -#ifdef PIPE_OS_WINDOWS -static mtx_t symbols_mutex; -#else -static mtx_t symbols_mutex = _MTX_INITIALIZER_NP; -#endif +static simple_mtx_t symbols_mutex = SIMPLE_MTX_INITIALIZER; const char* debug_symbol_name_cached(const void *addr) { const char* name; -#ifdef PIPE_OS_WINDOWS - static boolean first = TRUE; - - if (first) { - (void) mtx_init(&symbols_mutex, mtx_plain); - first = FALSE; - } -#endif - - mtx_lock(&symbols_mutex); + simple_mtx_lock(&symbols_mutex); if(!symbols_hash) symbols_hash = _mesa_pointer_hash_table_create(NULL); struct hash_entry *entry = _mesa_hash_table_search(symbols_hash, addr); @@ -280,6 +268,6 @@ debug_symbol_name_cached(const void *addr) entry = _mesa_hash_table_insert(symbols_hash, addr, (void*)name); } - mtx_unlock(&symbols_mutex); + simple_mtx_unlock(&symbols_mutex); return entry->data; } -- 2.7.4