All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Parish <srparish@us.ibm.com>
To: kraxel@bytesex.org
Cc: xen-devel@lists.xensource.com
Subject: [patch] convert page-l3.h macros to inlines
Date: Fri, 13 May 2005 11:16:35 +0000	[thread overview]
Message-ID: <20050513111635.GE27910@us.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]

Avoid multiple evals as discussed in "double incrementing l2tab" thread.

sRp

-- 
Scott Parish
Signed-off-by: srparish@us.ibm.com

[-- Attachment #2: macro-to-inline.diff --]
[-- Type: text/plain, Size: 3070 bytes --]

--- xen-unstable-orig/xen/include/asm-x86/x86_32/page-3l.h	2005-05-13 10:51:30.000000000 +0000
+++ xen-unstable-pae/xen/include/asm-x86/x86_32/page-3l.h	2005-05-13 10:42:15.000000000 +0000
@@ -24,28 +24,66 @@ typedef struct { u32 l3_lo; u32 l3_hi; }
 typedef l3_pgentry_t root_pgentry_t;
 
 /* read access (depricated) */
-#define l1e_get_value(_x)         ((u64)(_x).l1_lo | (u64)(_x).l1_hi << 32)
-#define l2e_get_value(_x)         ((u64)(_x).l2_lo | (u64)(_x).l2_hi << 32)
-#define l3e_get_value(_x)         ((u64)(_x).l3_lo | (u64)(_x).l3_hi << 32)
+static inline u64 l1e_get_value(l1_pgentry_t x)
+{
+    return ((u64)x.l1_lo | (u64)x.l1_hi << 32);
+}
+static inline u64 l2e_get_value(l2_pgentry_t x)
+{
+    return ((u64)x.l2_lo | (u64)x.l2_hi << 32);
+}
+static inline u64 l3e_get_value(l3_pgentry_t x)
+{
+    return ((u64)x.l3_lo | (u64)x.l3_hi << 32);
+}
+
 
 /* read access */
-#define l1e_get_pfn(_x)           ((((_x).l1_hi & 0x0f) << (32-PAGE_SHIFT))  |\
-				    ((_x).l1_lo         >> PAGE_SHIFT))
-#define l1e_get_phys(_x)          ((((u64)(_x).l1_hi & 0x0f) << 32)  |\
-				    ((u64)(_x).l1_lo & PAGE_MASK))
-#define l1e_get_flags(_x)         ((_x).l1_lo &  ~PAGE_MASK)
-
-#define l2e_get_pfn(_x)           ((((_x).l2_hi & 0x0f) << (32-PAGE_SHIFT))  |\
-				    ((_x).l2_lo         >> PAGE_SHIFT))
-#define l2e_get_phys(_x)          ((((u64)(_x).l2_hi & 0x0f) << 32)  |\
-				    ((u64)(_x).l2_lo & PAGE_MASK))
-#define l2e_get_flags(_x)         ((_x).l2_lo &  ~PAGE_MASK)
-
-#define l3e_get_pfn(_x)           ((((_x).l3_hi & 0x0f) << (32-PAGE_SHIFT))  |\
-				    ((_x).l3_lo         >> PAGE_SHIFT))
-#define l3e_get_phys(_x)          ((((u64)(_x).l3_hi & 0x0f) << 32)  |\
-				    ((u64)(_x).l3_lo & PAGE_MASK))
-#define l3e_get_flags(_x)         ((_x).l3_lo &  ~PAGE_MASK)
+static inline unsigned long l1e_get_pfn(l1_pgentry_t x)
+{
+    return (((x.l1_hi & 0x0fULL) << (32-PAGE_SHIFT))  |
+	     (x.l1_lo         >> PAGE_SHIFT));
+}
+static inline u64 l1e_get_phys(l1_pgentry_t x)
+{
+    return ((((u64)x.l1_hi & 0x0fULL) << 32)  |
+	     ((u64)x.l1_lo & PAGE_MASK));
+}
+static inline unsigned long l1e_get_flags(l1_pgentry_t x)
+{
+    return (x.l1_lo & ~PAGE_MASK);
+}
+
+static inline unsigned long l2e_get_pfn(l2_pgentry_t x)
+{
+    return (((x.l2_hi & 0x0fULL) << (32-PAGE_SHIFT))  |
+	     (x.l2_lo         >> PAGE_SHIFT));
+}
+static inline u64 l2e_get_phys(l2_pgentry_t x)
+{
+    return ((((u64)x.l2_hi & 0x0fULL) << 32)  |
+	     ((u64)x.l2_lo & PAGE_MASK));
+}
+static inline unsigned long l2e_get_flags(l2_pgentry_t x)
+{
+    return (x.l2_lo & ~PAGE_MASK);
+}
+
+static inline unsigned long l3e_get_pfn(l3_pgentry_t x)
+{
+    return (((x.l3_hi & 0x0fULL) << (32-PAGE_SHIFT))  |
+	     (x.l3_lo         >> PAGE_SHIFT));
+}
+static inline u64 l3e_get_phys(l3_pgentry_t x)
+{
+    return ((((u64)x.l3_hi & 0x0fULL) << 32)  |
+	     ((u64)x.l3_lo & PAGE_MASK));
+}
+static inline unsigned long l3e_get_flags(l3_pgentry_t x)
+{
+    return (x.l3_lo & ~PAGE_MASK);
+}
+
 
 /* write access */
 static inline l1_pgentry_t l1e_empty(void)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2005-05-13 11:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-13 11:16 Scott Parish [this message]
2005-05-13 12:12 ` [patch] convert page-l3.h macros to inlines Gerd Knorr
2005-05-13 13:36   ` Scott Parish
2005-05-13 13:57     ` Scott Parish
2005-05-13 16:25       ` Gerd Knorr
2005-05-13 17:48         ` Scott Parish
2005-05-17 21:48           ` Scott Parish

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=20050513111635.GE27910@us.ibm.com \
    --to=srparish@us.ibm.com \
    --cc=kraxel@bytesex.org \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.