util: Make refcnt and symbol debuggers work on windows
authorJakob Bornecrantz <jakob@vmware.com>
Thu, 17 Feb 2011 11:18:02 +0000 (11:18 +0000)
committerJakob Bornecrantz <jakob@vmware.com>
Fri, 18 Feb 2011 14:46:23 +0000 (14:46 +0000)
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
src/gallium/auxiliary/util/u_debug_refcnt.c
src/gallium/auxiliary/util/u_debug_symbol.c

index 40a26c9c6974db6f678517b9bd8fab320960a1cb..6f706a35fda355232bd980c4518c619e408cd0b3 100644 (file)
@@ -43,7 +43,8 @@ int debug_refcnt_state;
 struct os_stream* stream;
 
 /* TODO: maybe move this serial machinery to a stand-alone module and expose it? */
-static pipe_mutex serials_mutex;
+pipe_static_mutex(serials_mutex);
+
 static struct util_hash_table* serials_hash;
 static unsigned serials_last;
 
@@ -66,6 +67,15 @@ static boolean debug_serial(void* p, unsigned* pserial)
 {
    unsigned serial;
    boolean found = TRUE;
+#ifdef PIPE_SUBSYSTEM_WINDOWS_USER
+   static boolean first = TRUE;
+
+   if (first) {
+      pipe_mutex_init(serials_mutex);
+      first = FALSE;
+   }
+#endif
+
    pipe_mutex_lock(serials_mutex);
    if(!serials_hash)
       serials_hash = util_hash_table_create(hash_ptr, compare_ptr);
index cb03930a6702c509aa9b8f4835d7cb3e10193b4f..bae9be87a26df06af274f30e7974a7da2eca3120 100644 (file)
@@ -196,7 +196,7 @@ debug_symbol_print(const void *addr)
 }
 
 struct util_hash_table* symbols_hash;
-pipe_mutex symbols_mutex;
+pipe_static_mutex(symbols_mutex);
 
 static unsigned hash_ptr(void* p)
 {
@@ -217,6 +217,15 @@ const char*
 debug_symbol_name_cached(const void *addr)
 {
    const char* name;
+#ifdef PIPE_SUBSYSTEM_WINDOWS_USER
+   static boolean first = TRUE;
+
+   if (first) {
+      pipe_mutex_init(symbols_mutex);
+      first = FALSE;
+   }
+#endif
+
    pipe_mutex_lock(symbols_mutex);
    if(!symbols_hash)
       symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);