[Mesa-dev] [PATCH 5/8] util/disk_cache: move disk_cache declaration to the header

Timothy Arceri tarceri at itsqueeze.com
Fri Mar 10 02:28:52 UTC 2017


This will allow use to access members outside if the disk cache util.
---
 src/util/disk_cache.c | 21 ---------------------
 src/util/disk_cache.h | 21 ++++++++++++++++++++-
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index e0b540c..d3dcb1b 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -49,41 +49,20 @@
 
 /* Number of bits to mask off from a cache key to get an index. */
 #define CACHE_INDEX_KEY_BITS 16
 
 /* Mask for computing an index from a key. */
 #define CACHE_INDEX_KEY_MASK ((1 << CACHE_INDEX_KEY_BITS) - 1)
 
 /* The number of keys that can be stored in the index. */
 #define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
 
-struct disk_cache {
-   /* The path to the cache directory. */
-   char *path;
-
-   /* Thread queue for compressing and writing cache entries to disk */
-   struct util_queue cache_queue;
-
-   /* A pointer to the mmapped index file within the cache directory. */
-   uint8_t *index_mmap;
-   size_t index_mmap_size;
-
-   /* Pointer to total size of all objects in cache (within index_mmap) */
-   uint64_t *size;
-
-   /* Pointer to stored keys, (within index_mmap). */
-   uint8_t *stored_keys;
-
-   /* Maximum size of all cached objects (in bytes). */
-   uint64_t max_size;
-};
-
 /* Create a directory named 'path' if it does not already exist.
  *
  * Returns: 0 if path already exists as a directory or if created.
  *         -1 in all other cases.
  */
 static int
 mkdir_if_needed(const char *path)
 {
    struct stat sb;
 
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 19eb1a9..d1e1ab0 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -36,21 +36,40 @@
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* Size of cache keys in bytes. */
 #define CACHE_KEY_SIZE 20
 
 typedef uint8_t cache_key[CACHE_KEY_SIZE];
 
-struct disk_cache;
+struct disk_cache {
+   /* The path to the cache directory. */
+   char *path;
+
+   /* Thread queue for compressing and writing cache entries to disk */
+   struct util_queue cache_queue;
+
+   /* A pointer to the mmapped index file within the cache directory. */
+   uint8_t *index_mmap;
+   size_t index_mmap_size;
+
+   /* Pointer to total size of all objects in cache (within index_mmap) */
+   uint64_t *size;
+
+   /* Pointer to stored keys, (within index_mmap). */
+   uint8_t *stored_keys;
+
+   /* Maximum size of all cached objects (in bytes). */
+   uint64_t max_size;
+};
 
 struct disk_cache_put_job {
    struct util_queue_fence fence;
 
    struct disk_cache *cache;
 
    cache_key key;
 
    /* Cache data to be compressed and written. */
    const void *data;
-- 
2.9.3



More information about the mesa-dev mailing list