From 207e3a6e4b6d70a965f2852204c35ccf42fe3533 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 10 Feb 2017 13:02:22 +1100 Subject: [PATCH] util/radv: move *_get_function_timestamp() to utils MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/amd/vulkan/radv_device.c | 22 +++------------------- src/util/disk_cache.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 783ab12760f..7b8132989c5 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -25,14 +25,13 @@ * IN THE SOFTWARE. */ -#include #include #include #include #include -#include #include "radv_private.h" #include "radv_cs.h" +#include "util/disk_cache.h" #include "util/strtod.h" #include @@ -45,29 +44,14 @@ #include "sid.h" #include "util/debug.h" -static int -radv_get_function_timestamp(void *ptr, uint32_t* timestamp) -{ - Dl_info info; - struct stat st; - if (!dladdr(ptr, &info) || !info.dli_fname) { - return -1; - } - if (stat(info.dli_fname, &st)) { - return -1; - } - *timestamp = st.st_mtim.tv_sec; - return 0; -} - static int radv_device_get_cache_uuid(enum radeon_family family, void *uuid) { uint32_t mesa_timestamp, llvm_timestamp; uint16_t f = family; memset(uuid, 0, VK_UUID_SIZE); - if (radv_get_function_timestamp(radv_device_get_cache_uuid, &mesa_timestamp) || - radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp)) + if (!disk_cache_get_function_timestamp(radv_device_get_cache_uuid, &mesa_timestamp) || + !disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp)) return -1; memcpy(uuid, &mesa_timestamp, 4); diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h index 7c15aa180de..8b6fc0ddcbf 100644 --- a/src/util/disk_cache.h +++ b/src/util/disk_cache.h @@ -24,8 +24,10 @@ #ifndef DISK_CACHE_H #define DISK_CACHE_H +#include #include #include +#include #ifdef __cplusplus extern "C" { @@ -38,6 +40,21 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE]; struct disk_cache; +static inline bool +disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp) +{ + Dl_info info; + struct stat st; + if (!dladdr(ptr, &info) || !info.dli_fname) { + return false; + } + if (stat(info.dli_fname, &st)) { + return false; + } + *timestamp = st.st_mtim.tv_sec; + return true; +} + /* Provide inlined stub functions if the shader cache is disabled. */ #ifdef ENABLE_SHADER_CACHE -- 2.30.2