WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 22 of 25] libxc: osdep: Use XC_PAGE_{SHIFT, MASK}

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 22 of 25] libxc: osdep: Use XC_PAGE_{SHIFT, MASK}
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 03 Dec 2010 09:57:26 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 03 Dec 2010 02:28:06 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1291370224@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1291369007 0
# Node ID fd025a5043072ae2684f55e5c4ffdb86f6cda042
# Parent  ba7854a6f15b606a5285a786597bbdb452c9d360
libxc: osdep: Use XC_PAGE_{SHIFT,MASK}.

Avoid dependency on xc_private.h

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r ba7854a6f15b -r fd025a504307 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_linux.c    Fri Dec 03 09:36:47 2010 +0000
@@ -110,7 +110,7 @@ static void *linux_privcmd_map_foreign_b
     void *addr;
     int rc;
 
-    addr = mmap(NULL, num << PAGE_SHIFT, prot, MAP_SHARED, fd, 0);
+    addr = mmap(NULL, num << XC_PAGE_SHIFT, prot, MAP_SHARED, fd, 0);
     if ( addr == MAP_FAILED )
     {
         PERROR("xc_map_foreign_batch: mmap failed");
@@ -132,7 +132,7 @@ static void *linux_privcmd_map_foreign_b
             if ( (arr[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) ==
                  XEN_DOMCTL_PFINFO_PAGEDTAB )
             {
-                unsigned long paged_addr = (unsigned long)addr + (i << 
PAGE_SHIFT);
+                unsigned long paged_addr = (unsigned long)addr + (i << 
XC_PAGE_SHIFT);
                 rc = xc_map_foreign_batch_single(fd, dom, &arr[i],
                                                  paged_addr);
                 if ( rc < 0 )
@@ -146,7 +146,7 @@ static void *linux_privcmd_map_foreign_b
     {
         int saved_errno = errno;
         PERROR("xc_map_foreign_batch: ioctl failed");
-        (void)munmap(addr, num << PAGE_SHIFT);
+        (void)munmap(addr, num << XC_PAGE_SHIFT);
         errno = saved_errno;
         return NULL;
     }
@@ -164,7 +164,7 @@ static void *linux_privcmd_map_foreign_b
     unsigned int i;
     int rc;
 
-    addr = mmap(NULL, (unsigned long)num << PAGE_SHIFT, prot, MAP_SHARED,
+    addr = mmap(NULL, (unsigned long)num << XC_PAGE_SHIFT, prot, MAP_SHARED,
                 fd, 0);
     if ( addr == MAP_FAILED )
     {
@@ -189,7 +189,7 @@ static void *linux_privcmd_map_foreign_b
 
             ioctlx.num = 1;
             ioctlx.dom = dom;
-            ioctlx.addr = (unsigned long)addr + ((unsigned long)i<<PAGE_SHIFT);
+            ioctlx.addr = (unsigned long)addr + ((unsigned 
long)i<<XC_PAGE_SHIFT);
             ioctlx.arr = arr + i;
             ioctlx.err = err + i;
             do {
@@ -239,7 +239,7 @@ static void *linux_privcmd_map_foreign_b
                         continue;
                     }
                     rc = xc_map_foreign_batch_single(fd, dom, pfn + i,
-                        (unsigned long)addr + ((unsigned long)i<<PAGE_SHIFT));
+                        (unsigned long)addr + ((unsigned 
long)i<<XC_PAGE_SHIFT));
                     if ( rc < 0 )
                     {
                         rc = -errno;
@@ -273,7 +273,7 @@ static void *linux_privcmd_map_foreign_b
         int saved_errno = errno;
 
         PERROR("xc_map_foreign_bulk: ioctl failed");
-        (void)munmap(addr, (unsigned long)num << PAGE_SHIFT);
+        (void)munmap(addr, (unsigned long)num << XC_PAGE_SHIFT);
         errno = saved_errno;
         return NULL;
     }
@@ -290,7 +290,7 @@ static void *linux_privcmd_map_foreign_r
     int i;
     void *ret;
 
-    num = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+    num = (size + XC_PAGE_SIZE - 1) >> XC_PAGE_SHIFT;
     arr = calloc(num, sizeof(xen_pfn_t));
 
     for ( i = 0; i < num; i++ )
@@ -313,7 +313,7 @@ static void *linux_privcmd_map_foreign_r
     int j;
     void *ret;
 
-    num_per_entry = chunksize >> PAGE_SHIFT;
+    num_per_entry = chunksize >> XC_PAGE_SHIFT;
     num = num_per_entry * nentries;
     arr = calloc(num, sizeof(xen_pfn_t));
 
@@ -474,7 +474,7 @@ void discard_file_cache(xc_interface *xc
     {
         if ( (cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 )
             cur = 0;
-        cur &= ~(PAGE_SIZE-1);
+        cur &= ~(XC_PAGE_SIZE-1);
     }
 
     /* Discard from the buffer cache. */
@@ -521,7 +521,7 @@ static void *linux_gnttab_map_grant_ref(
     }
 
 mmap_again:    
-    addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, fd, map.index);
+    addr = mmap(NULL, XC_PAGE_SIZE, prot, MAP_SHARED, fd, map.index);
     if ( addr == MAP_FAILED )
     {
         int saved_errno = errno;
@@ -572,7 +572,7 @@ static void *do_gnttab_map_grant_refs(xc
         goto out;
     }
 
-    addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, fd,
+    addr = mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd,
                 map->index);
     if ( addr == MAP_FAILED )
     {
diff -r ba7854a6f15b -r fd025a504307 tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c   Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_minios.c   Fri Dec 03 09:36:47 2010 +0000
@@ -169,11 +169,11 @@ static void *minios_privcmd_map_foreign_
        pt_prot = L1_PROT;
 #endif
 
-    mfns = malloc((size / PAGE_SIZE) * sizeof(*mfns));
+    mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns));
 
     n = 0;
     for (i = 0; i < nentries; i++)
-        for (j = 0; j < chunksize / PAGE_SIZE; j++)
+        for (j = 0; j < chunksize / XC_PAGE_SIZE; j++)
             mfns[n++] = entries[i].mfn + j;
 
     ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot);
diff -r ba7854a6f15b -r fd025a504307 tools/libxc/xc_netbsd.c
--- a/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:47 2010 +0000
@@ -84,7 +84,7 @@ static void *netbsd_privcmd_map_foreign_
     int fd = (int)h;
     privcmd_mmapbatch_t ioctlx;
     void *addr;
-    addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
+    addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
     if ( addr == MAP_FAILED ) {
         PERROR("xc_map_foreign_batch: mmap failed");
         return NULL;
@@ -98,7 +98,7 @@ static void *netbsd_privcmd_map_foreign_
     {
         int saved_errno = errno;
         PERROR("xc_map_foreign_batch: ioctl failed");
-        (void)munmap(addr, num*PAGE_SIZE);
+        (void)munmap(addr, num*XC_PAGE_SIZE);
         errno = saved_errno;
         return NULL;
     }
@@ -126,7 +126,7 @@ static void *netbsd_privcmd_map_foreign_
     ioctlx.entry=&entry;
     entry.va=(unsigned long) addr;
     entry.mfn=mfn;
-    entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
+    entry.npages=(size+XC_PAGE_SIZE-1)>>XC_PAGE_SHIFT;
     if ( ioctl(fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
     {
         int saved_errno = errno;
@@ -154,7 +154,7 @@ static void *netbsd_privcmd_map_foreign_
 
        for (i = 0; i < nentries; i++) {
                entries[i].va = (uintptr_t)addr + (i * chunksize);
-               entries[i].npages = chunksize >> PAGE_SHIFT;
+               entries[i].npages = chunksize >> XC_PAGE_SHIFT;
        }
 
        ioctlx.num   = nentries;
diff -r ba7854a6f15b -r fd025a504307 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_private.h  Fri Dec 03 09:36:47 2010 +0000
@@ -53,8 +53,8 @@
 #undef PAGE_SIZE
 #undef PAGE_MASK
 #define PAGE_SHIFT              XC_PAGE_SHIFT
-#define PAGE_SIZE               (1UL << PAGE_SHIFT)
-#define PAGE_MASK               (~(PAGE_SIZE-1))
+#define PAGE_SIZE               XC_PAGE_SIZE
+#define PAGE_MASK               XC_PAGE_MASK
 
 /* Force a compilation error if condition is true */
 #define XC_BUILD_BUG_ON(p) ((void)sizeof(struct { int:-!!(p); }))
diff -r ba7854a6f15b -r fd025a504307 tools/libxc/xc_solaris.c
--- a/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:47 2010 +0000
@@ -80,7 +80,7 @@ static void *solaris_privcmd_map_foreign
     int fd = (int)h;
     privcmd_mmapbatch_t ioctlx;
     void *addr;
-    addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, fd, 0);
+    addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_SHARED, fd, 0);
     if ( addr == MAP_FAILED )
         return NULL;
 
@@ -92,7 +92,7 @@ static void *solaris_privcmd_map_foreign
     {
         int saved_errno = errno;
         PERROR("XXXXXXXX");
-        (void)munmap(addr, num*PAGE_SIZE);
+        (void)munmap(addr, num*XC_PAGE_SIZE);
         errno = saved_errno;
         return NULL;
     }
@@ -118,7 +118,7 @@ static void *xc_map_foreign_range(xc_int
     ioctlx.entry=&entry;
     entry.va=(unsigned long) addr;
     entry.mfn=mfn;
-    entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
+    entry.npages=(size+XC_PAGE_SIZE-1)>>XC_PAGE_SHIFT;
     if ( ioctl(fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
     {
         int saved_errno = errno;
@@ -145,7 +145,7 @@ static void *solaric_privcmd_map_foreign
 
     for (i = 0; i < nentries; i++) {
         entries[i].va = (uintptr_t)addr + (i * chunksize);
-        entries[i].npages = chunksize >> PAGE_SHIFT;
+        entries[i].npages = chunksize >> XC_PAGE_SHIFT;
     }
 
     ioctlx.num   = nentries;

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

<Prev in Thread] Current Thread [Next in Thread>