gallium: add PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY
[mesa.git] / src / gallium / auxiliary / util / u_debug_symbol.c
index 4b555238644fd16b9b5f9b5135df3c01cbfc2831..334803d008ee67fa2e6dd59db8cafd0325a75098 100644 (file)
@@ -36,7 +36,7 @@
 #include "os/os_thread.h"
 #include "util/u_string.h"
 
-#include "u_debug.h"
+#include "util/u_debug.h"
 #include "u_debug_symbol.h"
 #include "u_hash_table.h"
 
@@ -191,9 +191,9 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size)
       if (GetModuleFileNameA(hModule, buffer, sizeof buffer) == sizeof buffer) {
          return FALSE;
       }
-      util_snprintf(buf, size, "%p at %s+0x%lx",
-                    addr, buffer,
-                    (unsigned long)((uintptr_t)addr - (uintptr_t)hModule));
+      snprintf(buf, size, "%p at %s+0x%lx",
+               addr, buffer,
+               (unsigned long)((uintptr_t)addr - (uintptr_t)hModule));
 
       return TRUE;
    }
@@ -208,9 +208,9 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size)
    }
 
    if (Line.FileName) {
-      util_snprintf(buf, size, "%s at %s:%lu", pSymbol->Name, Line.FileName, Line.LineNumber);
+      snprintf(buf, size, "%s at %s:%lu", pSymbol->Name, Line.FileName, Line.LineNumber);
    } else {
-      util_snprintf(buf, size, "%s", pSymbol->Name);
+      snprintf(buf, size, "%s", pSymbol->Name);
    }
 
    return TRUE;
@@ -219,7 +219,7 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size)
 #endif /* PIPE_OS_WINDOWS */
 
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
+#if defined(HAVE_EXECINFO_H)
 
 #include <execinfo.h>
 
@@ -234,13 +234,13 @@ debug_symbol_name_glibc(const void *addr, char* buf, unsigned size)
    if (!syms) {
       return FALSE;
    }
-   strncpy(buf, syms[0], size);
+   strncpy(buf, syms[0], size - 1);
    buf[size - 1] = 0;
    free(syms);
    return TRUE;
 }
 
-#endif /* defined(__GLIBC__) && !defined(__UCLIBC__) */
+#endif /* defined(HAVE_EXECINFO_H) */
 
 
 void
@@ -252,13 +252,13 @@ debug_symbol_name(const void *addr, char* buf, unsigned size)
    }
 #endif
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
+#if defined(HAVE_EXECINFO_H)
    if (debug_symbol_name_glibc(addr, buf, size)) {
        return;
    }
-#endif
+#endif /* defined(HAVE_EXECINFO_H) */
 
-   util_snprintf(buf, size, "%p", addr);
+   snprintf(buf, size, "%p", addr);
    buf[size - 1] = 0;
 }
 
@@ -270,29 +270,14 @@ debug_symbol_print(const void *addr)
    debug_printf("\t%s\n", buf);
 }
 
-struct util_hash_table* symbols_hash;
+struct hash_table* symbols_hash;
 static mtx_t symbols_mutex = _MTX_INITIALIZER_NP;
 
-static unsigned hash_ptr(void* p)
-{
-   return (unsigned)(uintptr_t)p;
-}
-
-static int compare_ptr(void* a, void* b)
-{
-   if(a == b)
-      return 0;
-   else if(a < b)
-      return -1;
-   else
-      return 1;
-}
-
 const char*
 debug_symbol_name_cached(const void *addr)
 {
    const char* name;
-#ifdef PIPE_SUBSYSTEM_WINDOWS_USER
+#ifdef PIPE_OS_WINDOWS
    static boolean first = TRUE;
 
    if (first) {
@@ -303,7 +288,7 @@ debug_symbol_name_cached(const void *addr)
 
    mtx_lock(&symbols_mutex);
    if(!symbols_hash)
-      symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);
+      symbols_hash = util_hash_table_create_ptr_keys();
    name = util_hash_table_get(symbols_hash, (void*)addr);
    if(!name)
    {
@@ -311,7 +296,7 @@ debug_symbol_name_cached(const void *addr)
       debug_symbol_name(addr, buf, sizeof(buf));
       name = strdup(buf);
 
-      util_hash_table_set(symbols_hash, (void*)addr, (void*)name);
+      _mesa_hash_table_insert(symbols_hash, (void*)addr, (void*)name);
    }
    mtx_unlock(&symbols_mutex);
    return name;