[Mesa-dev] [PATCH] mesa: Fix test for big-endian architecture in compiler.h
Jochen Rollwagen
joro-2013 at t-online.de
Mon Feb 15 18:33:38 UTC 2016
Am 15.02.2016 um 15:53 schrieb Oded Gabbay:
> Sent with MailTrack
>
> On Sat, Feb 13, 2016 at 2:39 AM, Roland Scheidegger <sroland at vmware.com> wrote:
>> Am 12.02.2016 um 10:01 schrieb Jochen Rollwagen:
>>> Hi,
>>>
>>> i think i found & fixed a bug in mesa concerning tests for big-endian
>>> machines. The defines tested don't exist or are wrongly defined so the
>>> test (probably) never fires. The gcc defines on my machine concerning
>>> big-endian are
>>>
>>> jochen at mac-mini:~/sources/mesa$ gcc -dM -E - < /dev/null | grep BIG
>>> #define __BIGGEST_ALIGNMENT__ 16
>>> #define __BIG_ENDIAN__ 1
>>> #define __FLOAT_WORD_ORDER__ __ORDER_BIG_ENDIAN__
>>> #define _BIG_ENDIAN 1
>>> #define __ORDER_BIG_ENDIAN__ 4321
>>> #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
>>>
>>> The tested values in current mesa are quite different :-)
>>>
>>> The following patch fixes this.
>>>
>>> diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
>>> index c5ee741..99c63cb 100644
>>> --- a/src/mesa/main/compiler.h
>>> +++ b/src/mesa/main/compiler.h
>>> @@ -52,7 +52,7 @@ extern "C" {
>>> * Try to use a runtime test instead.
>>> * For now, only used by some DRI hardware drivers for color/texel
>>> packing.
>>> */
>>> -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
>>> +#if defined(__BYTE_ORDER__) && defined(__BIG_ENDIAN__) &&
>>> __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
>>> #if defined(__linux__)
>>> #include <byteswap.h>
>>> #define CPU_TO_LE32( x ) bswap_32( x )
>>>
>> Note that on some platforms this file would include endian.h - which
>> defines those BYTE_ORDER etc. values. Albeit it includes this _after_
>> these ifdefs...
>> But don't ask me how this is really supposed to work...
>>
>> Roland
> <stdlib.h> includes <bits/waitstatus.h> which includes <endian.h>
>
> However, this depends on the c/h files to include <stdlib.h> before
> including "compiler.h", which doesn't always happen (e.g
> dummy_errors.c) and it is a very fragile situation.
>
> So I think this is a good fix and this patch is:
> Reviewed-by: Oded Gabbay <oded.gabbay at gmail.com>
>
> Jochen,
>
> Note that I downloaded this patch from pw and it was malformed. I
> don't know if its a pw problem or a problem in how you sent the patch
> to the ml.
>
> Oded
>
>
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Well, i just copied it from the git-diff-terminal and pasted it into my
mail-client. Maybe a newline problem ? Anyway, i attached the patch (and
patched my local mesa with it before, which worked :-) ).
Cheers
Jochen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_BE_test_in_compiler.h.patch
Type: text/x-patch
Size: 576 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160215/42537f83/attachment.bin>
More information about the mesa-dev
mailing list