[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 9/9] exec/address-spaces: Inline legacy functions



On 20/9/22 07:15, Philippe Mathieu-Daudé wrote:
On 20/9/22 01:17, Bernhard Beschow wrote:
The functions just access a global pointer and perform some pointer
arithmetic on top. Allow the compiler to see through this by inlining.

I thought about this while reviewing the previous patch, ...

Signed-off-by: Bernhard Beschow <shentey@xxxxxxxxx>
---
  include/exec/address-spaces.h | 30 ++++++++++++++++++++++++++----
  softmmu/physmem.c             | 28 ----------------------------
  2 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h
index b31bd8dcf0..182af27cad 100644
--- a/include/exec/address-spaces.h
+++ b/include/exec/address-spaces.h
@@ -23,29 +23,51 @@
  #ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"

... but I'm not a fan of including this header here. It is restricted to system emulation, but still... Let see what the others think.

  /**
   * Get the root memory region.  This is a legacy function, provided for
   * compatibility. Prefer using SysBusState::system_memory directly.
   */
-MemoryRegion *get_system_memory(void);
+inline MemoryRegion *get_system_memory(void)
+{
+    assert(current_machine);
+
+    return &current_machine->main_system_bus.system_memory;
+}

Maybe we can simply declare them with __attribute__ ((const)) in the previous patch? See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.