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-changelog

[Xen-changelog] [xen-unstable] libxc: Define xc_ffs{8, 16, 32, 64} funct

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc: Define xc_ffs{8, 16, 32, 64} functions. Use them.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 08 Jan 2009 06:57:39 -0800
Delivery-date: Thu, 08 Jan 2009 07:02:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1231233279 0
# Node ID f6b92526e9162f0ea2183903cedee7394da86cfd
# Parent  d77f66f89c0413eb468d9716913cc18515989531
libxc: Define xc_ffs{8,16,32,64} functions. Use them.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/libxc/xc_pagetab.c |    3 +--
 tools/libxc/xc_private.c |   27 +++++++++++++++++++++++++++
 tools/libxc/xc_private.h |    5 +++++
 tools/libxc/xc_ptrace.c  |    5 ++---
 tools/libxc/xg_private.c |    1 -
 5 files changed, 35 insertions(+), 6 deletions(-)

diff -r d77f66f89c04 -r f6b92526e916 tools/libxc/xc_pagetab.c
--- a/tools/libxc/xc_pagetab.c  Mon Jan 05 11:55:24 2009 +0000
+++ b/tools/libxc/xc_pagetab.c  Tue Jan 06 09:14:39 2009 +0000
@@ -4,7 +4,6 @@
  * Function to translate virtual to physical addresses.
  */
 #include "xc_private.h"
-#include <strings.h>
 
 #define CR0_PG  0x80000000
 #define CR4_PAE 0x20
@@ -77,7 +76,7 @@ unsigned long xc_translate_foreign_addre
 
     /* Walk the pagetables */
     for (level = pt_levels; level > 0; level--) {
-        paddr += ((virt & mask) >> (ffsll(mask) - 1)) * size;
+        paddr += ((virt & mask) >> (xc_ffs64(mask) - 1)) * size;
         map = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, 
                                    paddr >>PAGE_SHIFT);
         if (!map) 
diff -r d77f66f89c04 -r f6b92526e916 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Mon Jan 05 11:55:24 2009 +0000
+++ b/tools/libxc/xc_private.c  Tue Jan 06 09:14:39 2009 +0000
@@ -639,6 +639,33 @@ int write_exact(int fd, const void *data
     return 0;
 }
 
+int xc_ffs8(uint8_t x)
+{
+    int i;
+    for ( i = 0; i < 8; i++ )
+        if ( x & (1u << i) )
+            return i+1;
+    return 0;
+}
+
+int xc_ffs16(uint16_t x)
+{
+    uint8_t h = x>>8, l = x;
+    return l ? xc_ffs8(l) : h ? xc_ffs8(h) + 8 : 0;
+}
+
+int xc_ffs32(uint32_t x)
+{
+    uint16_t h = x>>16, l = x;
+    return l ? xc_ffs16(l) : h ? xc_ffs16(h) + 16 : 0;
+}
+
+int xc_ffs64(uint64_t x)
+{
+    uint32_t h = x>>32, l = x;
+    return l ? xc_ffs32(l) : h ? xc_ffs32(h) + 32 : 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r d77f66f89c04 -r f6b92526e916 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Mon Jan 05 11:55:24 2009 +0000
+++ b/tools/libxc/xc_private.h  Tue Jan 06 09:14:39 2009 +0000
@@ -218,4 +218,9 @@ int read_exact(int fd, void *data, size_
 int read_exact(int fd, void *data, size_t size);
 int write_exact(int fd, const void *data, size_t size);
 
+int xc_ffs8(uint8_t x);
+int xc_ffs16(uint16_t x);
+int xc_ffs32(uint32_t x);
+int xc_ffs64(uint64_t x);
+
 #endif /* __XC_PRIVATE_H__ */
diff -r d77f66f89c04 -r f6b92526e916 tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c   Mon Jan 05 11:55:24 2009 +0000
+++ b/tools/libxc/xc_ptrace.c   Tue Jan 06 09:14:39 2009 +0000
@@ -44,8 +44,7 @@ static uint64_t                         
 static uint64_t                         regs_valid;
 static vcpu_guest_context_any_t      ctxt[MAX_VIRT_CPUS];
 
-extern int ffsll(long long int);
-#define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = 
ffsll(cpumap)); cpumap &= ~(1 << (index - 1)) )
+#define FOREACH_CPU(cpumap, i)  for ( cpumap = online_cpumap; (i = 
xc_ffs64(cpumap)); cpumap &= ~(1 << (index - 1)) )
 
 static int
 fetch_regs(int xc_handle, int cpu, int *online)
@@ -136,7 +135,7 @@ online_vcpus_changed(uint64_t cpumap)
     uint64_t changed_cpumap = cpumap ^ online_cpumap;
     int index;
 
-    while ( (index = ffsll(changed_cpumap)) ) {
+    while ( (index = xc_ffs64(changed_cpumap)) ) {
         if ( cpumap & (1 << (index - 1)) )
         {
             if (handlers.td_create) handlers.td_create(index - 1);
diff -r d77f66f89c04 -r f6b92526e916 tools/libxc/xg_private.c
--- a/tools/libxc/xg_private.c  Mon Jan 05 11:55:24 2009 +0000
+++ b/tools/libxc/xg_private.c  Tue Jan 06 09:14:39 2009 +0000
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <zlib.h>
-#include <strings.h>
 #include <malloc.h>
 
 #include "xg_private.h"

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxc: Define xc_ffs{8, 16, 32, 64} functions. Use them., Xen patchbot-unstable <=