diff options
author | Marek Olšák <marek.olsak@amd.com> | 2016-11-13 16:54:38 +0100 |
---|---|---|
committer | Marek Olšák <marek.olsak@amd.com> | 2016-11-15 20:22:28 +0100 |
commit | a6ff2a3378636f4a261ea32c3dc870b0aeae3c03 (patch) | |
tree | d6cd9dee6c6d2e3c61609521955dd285cdf85825 /src/util | |
parent | 31727300e177b11c2b2b267838b59b090cb605d0 (diff) |
util/disk_cache: use unambiguous naming
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/disk_cache.c | 30 | ||||
-rw-r--r-- | src/util/disk_cache.h | 56 |
2 files changed, 44 insertions, 42 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index 79242aa3c1..428787820e 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -53,7 +53,7 @@ /* The number of keys that can be stored in the index. */ #define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS) -struct program_cache { +struct disk_cache { /* The path to the cache directory. */ char *path; @@ -131,11 +131,11 @@ concatenate_and_mkdir(void *ctx, char *path, char *name) return NULL; } -struct program_cache * -cache_create(void) +struct disk_cache * +disk_cache_create(void) { void *local; - struct program_cache *cache = NULL; + struct disk_cache *cache = NULL; char *path, *max_size_str; uint64_t max_size; int fd = -1; @@ -210,7 +210,7 @@ cache_create(void) goto fail; } - cache = ralloc(NULL, struct program_cache); + cache = ralloc(NULL, struct disk_cache); if (cache == NULL) goto fail; @@ -313,7 +313,7 @@ cache_create(void) } void -cache_destroy(struct program_cache *cache) +disk_cache_destroy(struct disk_cache *cache) { munmap(cache->index_mmap, cache->index_mmap_size); @@ -326,7 +326,7 @@ cache_destroy(struct program_cache *cache) * Returns NULL if out of memory. */ static char * -get_cache_file(struct program_cache *cache, cache_key key) +get_cache_file(struct disk_cache *cache, cache_key key) { char buf[41]; @@ -342,7 +342,7 @@ get_cache_file(struct program_cache *cache, cache_key key) * _get_cache_file above. */ static void -make_cache_file_directory(struct program_cache *cache, cache_key key) +make_cache_file_directory(struct disk_cache *cache, cache_key key) { char *dir; char buf[41]; @@ -484,7 +484,7 @@ is_two_character_sub_directory(struct dirent *entry) } static void -evict_random_item(struct program_cache *cache) +evict_random_item(struct disk_cache *cache) { const char hex[] = "0123456789abcde"; char *dir_path; @@ -531,7 +531,7 @@ evict_random_item(struct program_cache *cache) } void -cache_put(struct program_cache *cache, +disk_cache_put(struct disk_cache *cache, cache_key key, const void *data, size_t size) @@ -628,7 +628,7 @@ cache_put(struct program_cache *cache, } void * -cache_get(struct program_cache *cache, cache_key key, size_t *size) +disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size) { int fd = -1, ret, len; struct stat sb; @@ -679,7 +679,7 @@ cache_get(struct program_cache *cache, cache_key key, size_t *size) } void -cache_put_key(struct program_cache *cache, cache_key key) +disk_cache_put_key(struct disk_cache *cache, cache_key key) { uint32_t *key_chunk = (uint32_t *) key; int i = *key_chunk & CACHE_INDEX_KEY_MASK; @@ -691,14 +691,14 @@ cache_put_key(struct program_cache *cache, cache_key key) } /* This function lets us test whether a given key was previously - * stored in the cache with cache_put_key(). The implement is + * stored in the cache with disk_cache_put_key(). The implement is * efficient by not using syscalls or hitting the disk. It's not * race-free, but the races are benign. If we race with someone else - * calling cache_put_key, then that's just an extra cache miss and an + * calling disk_cache_put_key, then that's just an extra cache miss and an * extra recompile. */ bool -cache_has_key(struct program_cache *cache, cache_key key) +disk_cache_has_key(struct disk_cache *cache, cache_key key) { uint32_t *key_chunk = (uint32_t *) key; int i = *key_chunk & CACHE_INDEX_KEY_MASK; diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h index d4d939883e..7e9cb809b5 100644 --- a/src/util/disk_cache.h +++ b/src/util/disk_cache.h @@ -36,6 +36,8 @@ extern "C" { typedef uint8_t cache_key[CACHE_KEY_SIZE]; +struct disk_cache; + /* Provide inlined stub functions if the shader cache is disabled. */ #ifdef ENABLE_SHADER_CACHE @@ -49,12 +51,12 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE]; * This cache provides two distinct operations: * * o Storage and retrieval of arbitrary objects by cryptographic - * name (or "key"). This is provided via cache_put() and - * cache_get(). + * name (or "key"). This is provided via disk_cache_put() and + * disk_cache_get(). * * o The ability to store a key alone and check later whether the - * key was previously stored. This is provided via cache_put_key() - * and cache_has_key(). + * key was previously stored. This is provided via disk_cache_put_key() + * and disk_cache_has_key(). * * The put_key()/has_key() operations are conceptually identical to * put()/get() with no data, but are provided separately to allow for @@ -66,32 +68,32 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE]; * names are computed). See mesa-sha1.h and _mesa_sha1_compute for * assistance in computing SHA-1 signatures. */ -struct program_cache * -cache_create(void); +struct disk_cache * +disk_cache_create(void); /** * Destroy a cache object, (freeing all associated resources). */ void -cache_destroy(struct program_cache *cache); +disk_cache_destroy(struct disk_cache *cache); /** * Store an item in the cache under the name \key. * - * The item can be retrieved later with cache_get(), (unless the item has + * The item can be retrieved later with disk_cache_get(), (unless the item has * been evicted in the interim). * - * Any call to cache_put() may cause an existing, random item to be + * Any call to disk_cache_put() may cause an existing, random item to be * evicted from the cache. */ void -cache_put(struct program_cache *cache, cache_key key, - const void *data, size_t size); +disk_cache_put(struct disk_cache *cache, cache_key key, + const void *data, size_t size); /** * Retrieve an item previously stored in the cache with the name <key>. * - * The item must have been previously stored with a call to cache_put(). + * The item must have been previously stored with a call to disk_cache_put(). * * If \size is non-NULL, then, on successful return, it will be set to the * size of the object. @@ -102,67 +104,67 @@ cache_put(struct program_cache *cache, cache_key key, * caller should call free() it when finished. */ void * -cache_get(struct program_cache *cache, cache_key key, size_t *size); +disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size); /** * Store the name \key within the cache, (without any associated data). * - * Later this key can be checked with cache_has_key(), (unless the key + * Later this key can be checked with disk_cache_has_key(), (unless the key * has been evicted in the interim). * * Any call to cache_record() may cause an existing, random key to be * evicted from the cache. */ void -cache_put_key(struct program_cache *cache, cache_key key); +disk_cache_put_key(struct disk_cache *cache, cache_key key); /** * Test whether the name \key was previously recorded in the cache. * - * Return value: True if cache_put_key() was previously called with + * Return value: True if disk_cache_put_key() was previously called with * \key, (and the key was not evicted in the interim). * - * Note: cache_has_key() will only return true for keys passed to - * cache_put_key(). Specifically, a call to cache_put() will not cause - * cache_has_key() to return true for the same key. + * Note: disk_cache_has_key() will only return true for keys passed to + * disk_cache_put_key(). Specifically, a call to disk_cache_put() will not cause + * disk_cache_has_key() to return true for the same key. */ bool -cache_has_key(struct program_cache *cache, cache_key key); +disk_cache_has_key(struct disk_cache *cache, cache_key key); #else -static inline struct program_cache * -cache_create(void) +static inline struct disk_cache * +disk_cache_create(void) { return NULL; } static inline void -cache_destroy(struct program_cache *cache) { +disk_cache_destroy(struct disk_cache *cache) { return; } static inline void -cache_put(struct program_cache *cache, cache_key key, +disk_cache_put(struct disk_cache *cache, cache_key key, const void *data, size_t size) { return; } static inline uint8_t * -cache_get(struct program_cache *cache, cache_key key, size_t *size) +disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size) { return NULL; } static inline void -cache_put_key(struct program_cache *cache, cache_key key) +disk_cache_put_key(struct disk_cache *cache, cache_key key) { return; } static inline bool -cache_has_key(struct program_cache *cache, cache_key key) +disk_cache_has_key(struct disk_cache *cache, cache_key key) { return false; } |