From 11498c2d92e703923d373b64ad3f33aec5f383f2 Mon Sep 17 00:00:00 2001
From: Jiajie Li <lijiajie11@huawei.com>
Date: Thu, 17 Feb 2022 09:51:13 +0800
Subject: [PATCH] i386/cpu: fix compile error in all target configure

When compile with `./configure && make -j`, there will be
error: "unknown type name `ram_addr_t`", fix the error by
adding compilation macro to control it.

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
---
 target/i386/cpu.c | 16 ++++++++--------
 target/i386/cpu.h |  2 ++
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a4732a7372..d9dca1dafb 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6711,14 +6711,6 @@ static bool x86_cpu_get_paging_enabled(const CPUState *cs)
 
     return cpu->env.cr[0] & CR0_PG_MASK;
 }
-#endif /* !CONFIG_USER_ONLY */
-
-static void x86_cpu_set_pc(CPUState *cs, vaddr value)
-{
-    X86CPU *cpu = X86_CPU(cs);
-
-    cpu->env.eip = value;
-}
 
 /* At present, we check the vm is *LARGE* or not, i.e. whether
  * the memory size is more than 4T or not.
@@ -6736,6 +6728,14 @@ void x86_cpu_adjuest_by_ram_size(ram_addr_t ram_size, X86CPU *cpu)
         cpu->fill_mtrr_mask = true;
     }
 }
+#endif /* !CONFIG_USER_ONLY */
+
+static void x86_cpu_set_pc(CPUState *cs, vaddr value)
+{
+    X86CPU *cpu = X86_CPU(cs);
+
+    cpu->env.eip = value;
+}
 
 int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request)
 {
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 6f777fd6ca..d9296a9abc 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1842,10 +1842,12 @@ struct X86CPU {
 extern const VMStateDescription vmstate_x86_cpu;
 #endif
 
+#ifndef CONFIG_USER_ONLY
 #define DEFAULT_VM_CPU_PHYS_BITS 42
 #define LARGE_VM_CPU_PHYS_BITS 46
 
 void x86_cpu_adjuest_by_ram_size(ram_addr_t ram_size, X86CPU *cpu);
+#endif
 
 int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request);
 
-- 
2.27.0