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

[Xen-devel] [PATCH] Added function prototypes to libxl_utils.h and function definitions to libxl_utils.c for the logical 'or'-ing and logical 'and'-ing of two bitmaps



Linda Jacobson
---
 tools/libxl/libxl_utils.c   | 51 +++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_utils.h   |  6 ++++++
 tools/libxl/libxlu_disk_l.c |  8 ++-----
 tools/libxl/libxlu_disk_l.h |  6 +-----
 4 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index 9053b27..5b1fab8 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -691,6 +691,57 @@ void libxl_bitmap_reset(libxl_bitmap *bitmap, int bit)
     bitmap->map[bit / 8] &= ~(1 << (bit & 7));
 }
 
+int libxl_bitmap_or(libxl_ctx *ctx, libxl_bitmap *or_map,
+                    libxl_bitmap *map1, libxl_bitmap *map2)
+{
+    uint32_t size;
+    int rc;
+    int bit;
+
+    GC_INIT(ctx);
+/* if bitmaps aren't the same size, or should be size of larger bit map
+*/
+    size = max(map1->size, map2->size);
+    rc = libxl_bitmap_alloc(ctx, or_map, size);
+    if (rc)
+        goto out;
+    for (bit = 0; bit < (size * 8); bit++)
+    {
+        if (libxl_bitmap_test(map1, bit))
+            libxl_bitmap_set(or_map, bit);
+        else if (libxl_bitmap_test(map2, bit))
+            libxl_bitmap_set(or_map, bit);
+    }
+out:
+    GC_FREE;
+    return rc;
+} 
+
+int libxl_bitmap_and(libxl_ctx *ctx, libxl_bitmap *and_map,
+                     libxl_bitmap *map1, libxl_bitmap *map2)
+{
+    uint32_t size;
+    int rc;
+    int bit;
+
+    GC_INIT(ctx);
+/* if bitmaps aren't same size, 'and' should be size of smaller bit map
+*/ 
+    size = min(map1->size, map2->size);
+    rc = libxl_bitmap_alloc(ctx, and_map, size);
+    if (rc)
+        goto out;
+    for (bit = 0; bit < (size * 8); bit++)
+    {
+        if (libxl_bitmap_test (map1, bit) && 
+            libxl_bitmap_test (map2, bit) )
+            libxl_bitmap_set (and_map, bit);
+    }
+out:
+    GC_FREE;
+    return rc;
+ } 
+
 int libxl_bitmap_count_set(const libxl_bitmap *bitmap)
 {
     int i, nr_set_bits = 0;
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 68b5580..1ba2b44 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -91,6 +91,12 @@ void libxl_bitmap_set(libxl_bitmap *bitmap, int bit);
 void libxl_bitmap_reset(libxl_bitmap *bitmap, int bit);
 int libxl_bitmap_count_set(const libxl_bitmap *bitmap);
 char *libxl_bitmap_to_hex_string(libxl_ctx *ctx, const libxl_bitmap *bitmap);
+/* or, and and xor functions for two bitmaps
+ */
+int libxl_bitmap_or(libxl_ctx *ctx, libxl_bitmap *new_bitmap,
+                    libxl_bitmap *bitmap1, libxl_bitmap *bitmap2); 
+int libxl_bitmap_and(libxl_ctx *ctx, libxl_bitmap *new_bitmap,
+                     libxl_bitmap *bitmap1, libxl_bitmap *bitmap2);
 static inline void libxl_bitmap_set_any(libxl_bitmap *bitmap)
 {
     memset(bitmap->map, -1, bitmap->size);
diff --git a/tools/libxl/libxlu_disk_l.c b/tools/libxl/libxlu_disk_l.c
index beea7f9..2c6e8e3 100644
--- a/tools/libxl/libxlu_disk_l.c
+++ b/tools/libxl/libxlu_disk_l.c
@@ -1011,10 +1011,6 @@ int xlu__disk_yyget_lineno (yyscan_t yyscanner );
 
 void xlu__disk_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
-int xlu__disk_yyget_column  (yyscan_t yyscanner );
-
-void xlu__disk_yyset_column (int column_no ,yyscan_t yyscanner );
-
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
  */
@@ -1159,7 +1155,7 @@ YY_DECL
 
  /*----- the scanner rules which do the parsing -----*/
 
-#line 1163 "libxlu_disk_l.c"
+#line 1159 "libxlu_disk_l.c"
 
        if ( !yyg->yy_init )
                {
@@ -1502,7 +1498,7 @@ YY_RULE_SETUP
 #line 259 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 1506 "libxlu_disk_l.c"
+#line 1502 "libxlu_disk_l.c"
                        case YY_STATE_EOF(INITIAL):
                        case YY_STATE_EOF(LEXERR):
                                yyterminate();
diff --git a/tools/libxl/libxlu_disk_l.h b/tools/libxl/libxlu_disk_l.h
index f615582..08f60e5 100644
--- a/tools/libxl/libxlu_disk_l.h
+++ b/tools/libxl/libxlu_disk_l.h
@@ -280,10 +280,6 @@ int xlu__disk_yyget_lineno (yyscan_t yyscanner );
 
 void xlu__disk_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
-int xlu__disk_yyget_column  (yyscan_t yyscanner );
-
-void xlu__disk_yyset_column (int column_no ,yyscan_t yyscanner );
-
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
  */
@@ -350,6 +346,6 @@ extern int xlu__disk_yylex (yyscan_t yyscanner);
 
 #line 259 "libxlu_disk_l.l"
 
-#line 354 "libxlu_disk_l.h"
+#line 350 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
 #endif /* xlu__disk_yyHEADER_H */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.