From 207e3a6e4b6d70a965f2852204c35ccf42fe3533 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 10 Feb 2017 13:02:22 +1100 Subject: util/radv: move *_get_function_timestamp() to utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/util/disk_cache.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/util') 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 -- cgit v1.2.3