From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linda Subject: Re: [PATCH] tools/libxl new bitmap functions Date: Fri, 03 Apr 2015 07:48:33 -0600 Message-ID: <551E9A31.9050105@jma3.com> References: <1427996296-27980-1-git-send-email-lindaj@jma3.com> <1428053111.7917.18.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1428053111.7917.18.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli Cc: Julien Grall , "lars.kurth@xen.org" , Wei Liu , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Dario, I like your comments on naming. We'll see what others say. As far as difference, at least as I've implemented it, it's the exclusive or. To all, I've been thinking about Konrad's comment that we should disallow bitmaps of unequal size, in the XOR/difference function. I've implemented it, so the resulting bitmap is the size of the larger input bitmap, and the bits past the end of the smaller bitmap are all ones. I think this is inelegant. Another possibility, is, if two bitmaps are of unequal size, make the XOR bitmap be the size of the smaller bitmap. This would actually yield a reasonable result. What do others say? Thanks. Linda Jacobson On 4/3/2015 3:25 AM, Dario Faggioli wrote: > On Thu, 2015-04-02 at 11:38 -0600, Linda Jacobson wrote: >> From: Linda >> >> Added bitmap functions for union intersection and difference betweenn two bitmaps >> > Just wondering, about union and intersection, are them the best names > for these operations, or do we want libxl_bitmap_or() and > libxl_bitmap_and()? Personally, I'd go for _and() and _or(), it's more > common and more consistent with what we have already in the codebase. > > About difference, what it the exact intended semantic of that operation? > In set theory, AFAICR, A-B is the set of elements that are in A and are > not in B. For a binary bitmap, I'd say it is the set of bits that are > set in A and are not set in B, is it so? Whatever it is, we should write > it down somewhere, e.g., in libxl_utils.h, as the function's doc > comment. > >> --- a/tools/libxl/libxl_utils.c >> +++ b/tools/libxl/libxl_utils.c >> +int libxl_bitmap_intersection (libxl_ctx *ctx, libxl_bitmap >> +*intersection_bitmap, libxl_bitmap *bitmap1, libxl_bitmap *bitmap2) >> > Lots of long lines. Limit is 80 charathers (and keeping them a little > less than that is even better :-)) > > To make that easier to happen, in this specific case (but also because > it is more convenient in general and requires less typing), I'd use > shorter variable names. > > Perhaps not as much as ba and bb for the operands and bi for the result > (that would diverge from existing functions too much for my taste), but > at least bitmap1, bitmap2 and intersect, instead of intersection_bitmap. > Or even bitmap1 and bitmap2 for the operands, and just bitmap for the > result. > > Of course, that does not guarantee that the fucntion signature stays on > one line. If it still does not, you should break it. > > Regards, > Dario