[Mesa-dev] [PATCH 43/88] glsl: add a cache_remove() function
Timothy Arceri
timothy.arceri at collabora.com
Sat Sep 24 05:25:24 UTC 2016
This will be used to remove cache items created with an old version
of Mesa from the cache.
---
src/compiler/glsl/cache.c | 22 ++++++++++++++++++++++
src/compiler/glsl/cache.h | 12 ++++++++++++
2 files changed, 34 insertions(+)
diff --git a/src/compiler/glsl/cache.c b/src/compiler/glsl/cache.c
index 22c4ee1..a6a9e47 100644
--- a/src/compiler/glsl/cache.c
+++ b/src/compiler/glsl/cache.c
@@ -537,6 +537,28 @@ evict_random_item(struct program_cache *cache)
}
void
+cache_remove(struct program_cache *cache, cache_key key)
+{
+ struct stat sb;
+
+ char *filename = get_cache_file(cache, key);
+ if (filename == NULL) {
+ return;
+ }
+
+ if (stat(filename, &sb) == -1) {
+ ralloc_free(filename);
+ return;
+ }
+
+ unlink(filename);
+ ralloc_free(filename);
+
+ if (sb.st_size)
+ p_atomic_add(cache->size, - sb.st_size);
+}
+
+void
cache_put(struct program_cache *cache,
cache_key key,
const void *data,
diff --git a/src/compiler/glsl/cache.h b/src/compiler/glsl/cache.h
index 78df32b..e6d04bf 100644
--- a/src/compiler/glsl/cache.h
+++ b/src/compiler/glsl/cache.h
@@ -77,6 +77,12 @@ void
cache_destroy(struct program_cache *cache);
/**
+ * Remove the item in the cache under the name \key.
+ */
+void
+cache_remove(struct program_cache *cache, cache_key key);
+
+/**
* Store an item in the cache under the name \key.
*
* The item can be retrieved later with cache_get(), (unless the item has
@@ -145,6 +151,12 @@ cache_put(struct program_cache *cache, cache_key key,
return;
}
+static inline void
+cache_remove(struct program_cache *cache, cache_key key)
+{
+ return;
+}
+
static inline uint8_t *
cache_get(struct program_cache *cache, cache_key key, size_t *size)
{
--
2.7.4
More information about the mesa-dev
mailing list