diff mbox series

[v2,4/9] hw/arm: Include missing 'exec/tswap.h' header

Message ID 20241211230357.97036-5-philmd@linaro.org
State New
Headers show
Series misc: Reduce 'exec/tswap.h' inclusions | expand

Commit Message

Philippe Mathieu-Daudé Dec. 11, 2024, 11:03 p.m. UTC
Some files indirectly get "exec/tswap.h" declarations via
"exec/cpu-all.h". Include it directly to be able to remove
the former from the latter, otherwise we get:

  hw/arm/boot.c:175:19: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    175 |         code[i] = tswap32(insn);
        |                   ^
  hw/arm/npcm7xx.c:326:26: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    326 |         board_setup[i] = tswap32(board_setup[i]);
        |                          ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/boot.c    | 1 +
 hw/arm/npcm7xx.c | 1 +
 2 files changed, 2 insertions(+)

Comments

Richard Henderson Dec. 11, 2024, 11:53 p.m. UTC | #1
On 12/11/24 17:03, Philippe Mathieu-Daudé wrote:
> Some files indirectly get "exec/tswap.h" declarations via
> "exec/cpu-all.h". Include it directly to be able to remove
> the former from the latter, otherwise we get:
> 
>    hw/arm/boot.c:175:19: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>      175 |         code[i] = tswap32(insn);
>          |                   ^
>    hw/arm/npcm7xx.c:326:26: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>      326 |         board_setup[i] = tswap32(board_setup[i]);
>          |                          ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/boot.c    | 1 +
>   hw/arm/npcm7xx.c | 1 +
>   2 files changed, 2 insertions(+)
> 

These could all be cpu_to_le32, since TARGET_BIG_ENDIAN is always false for qemu-system-arm.


r~
Philippe Mathieu-Daudé Dec. 17, 2024, 3:20 p.m. UTC | #2
On 12/12/24 00:53, Richard Henderson wrote:
> On 12/11/24 17:03, Philippe Mathieu-Daudé wrote:
>> Some files indirectly get "exec/tswap.h" declarations via
>> "exec/cpu-all.h". Include it directly to be able to remove
>> the former from the latter, otherwise we get:
>>
>>    hw/arm/boot.c:175:19: error: call to undeclared function 'tswap32'; 
>> ISO C99 and later do not support implicit function declarations [- 
>> Wimplicit-function-declaration]
>>      175 |         code[i] = tswap32(insn);
>>          |                   ^
>>    hw/arm/npcm7xx.c:326:26: error: call to undeclared function 
>> 'tswap32'; ISO C99 and later do not support implicit function 
>> declarations [-Wimplicit-function-declaration]
>>      326 |         board_setup[i] = tswap32(board_setup[i]);
>>          |                          ^
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/arm/boot.c    | 1 +
>>   hw/arm/npcm7xx.c | 1 +
>>   2 files changed, 2 insertions(+)
>>
> 
> These could all be cpu_to_le32, since TARGET_BIG_ENDIAN is always false 
> for qemu-system-arm.

I agree, but last time I did that Peter insisted for tswap():
https://lore.kernel.org/qemu-devel/CAFEAcA8Exn0VMzM1h048q4Nm7toxkpaOv4B-ZE4FEXKgHoqy7A@mail.gmail.com/

Peter, was my wording in that previous series not clear (in that case
I can try to clarify) or was it OK but you reject the possibility of
using cpu_to_le32() to remove tswap() calls?

(Here my goal is to have a single binary, so I start removing target-
specific endianness).

Thanks,

Phil.
diff mbox series

Patch

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 5301d8d318c..30ba98d52fb 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -26,6 +26,7 @@ 
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/units.h"
+#include "exec/tswap.h"
 
 /* Kernel boot protocol is specified in the kernel docs
  * Documentation/arm/Booting and Documentation/arm64/booting.txt
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index af04c4b7ec4..3a5ef26f689 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -28,6 +28,7 @@ 
 #include "qemu/units.h"
 #include "sysemu/sysemu.h"
 #include "target/arm/cpu-qom.h"
+#include "exec/tswap.h"
 
 /*
  * This covers the whole MMIO space. We'll use this to catch any MMIO accesses