[Mesa-dev] [PATCH V2] util/disk_cache: support caches for multiple architectures

Emil Velikov emil.l.velikov at gmail.com
Sat Mar 4 14:44:01 UTC 2017


On 3 March 2017 at 23:37, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> On 03/03/17 23:27, Grazvydas Ignotas wrote:
>>
>> On Fri, Mar 3, 2017 at 5:27 AM, Timothy Arceri <tarceri at itsqueeze.com>
>> wrote:
>>>
>>> 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.
>>> ---
>>>  src/util/disk_cache.c | 19 +++++++++++++++++++
>>>  1 file changed, 19 insertions(+)
>>>
>>> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
>>> index 3abdec4..92528a9 100644
>>> --- a/src/util/disk_cache.c
>>> +++ b/src/util/disk_cache.c
>>> @@ -40,20 +40,30 @@
>>>  #include "zlib.h"
>>>
>>>  #include "util/crc32.h"
>>>  #include "util/u_atomic.h"
>>>  #include "util/mesa-sha1.h"
>>>  #include "util/ralloc.h"
>>>  #include "main/errors.h"
>>>
>>>  #include "disk_cache.h"
>>>
>>> +#if defined(__ILP32__)
>>> +#if defined(__x86_64__) || defined(__arm__)
>>> +#define CACHE_ARCH "ilp-32"
>>> +#else
>>> +#define CACHE_ARCH "32"
>>> +#endif
>>> +#else
>>> +#define CACHE_ARCH "64"
>>> +#endif
>>
>>
>> That reports "64" for me on gcc -m32, I think only clang sets
>> __ILP32__ for non-x32 32bit build.
>
>
> Well that's annoying.
>
>> I'd still suggest using sizeof(void
>> *) directly in the code, perhaps within some "const char
>> *get_arch_bitness_string()" helper, that should be more reliable.
>
>
> I'm tempted to just push this:
> https://patchwork.freedesktop.org/patch/141891/
>
> And worry about issues later if that's not good enough.
>
Can we use anything like the following and polish later ? We already
use __ILP32__ in mesa so we can assume the compiler is sane.
This has the benefit of a) no build system glue, b) no special casing
for arches - 64bit ppc/sparc/others anyone ?

const char *
get_arch_bitness_string(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";
}


Thanks
Emil


More information about the mesa-dev mailing list