qemu-riscv
[Top][All Lists]
Advanced

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

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


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 9/9] exec/address-spaces: Inline legacy functions
Date: Tue, 20 Sep 2022 07:29:43 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

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@gmail.com>
---
  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]