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 <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 22:15:16 +08:00 committed by Marge Bot
parent 8f9e336aed
commit cf36399459

View file

@ -37,6 +37,7 @@
#include <stdio.h>
#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);
}