qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 1/2] pass parameter as char.
Date: Thu, 11 Dec 2008 09:11:49 -0500	[thread overview]
Message-ID: <1229004710-28331-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1229004710-28331-1-git-send-email-glommer@redhat.com>

pass parameter to tb_invalidate_phys_page_fast() as a char, that we'll
actually transform into an integer. It will make it easier for generator macros
to deal with it.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 exec.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index 105812f..35e0b8e 100644
--- a/exec.c
+++ b/exec.c
@@ -997,11 +997,29 @@ void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t
 #endif
 }
 
+static inline int size2len(char size)
+{
+    switch (size) {
+    case 'b':
+        return 1;
+    case 'w':
+        return 2;
+    case 'l':
+        return 4;
+    }
+     
+    /* should never happen */
+    fprintf(stderr, "%s: invalid size %d\n", __func__, size);
+    exit(1);
+    return -1;
+}
+
 /* len must be <= 8 and start must be a multiple of len */
-static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int len)
+static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, char size)
 {
     PageDesc *p;
     int offset, b;
+    int len = size2len(size);
 #if 0
     if (1) {
         if (loglevel) {
@@ -2444,7 +2462,7 @@ static void notdirty_mem_writeb(void *opaque, target_phys_addr_t ram_addr,
     dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
-        tb_invalidate_phys_page_fast(ram_addr, 1);
+        tb_invalidate_phys_page_fast(ram_addr, 'b');
         dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
 #endif
     }
@@ -2469,7 +2487,7 @@ static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr,
     dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
-        tb_invalidate_phys_page_fast(ram_addr, 2);
+        tb_invalidate_phys_page_fast(ram_addr, 'w');
         dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
 #endif
     }
@@ -2494,7 +2512,7 @@ static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr,
     dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
-        tb_invalidate_phys_page_fast(ram_addr, 4);
+        tb_invalidate_phys_page_fast(ram_addr, 'l');
         dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
 #endif
     }
-- 
1.5.6.5

  reply	other threads:[~2008-12-11 14:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 14:11 [Qemu-devel] [PATCH 0/2] reduce code duplication Glauber Costa
2008-12-11 14:11 ` Glauber Costa [this message]
2008-12-11 14:11   ` [Qemu-devel] [PATCH 2/2] " Glauber Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1229004710-28331-2-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).