[PATCH 2/6] target/arm: Make set_feature() available for other files

Philippe Mathieu-Daudé posted 6 patches 5 years, 9 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
[PATCH 2/6] target/arm: Make set_feature() available for other files
Posted by Philippe Mathieu-Daudé 5 years, 9 months ago
From: Thomas Huth <thuth@redhat.com>

Move the common set_feature() and unset_feature() functions
from cpu.c and cpu64.c to cpu.h.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-ID: <20190921150420.30743-2-thuth@redhat.com>
[PMD: Split Thomas's patch in two: set_feature, cpu_register (later)]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 target/arm/cpu.h   | 10 ++++++++++
 target/arm/cpu.c   | 10 ----------
 target/arm/cpu64.c | 11 +----------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8b9f2961ba..5e32fe7518 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -696,6 +696,16 @@ typedef struct CPUARMState {
     void *gicv3state;
 } CPUARMState;
 
+static inline void set_feature(CPUARMState *env, int feature)
+{
+    env->features |= 1ULL << feature;
+}
+
+static inline void unset_feature(CPUARMState *env, int feature)
+{
+    env->features &= ~(1ULL << feature);
+}
+
 /**
  * ARMELChangeHookFn:
  * type of a function which can be registered via arm_register_el_change_hook()
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index a79f233b17..37f18d1648 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -724,16 +724,6 @@ static bool arm_cpu_virtio_is_big_endian(CPUState *cs)
 
 #endif
 
-static inline void set_feature(CPUARMState *env, int feature)
-{
-    env->features |= 1ULL << feature;
-}
-
-static inline void unset_feature(CPUARMState *env, int feature)
-{
-    env->features &= ~(1ULL << feature);
-}
-
 static int
 print_insn_thumb1(bfd_vma pc, disassemble_info *info)
 {
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 62d36f9e8d..622082eae2 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "cpu.h"
+#include "internals.h"
 #include "qemu/module.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
@@ -29,16 +30,6 @@
 #include "kvm_arm.h"
 #include "qapi/visitor.h"
 
-static inline void set_feature(CPUARMState *env, int feature)
-{
-    env->features |= 1ULL << feature;
-}
-
-static inline void unset_feature(CPUARMState *env, int feature)
-{
-    env->features &= ~(1ULL << feature);
-}
-
 #ifndef CONFIG_USER_ONLY
 static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
 {
-- 
2.21.1


Re: [PATCH 2/6] target/arm: Make set_feature() available for other files
Posted by Philippe Mathieu-Daudé 5 years, 9 months ago
On 4/21/20 3:19 PM, Philippe Mathieu-Daudé wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> Move the common set_feature() and unset_feature() functions
> from cpu.c and cpu64.c to cpu.h.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> Message-ID: <20190921150420.30743-2-thuth@redhat.com>
> [PMD: Split Thomas's patch in two: set_feature, cpu_register (later)]
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   target/arm/cpu.h   | 10 ++++++++++
>   target/arm/cpu.c   | 10 ----------
>   target/arm/cpu64.c | 11 +----------
>   3 files changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 8b9f2961ba..5e32fe7518 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -696,6 +696,16 @@ typedef struct CPUARMState {
>       void *gicv3state;
>   } CPUARMState;
>   
> +static inline void set_feature(CPUARMState *env, int feature)
> +{
> +    env->features |= 1ULL << feature;
> +}
> +
> +static inline void unset_feature(CPUARMState *env, int feature)
> +{
> +    env->features &= ~(1ULL << feature);
> +}

Nack sigh... This still doesn't work:

target/arm/kvm64.c: At top level:
target/arm/kvm64.c:450:20: error: conflicting types for ‘set_feature’
  static inline void set_feature(uint64_t *features, int feature)
                     ^~~~~~~~~~~
In file included from include/sysemu/kvm.h:252:0,
                  from target/arm/kvm64.c:27:
target/arm/cpu.h:699:20: note: previous definition of ‘set_feature’ was here
  static inline void set_feature(CPUARMState *env, int feature)
                     ^~~~~~~~~~~
target/arm/kvm64.c:455:20: error: conflicting types for ‘unset_feature’
  static inline void unset_feature(uint64_t *features, int feature)
                     ^~~~~~~~~~~~~
In file included from include/sysemu/kvm.h:252:0,
                  from target/arm/kvm64.c:27:
target/arm/cpu.h:704:20: note: previous definition of ‘unset_feature’ 
was here
  static inline void unset_feature(CPUARMState *env, int feature)
                     ^~~~~~~~~~~~~
rules.mak:69: recipe for target 'target/arm/kvm64.o' failed
make: *** [target/arm/kvm64.o] Error 1

> +
>   /**
>    * ARMELChangeHookFn:
>    * type of a function which can be registered via arm_register_el_change_hook()
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index a79f233b17..37f18d1648 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -724,16 +724,6 @@ static bool arm_cpu_virtio_is_big_endian(CPUState *cs)
>   
>   #endif
>   
> -static inline void set_feature(CPUARMState *env, int feature)
> -{
> -    env->features |= 1ULL << feature;
> -}
> -
> -static inline void unset_feature(CPUARMState *env, int feature)
> -{
> -    env->features &= ~(1ULL << feature);
> -}
> -
>   static int
>   print_insn_thumb1(bfd_vma pc, disassemble_info *info)
>   {
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 62d36f9e8d..622082eae2 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -21,6 +21,7 @@
>   #include "qemu/osdep.h"
>   #include "qapi/error.h"
>   #include "cpu.h"
> +#include "internals.h"

This include is not necessary.

>   #include "qemu/module.h"
>   #if !defined(CONFIG_USER_ONLY)
>   #include "hw/loader.h"
> @@ -29,16 +30,6 @@
>   #include "kvm_arm.h"
>   #include "qapi/visitor.h"
>   
> -static inline void set_feature(CPUARMState *env, int feature)
> -{
> -    env->features |= 1ULL << feature;
> -}
> -
> -static inline void unset_feature(CPUARMState *env, int feature)
> -{
> -    env->features &= ~(1ULL << feature);
> -}
> -
>   #ifndef CONFIG_USER_ONLY
>   static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
>   {
>