summaryrefslogtreecommitdiffstats
path: root/src/util/disk_cache.h
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-02-10 13:02:22 +1100
committerTimothy Arceri <[email protected]>2017-02-22 08:40:00 +1100
commit207e3a6e4b6d70a965f2852204c35ccf42fe3533 (patch)
treefc7a5a92f2844a355f1558f0a6afe0af9abaec28 /src/util/disk_cache.h
parented6b47f435d902a26a4c572d4aced7d4a720b6f3 (diff)
util/radv: move *_get_function_timestamp() to utils
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/util/disk_cache.h')
-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