* [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
@ 2015-04-10 1:51 Linda Jacobson
2015-04-10 8:56 ` Wei Liu
0 siblings, 1 reply; 4+ messages in thread
From: Linda Jacobson @ 2015-04-10 1:51 UTC (permalink / raw)
To: xen-devel; +Cc: julien.grall, lars.kurth.xen, wei.liu2, lindaj
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [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
2015-04-10 1:51 [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
@ 2015-04-10 8:56 ` Wei Liu
[not found] ` <5527B10A.3060803@jma3.com>
0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2015-04-10 8:56 UTC (permalink / raw)
To: Linda Jacobson; +Cc: julien.grall, xen-devel, wei.liu2, lars.kurth.xen
Please edit the subject line to be more concise. Something like:
libxl: provide libxl_bitmap_{and,or}
On Thu, Apr 09, 2015 at 07:51:28PM -0600, Linda Jacobson wrote:
> Linda Jacobson
You need to properly sign off this patch. See
http://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
> ---
> 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 +-----
The changes to libxlu_disk_* are not necessary. Presumably this is due
to you have different version of bison / flex installed.
I guess you used "git commit -a" to commit all the changes, right?
To avoid committing unrelated changes, you can use
$ git add libxl_utils.c
$ git add libxl_utils.h
$ git commit -s
to only commit changes to libxl_utils.{c,h}.
(the "-s" for git commit will nicely generate a Signed-off-by line for
you, provided you have configured your name and email properly in git)
> 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
> +*/
The indentation of this comment needs to be fixed.
> + size = max(map1->size, map2->size);
> + rc = libxl_bitmap_alloc(ctx, or_map, size);
> + if (rc)
> + goto out;
Add a blank line here.
> + for (bit = 0; bit < (size * 8); bit++)
> + {
Please move the `{' to the end of last line.
> + 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);
> + }
Add a blank line here.
> +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
> +*/
Fix indentation please.
> + size = min(map1->size, map2->size);
> + rc = libxl_bitmap_alloc(ctx, and_map, size);
> + if (rc)
> + goto out;
Add blank line.
> + for (bit = 0; bit < (size * 8); bit++)
> + {
Move `{' up.
> + if (libxl_bitmap_test (map1, bit) &&
> + libxl_bitmap_test (map2, bit) )
^
extraneous space
> + libxl_bitmap_set (and_map, bit);
> + }
Add a blank line.
> +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,
or_bitmap
Use the same name you used in actual function.
> + libxl_bitmap *bitmap1, libxl_bitmap *bitmap2);
> +int libxl_bitmap_and(libxl_ctx *ctx, libxl_bitmap *new_bitmap,
and_bitmap
> + libxl_bitmap *bitmap1, libxl_bitmap *bitmap2);
> static inline void libxl_bitmap_set_any(libxl_bitmap *bitmap)
> {
> memset(bitmap->map, -1, bitmap->size);
The rest (changes to libxlu_disk_l.*) should not be committed.
Wei.
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [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
[not found] ` <20150410112201.GC16939@zion.uk.xensource.com>
@ 2015-04-10 11:23 ` Wei Liu
2015-04-10 12:13 ` Linda
0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2015-04-10 11:23 UTC (permalink / raw)
To: Linda; +Cc: Wei Liu, xen-devel
Now really CC xen-devel. :-/
On Fri, Apr 10, 2015 at 12:22:02PM +0100, Wei Liu wrote:
> CC xen-devel. Please use reply-all in the future.
>
> On Fri, Apr 10, 2015 at 05:16:26AM -0600, Linda wrote:
> > a few questions below, and I'll make all the changes you suggest.
> >
> > On 4/10/2015 2:56 AM, Wei Liu wrote:
> > >Please edit the subject line to be more concise. Something like:
> > > libxl: provide libxl_bitmap_{and,or}
> > >
> > >On Thu, Apr 09, 2015 at 07:51:28PM -0600, Linda Jacobson wrote:
> > >>Linda Jacobson
> > >You need to properly sign off this patch. See
> > >
> > > http://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
> > >
> > >>---
> > >> 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 +-----
> > >The changes to libxlu_disk_* are not necessary. Presumably this is due
> > >to you have different version of bison / flex installed.
> > >
> > >I guess you used "git commit -a" to commit all the changes, right?
> > >
> > >To avoid committing unrelated changes, you can use
> > >
> > > $ git add libxl_utils.c
> > > $ git add libxl_utils.h
> > > $ git commit -s
> > >
> > >to only commit changes to libxl_utils.{c,h}.
> > >
> > >(the "-s" for git commit will nicely generate a Signed-off-by line for
> > >you, provided you have configured your name and email properly in git)
> > I hope I configured my name and email properly - I used git user.name (Linda
> > Jacobson) and git user.email (lindaj@jma3.com). Is that correct? I think
>
> I think so.
>
> > that the -s is the way I did it last time, because it did give
> > me a signature.
> >
>
> Yes, that's what we want.
>
> > So how do I uncommit the things I accidentally committed?
>
> git reset HEAD^ can reset your commit (provided the first commit in your
> tree is this commit).
>
> Wei.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [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
2015-04-10 11:23 ` Wei Liu
@ 2015-04-10 12:13 ` Linda
0 siblings, 0 replies; 4+ messages in thread
From: Linda @ 2015-04-10 12:13 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel
On 4/10/2015 5:23 AM, Wei Liu wrote:
> Now really CC xen-devel. :-/
>
> On Fri, Apr 10, 2015 at 12:22:02PM +0100, Wei Liu wrote:
>> CC xen-devel. Please use reply-all in the future.
>>
>> On Fri, Apr 10, 2015 at 05:16:26AM -0600, Linda wrote:
>>> a few questions below, and I'll make all the changes you suggest.
>>>
>>> On 4/10/2015 2:56 AM, Wei Liu wrote:
>>>> Please edit the subject line to be more concise. Something like:
>>>> libxl: provide libxl_bitmap_{and,or}
>>>>
>>>> On Thu, Apr 09, 2015 at 07:51:28PM -0600, Linda Jacobson wrote:
>>>>> Linda Jacobson
>>>> You need to properly sign off this patch. See
>>>>
>>>> http://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
>>>>
>>>>> ---
>>>>> 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 +-----
>>>> The changes to libxlu_disk_* are not necessary. Presumably this is due
>>>> to you have different version of bison / flex installed.
>>>>
>>>> I guess you used "git commit -a" to commit all the changes, right?
>>>>
>>>> To avoid committing unrelated changes, you can use
>>>>
>>>> $ git add libxl_utils.c
>>>> $ git add libxl_utils.h
>>>> $ git commit -s
>>>>
>>>> to only commit changes to libxl_utils.{c,h}.
>>>>
>>>> (the "-s" for git commit will nicely generate a Signed-off-by line for
>>>> you, provided you have configured your name and email properly in git)
>>> I hope I configured my name and email properly - I used git user.name (Linda
>>> Jacobson) and git user.email (lindaj@jma3.com). Is that correct? I think
>> I think so.
>>
>>> that the -s is the way I did it last time, because it did give
>>> me a signature.
>>>
>> Yes, that's what we want.
>>
>>> So how do I uncommit the things I accidentally committed?
>> git reset HEAD^ can reset your commit (provided the first commit in your
>> tree is this commit).
>>
>> Wei.
It should be. I've got to go now, but the fixes will be in late today
(mid-day here).
And thanks, for all your help and guidance.
Linda
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-10 12:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10 1:51 [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
2015-04-10 8:56 ` Wei Liu
[not found] ` <5527B10A.3060803@jma3.com>
[not found] ` <20150410112201.GC16939@zion.uk.xensource.com>
2015-04-10 11:23 ` Wei Liu
2015-04-10 12:13 ` Linda
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.