qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org, MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Subject: Re: [Qemu-devel] [PATCH] get rid of private bitmap functions in block/sheepdog.c, use generic ones
Date: Fri, 1 Apr 2011 22:23:32 +0200	[thread overview]
Message-ID: <20110401202332.GB31037@volta.aurel32.net> (raw)
In-Reply-To: <20110310140341.CFAFE1336E@gandalf.localdomain>

On Thu, Mar 10, 2011 at 05:03:41PM +0300, Michael Tokarev wrote:
> qemu now has generic bitmap functions,
> so don't redefine them in sheepdog.c,
> use common header instead.  A small cleanup.
> 
> Here's only one function which is actually
> used in sheepdog and gets replaced with
> a generic one (simplified):
> 
> - static inline int test_bit(int nr, const volatile unsigned long *addr)
> + static inline int test_bit(int nr, const unsigned long *addr)
>  {
> -  return ((1UL << (nr % BITS_PER_LONG))
>             & ((unsigned long*)addr)[nr / BITS_PER_LONG])) != 0;
> +  return 1UL & (addr[nr / BITS_PER_LONG] >> (nr & (BITS_PER_LONG-1)));
>  }
> 
> The body is equivalent, but the argument is not: there's
> "volatile" in there.  Why it is used for - I'm not sure.
> 
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

Thanks, applied.

> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index a54e0de..98946d7 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -13,6 +13,7 @@
>  #include "qemu-error.h"
>  #include "qemu_socket.h"
>  #include "block_int.h"
> +#include "bitops.h"
>  
>  #define SD_PROTO_VER 0x01
>  
> @@ -1829,20 +1830,6 @@ static int sd_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
>      return 0;
>  }
>  
> -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> -#define BITS_PER_BYTE        8
> -#define BITS_TO_LONGS(nr)    DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
> -#define DECLARE_BITMAP(name,bits)               \
> -    unsigned long name[BITS_TO_LONGS(bits)]
> -
> -#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
> -
> -static inline int test_bit(unsigned int nr, const unsigned long *addr)
> -{
> -    return ((1UL << (nr % BITS_PER_LONG)) &
> -            (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
> -}
> -
>  static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
>  {
>      BDRVSheepdogState *s = bs->opaque;
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

      parent reply	other threads:[~2011-04-01 20:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10 14:03 [Qemu-devel] [PATCH] get rid of private bitmap functions in block/sheepdog.c, use generic ones Michael Tokarev
2011-03-15  5:09 ` MORITA Kazutaka
2011-04-01 20:23 ` Aurelien Jarno [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110401202332.GB31037@volta.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=mjt@tls.msk.ru \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).