summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/disk_cache.h17
1 files changed, 17 insertions, 0 deletions
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 <dlfcn.h>
#include <stdint.h>
#include <stdbool.h>
+#include <sys/stat.h>
#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