From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4Stk-0004X9-MH for qemu-devel@nongnu.org; Mon, 15 Jun 2015 07:49:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4Stf-0003y8-Fs for qemu-devel@nongnu.org; Mon, 15 Jun 2015 07:49:52 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4Stf-0003y0-AL for qemu-devel@nongnu.org; Mon, 15 Jun 2015 07:49:47 -0400 Received: by wgez8 with SMTP id z8so66699049wge.0 for ; Mon, 15 Jun 2015 04:49:46 -0700 (PDT) From: Alvise Rigo Date: Mon, 15 Jun 2015 13:51:22 +0200 Message-Id: <1434369088-15076-2-git-send-email-a.rigo@virtualopensystems.com> In-Reply-To: <1434369088-15076-1-git-send-email-a.rigo@virtualopensystems.com> References: <1434369088-15076-1-git-send-email-a.rigo@virtualopensystems.com> Subject: [Qemu-devel] [RFC v2 1/7] bitmap: Add bitmap_one_extend operation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mttcg@listserver.greensocs.com, claudio.fontana@huawei.com, cota@braap.org, jani.kokkonen@huawei.com, tech@virtualopensystems.com, alex.bennee@linaro.org, rth@twiddle.net Suggested-by: Jani Kokkonen Suggested-by: Claudio Fontana Signed-off-by: Alvise Rigo --- include/qemu/bitmap.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 86dd9cd..c59e8e7 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -246,4 +246,13 @@ static inline unsigned long *bitmap_zero_extend(unsigned long *old, return new; } +static inline unsigned long *bitmap_one_extend(unsigned long *old, + long old_nbits, long new_nbits) +{ + long new_len = BITS_TO_LONGS(new_nbits) * sizeof(unsigned long); + unsigned long *new = g_realloc(old, new_len); + bitmap_set(new, old_nbits, new_nbits - old_nbits); + return new; +} + #endif /* BITMAP_H */ -- 2.4.3