Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / disk_cache.h
index 3129de8ec9d15444229b54e437af0bdd00957019..29fb37cea1100f1111fd706cf243288e0f286759 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <sys/stat.h>
+#include "util/mesa-sha1.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -90,7 +91,7 @@ disk_cache_format_hex_id(char *buf, const uint8_t *hex_id, unsigned size)
    return buf;
 }
 
-#ifdef HAVE_DLFCN_H
+#ifdef HAVE_DLADDR
 static inline bool
 disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
 {
@@ -115,18 +116,27 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
 }
 
 static inline bool
-disk_cache_get_function_identifier(void *ptr, uint32_t *id)
+disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx)
 {
+   uint32_t timestamp;
+
 #ifdef HAVE_DL_ITERATE_PHDR
    const struct build_id_note *note = NULL;
    if ((note = build_id_find_nhdr_for_addr(ptr))) {
-      const uint8_t *id_sha1 = build_id_data(note);
-      assert(id_sha1);
-      *id = *id_sha1;
-      return true;
+      _mesa_sha1_update(ctx, build_id_data(note), build_id_length(note));
    } else
 #endif
-   return disk_cache_get_function_timestamp(ptr, id);
+   if (disk_cache_get_function_timestamp(ptr, &timestamp)) {
+      _mesa_sha1_update(ctx, &timestamp, sizeof(timestamp));
+   } else
+      return false;
+   return true;
+}
+#else
+static inline bool
+disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx)
+{
+   return false;
 }
 #endif
 
@@ -170,6 +180,12 @@ disk_cache_create(const char *gpu_name, const char *timestamp,
 void
 disk_cache_destroy(struct disk_cache *cache);
 
+/* Wait for all previous disk_cache_put() calls to be processed (used for unit
+ * testing).
+ */
+void
+disk_cache_wait_for_idle(struct disk_cache *cache);
+
 /**
  * Remove the item in the cache under the name \key.
  */