<div dir="auto">Hi Tim, one comment below<div dir="auto"><br></div><div dir="auto">BR</div><div dir="auto">Nils<br><div dir="auto"><br><div class="gmail_extra"><br><div class="gmail_quote">Den 10 feb. 2017 3:03 fm skrev "Timothy Arceri" <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
src/amd/vulkan/radv_device.c | 22 +++-------------------<br>
src/intel/vulkan/anv_device.c | 20 ++------------------<br>
src/util/disk_cache.h | 17 +++++++++++++++++<br>
3 files changed, 22 insertions(+), 37 deletions(-)<br>
<br>
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c<br>
index 8a54a2a..b5a3435 100644<br>
--- a/src/amd/vulkan/radv_device.c<br>
+++ b/src/amd/vulkan/radv_device.c<br>
@@ -25,14 +25,13 @@<br>
* IN THE SOFTWARE.<br>
*/<br>
<br>
-#include <dlfcn.h><br>
#include <stdbool.h><br>
#include <string.h><br>
#include <unistd.h><br>
#include <fcntl.h><br>
-#include <sys/stat.h><br>
#include "radv_private.h"<br>
#include "radv_cs.h"<br>
+#include "util/disk_cache.h"<br>
#include "util/strtod.h"<br>
<br>
#include <xf86drm.h><br>
@@ -47,28 +46,13 @@<br>
struct radv_dispatch_table dtable;<br>
<br>
static int<br>
-radv_get_function_timestamp(<wbr>void *ptr, uint32_t* timestamp)<br>
-{<br>
- Dl_info info;<br>
- struct stat st;<br>
- if (!dladdr(ptr, &info) || !info.dli_fname) {<br>
- return -1;<br>
- }<br>
- if (stat(info.dli_fname, &st)) {<br>
- return -1;<br>
- }<br>
- *timestamp = st.st_mtim.tv_sec;<br>
- return 0;<br>
-}<br>
-<br>
-static int<br>
radv_device_get_cache_uuid(<wbr>enum radeon_family family, void *uuid)<br>
{<br>
uint32_t mesa_timestamp, llvm_timestamp;<br>
uint16_t f = family;<br>
memset(uuid, 0, VK_UUID_SIZE);<br>
- if (radv_get_function_timestamp(<wbr>radv_device_get_cache_uuid, &mesa_timestamp) ||<br>
- radv_get_function_timestamp(<wbr>LLVMInitializeAMDGPUTargetInfo<wbr>, &llvm_timestamp))<br>
+ if (disk_cache_get_function_<wbr>timestamp(radv_device_get_<wbr>cache_uuid, &mesa_timestamp) ||<br>
+ disk_cache_get_function_<wbr>timestamp(<wbr>LLVMInitializeAMDGPUTargetInfo<wbr>, &llvm_timestamp))<br>
return -1;<br>
<br>
memcpy(uuid, &mesa_timestamp, 4);<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index 91ee67f..607fc4f 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -21,18 +21,17 @@<br>
* IN THE SOFTWARE.<br>
*/<br>
<br>
-#include <dlfcn.h><br>
#include <assert.h><br>
#include <stdbool.h><br>
#include <string.h><br>
#include <sys/mman.h><br>
-#include <sys/stat.h><br>
#include <unistd.h><br>
#include <fcntl.h><br>
<br>
#include "anv_private.h"<br>
#include "util/strtod.h"<br>
#include "util/debug.h"<br>
+#include "util/disk_cache.h"<br>
<br>
#include "genxml/gen7_pack.h"<br>
<br>
@@ -55,27 +54,12 @@ compiler_perf_log(void *data, const char *fmt, ...)<br>
}<br>
<br>
static bool<br>
-anv_get_function_timestamp(<wbr>void *ptr, uint32_t* timestamp)<br>
-{<br>
- Dl_info info;<br>
- struct stat st;<br>
- if (!dladdr(ptr, &info) || !info.dli_fname)<br>
- return false;<br>
-<br>
- if (stat(info.dli_fname, &st))<br>
- return false;<br>
-<br>
- *timestamp = st.st_mtim.tv_sec;<br>
- return true;<br>
-}<br>
-<br>
-static bool<br>
anv_device_get_cache_uuid(void *uuid)<br>
{<br>
uint32_t timestamp;<br>
<br>
memset(uuid, 0, VK_UUID_SIZE);<br>
- if (!anv_get_function_timestamp(<wbr>anv_device_get_cache_uuid, ×tamp))<br>
+ if (!disk_cache_get_function_<wbr>timestamp(anv_device_get_<wbr>cache_uuid, ×tamp))<br></blockquote></div></div></div></div><div dir="auto"><br></div><div dir="auto">The utility function has reversed return status compared to the removed and version so this condition should be flipped as well.</div><div dir="auto"><br></div><div dir="auto"><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
return false;<br>
<br>
snprintf(uuid, VK_UUID_SIZE, "anv-%d", timestamp);<br>
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h<br>
index 4ff1da5..6fbc07b 100644<br>
--- a/src/util/disk_cache.h<br>
+++ b/src/util/disk_cache.h<br>
@@ -24,8 +24,10 @@<br>
#ifndef DISK_CACHE_H<br>
#define DISK_CACHE_H<br>
<br>
+#include <dlfcn.h><br>
#include <stdint.h><br>
#include <stdbool.h><br>
+#include <sys/stat.h><br>
<br>
#ifdef __cplusplus<br>
extern "C" {<br>
@@ -133,6 +135,21 @@ disk_cache_put_key(struct disk_cache *cache, cache_key key);<br>
bool<br>
disk_cache_has_key(struct disk_cache *cache, cache_key key);<br>
<br>
+static inline int<br>
+disk_cache_get_function_<wbr>timestamp(void *ptr, uint32_t* timestamp)<br>
+{<br>
+ Dl_info info;<br>
+ struct stat st;<br>
+ if (!dladdr(ptr, &info) || !info.dli_fname) {<br>
+ return -1;<br>
+ }<br>
+ if (stat(info.dli_fname, &st)) {<br>
+ return -1;<br>
+ }<br>
+ *timestamp = st.st_mtim.tv_sec;<br>
+ return 0;<br>
+}<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
<font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br></div></div></div></div>