[PATCH v3 22/25] system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition

Philippe Mathieu-Daudé posted 25 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v3 22/25] system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
Guard the native endian definition we want to remove by surrounding
it with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the target
config, then the target won't be able to use the legacy API anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu-common.h | 2 ++
 system/memory-internal.h  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index e0be4ee2b8f..f4961a20911 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -39,7 +39,9 @@ void tcg_iommu_init_notifier_list(CPUState *cpu);
 void tcg_iommu_free_notifier_list(CPUState *cpu);
 
 enum device_endian {
+#ifndef TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API
     DEVICE_NATIVE_ENDIAN,
+#endif
     DEVICE_BIG_ENDIAN,
     DEVICE_LITTLE_ENDIAN,
 };
diff --git a/system/memory-internal.h b/system/memory-internal.h
index 46f758fa7e4..5f0524756eb 100644
--- a/system/memory-internal.h
+++ b/system/memory-internal.h
@@ -41,9 +41,11 @@ void mtree_print_dispatch(struct AddressSpaceDispatch *d,
 /* returns true if end is big endian. */
 static inline bool devend_big_endian(enum device_endian end)
 {
+#ifndef TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API
     if (end == DEVICE_NATIVE_ENDIAN) {
         return target_big_endian();
     }
+#endif
     return end == DEVICE_BIG_ENDIAN;
 }
 
-- 
2.52.0


Re: [PATCH v3 22/25] system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition
Posted by Richard Henderson 1 month, 1 week ago
On 12/25/25 02:22, Philippe Mathieu-Daudé wrote:
> Guard the native endian definition we want to remove by surrounding
> it with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.
> 
> Once a target gets cleaned we'll set the definition in the target
> config, then the target won't be able to use the legacy API anymore.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cpu-common.h | 2 ++
>   system/memory-internal.h  | 2 ++
>   2 files changed, 4 insertions(+)
> 
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index e0be4ee2b8f..f4961a20911 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -39,7 +39,9 @@ void tcg_iommu_init_notifier_list(CPUState *cpu);
>   void tcg_iommu_free_notifier_list(CPUState *cpu);
>   
>   enum device_endian {
> +#ifndef TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API
>       DEVICE_NATIVE_ENDIAN,
> +#endif
>       DEVICE_BIG_ENDIAN,
>       DEVICE_LITTLE_ENDIAN,
>   };

For cross-target compatibility, you surely need the enumerators to stay unchanged.
Add "= 1" to DEVICE_BIG_ENDIAN?


r~