From cf36399459956d7451441cb633616b2850779e91 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 6 Sep 2022 22:15:16 +0800 Subject: [PATCH] util: Remove the need of _MTX_INITIALIZER_NP by using simple_mtx_t/SIMPLE_M in u_debug_refcnt.c Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/util/u_debug_refcnt.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/util/u_debug_refcnt.c b/src/util/u_debug_refcnt.c index 566fb9cc51c..6b8edf9ba65 100644 --- a/src/util/u_debug_refcnt.c +++ b/src/util/u_debug_refcnt.c @@ -37,6 +37,7 @@ #include +#include "util/simple_mtx.h" #include "util/u_debug.h" #include "util/u_debug_refcnt.h" #include "util/u_debug_stack.h" @@ -52,12 +53,8 @@ static FILE *stream; /* TODO: maybe move this serial machinery to a stand-alone module and * expose it? */ -#ifdef PIPE_OS_WINDOWS -static mtx_t serials_mutex; -#else -static mtx_t serials_mutex = _MTX_INITIALIZER_NP; -#endif +static simple_mtx_t serials_mutex = SIMPLE_MTX_INITIALIZER; static struct hash_table *serials_hash; static unsigned serials_last; @@ -70,16 +67,8 @@ debug_serial(void *p, unsigned *pserial) { unsigned serial; boolean found = TRUE; -#ifdef PIPE_OS_WINDOWS - static boolean first = TRUE; - if (first) { - (void) mtx_init(&serials_mutex, mtx_plain); - first = FALSE; - } -#endif - - mtx_lock(&serials_mutex); + simple_mtx_lock(&serials_mutex); if (!serials_hash) serials_hash = util_hash_table_create_ptr_keys(); @@ -97,7 +86,7 @@ debug_serial(void *p, unsigned *pserial) _mesa_hash_table_insert(serials_hash, p, (void *) (uintptr_t) serial); found = FALSE; } - mtx_unlock(&serials_mutex); + simple_mtx_unlock(&serials_mutex); *pserial = serial; @@ -111,9 +100,9 @@ debug_serial(void *p, unsigned *pserial) static void debug_serial_delete(void *p) { - mtx_lock(&serials_mutex); + simple_mtx_lock(&serials_mutex); _mesa_hash_table_remove_key(serials_hash, p); - mtx_unlock(&serials_mutex); + simple_mtx_unlock(&serials_mutex); }