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

Re: [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



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

_______________________________________________
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®.