mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
util/disk_cache: support caches for multiple architectures
Previously we were deleting the entire cache if a user switched between 32 and 64 bit applications. V2: make the check more generic, it should now work with any platform we are likely to support. V3: Use suggestion from Emil to make even more generic/fix issue with __ILP32__ not being declared on gcc for regular 32-bit builds. Tested-by: Grazvydas Ignotas <notasas@gmail.com> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
This commit is contained in:
parent
175d4aa8f5
commit
11f0efec2e
1 changed files with 26 additions and 0 deletions
|
|
@ -74,6 +74,23 @@ struct disk_cache {
|
||||||
uint64_t max_size;
|
uint64_t max_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_arch_bitness_str(void)
|
||||||
|
{
|
||||||
|
if (sizeof(void *) == 4)
|
||||||
|
#ifdef __ILP32__
|
||||||
|
return "ilp-32";
|
||||||
|
#else
|
||||||
|
return "32";
|
||||||
|
#endif
|
||||||
|
if (sizeof(void *) == 8)
|
||||||
|
return "64";
|
||||||
|
|
||||||
|
/* paranoia check which will be dropped by the optimiser */
|
||||||
|
assert(!"unknown_arch");
|
||||||
|
return "unknown_arch";
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a directory named 'path' if it does not already exist.
|
/* Create a directory named 'path' if it does not already exist.
|
||||||
*
|
*
|
||||||
* Returns: 0 if path already exists as a directory or if created.
|
* Returns: 0 if path already exists as a directory or if created.
|
||||||
|
|
@ -178,6 +195,15 @@ create_mesa_cache_dir(void *mem_ctx, const char *path, const char *timestamp,
|
||||||
if (new_path == NULL)
|
if (new_path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Create a parent architecture directory so that we don't remove cache
|
||||||
|
* files for other architectures. In theory we could share the cache
|
||||||
|
* between architectures but we have no way of knowing if they were created
|
||||||
|
* by a compatible Mesa version.
|
||||||
|
*/
|
||||||
|
new_path = concatenate_and_mkdir(mem_ctx, new_path, get_arch_bitness_str());
|
||||||
|
if (new_path == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Remove cache directories for old Mesa versions */
|
/* Remove cache directories for old Mesa versions */
|
||||||
remove_old_cache_directories(mem_ctx, new_path, timestamp);
|
remove_old_cache_directories(mem_ctx, new_path, timestamp);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue