Re: [PATCH v6 050/103] tests/tcg/multiarch/sha1.c: fix big endian implementation

Pierrick Bouvier <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
On 7/28/26 12:36 AM, Philippe Mathieu-Daudé wrote:
> On 28/7/26 06:41, Pierrick Bouvier wrote:
>> All big endian targets were returning a wrong value due to this.
>>
>> Tested-by: Alex Bennée <[email protected]>
>> Signed-off-by: Pierrick Bouvier <[email protected]>
>> ---
>>    tests/tcg/multiarch/sha1.c | 4 ++--
>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/tcg/multiarch/sha1.c b/tests/tcg/multiarch/sha1.c
>> index 0081bd76577..6cebad2951d 100644
>> --- a/tests/tcg/multiarch/sha1.c
>> +++ b/tests/tcg/multiarch/sha1.c
>> @@ -48,10 +48,10 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
>>    
>>    /* blk0() and blk() perform the initial expand. */
>>    /* I got the idea of expanding during the round function from SSLeay */
>> -#if BYTE_ORDER == LITTLE_ENDIAN
>> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>>    #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
>>        |(rol(block->l[i],8)&0x00FF00FF))
>> -#elif BYTE_ORDER == BIG_ENDIAN
>> +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
>>    #define blk0(i) block->l[i]
>>    #else
>>    #error "Endianness not defined!"
> 
> Orthogonal but what about tests/tcg/multiarch/sigbus.c?

That's a good point.
Taking a look, the original issue with the current test is that #include 
<endian.h> was missing (for some wrong reason, I thought it was defined 
by qemu in compiler.h), letting the defines undefined.
sigbus is correct since it has the right include.
I'll change the current fix to just add the right header.

Thanks,
Pierrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.