[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] tests/tcg/multiarch: Make the system memory test work on
From: |
Thomas Weißschuh |
Subject: |
Re: [PATCH 1/2] tests/tcg/multiarch: Make the system memory test work on big-endian |
Date: |
Sat, 22 Apr 2023 13:02:25 +0200 |
On 2023-04-22 02:58:07+0200, Ilya Leoshkevich wrote:
> Make sure values are stored in memory as little-endian regardless of
> the host endianness.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> tests/tcg/multiarch/system/memory.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/tests/tcg/multiarch/system/memory.c
> b/tests/tcg/multiarch/system/memory.c
> index 214f7d4f54b..8ef6666b440 100644
> --- a/tests/tcg/multiarch/system/memory.c
> +++ b/tests/tcg/multiarch/system/memory.c
> @@ -121,6 +121,9 @@ static void init_test_data_u16(int offset)
> for (i = 0; i < max; i++) {
> uint8_t low = count++, high = count++;
> word = BYTE_SHIFT(high, 1) | BYTE_SHIFT(low, 0);
> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> + word = __builtin_bswap16(word);
> +#endif
These looks like a usecase for cpu_to_le16() and friends.
> *ptr++ = word;
> pdot(i);
> }
> @@ -142,6 +145,9 @@ static void init_test_data_u32(int offset)
> uint8_t b4 = count++, b3 = count++;
> uint8_t b2 = count++, b1 = count++;
> word = BYTE_SHIFT(b1, 3) | BYTE_SHIFT(b2, 2) | BYTE_SHIFT(b3, 1) |
> b4;
> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> + word = __builtin_bswap32(word);
> +#endif
> *ptr++ = word;
> pdot(i);
> }
> [..]