From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq1xv-0006ro-PZ for qemu-devel@nongnu.org; Wed, 25 Jan 2012 07:28:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq1xl-00027c-Ms for qemu-devel@nongnu.org; Wed, 25 Jan 2012 07:28:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq1xl-00027V-DG for qemu-devel@nongnu.org; Wed, 25 Jan 2012 07:28:29 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0PCSSRZ010465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Jan 2012 07:28:28 -0500 Message-ID: <4F1FF549.1070807@redhat.com> Date: Wed, 25 Jan 2012 14:27:53 +0200 From: Orit Wasserman MIME-Version: 1.0 References: <1327490809-21393-1-git-send-email-owasserm@redhat.com> <1327490809-21393-3-git-send-email-owasserm@redhat.com> <4F1FEC18.5040804@redhat.com> <4F1FF3FF.2010602@redhat.com> In-Reply-To: <4F1FF3FF.2010602@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 02/11] Add uleb encoding/decoding functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org On 01/25/2012 02:22 PM, Orit Wasserman wrote: > On 01/25/2012 01:48 PM, Avi Kivity wrote: >> On 01/25/2012 01:26 PM, Orit Wasserman wrote: >>> Implement Unsigned Little Endian Base 128. >>> >>> >>> +/* ULEB128 */ >>> +int uleb128_encode_small(uint8_t *out, uint32_t n); >>> +int uleb128_decode_small(const uint8 *in, uint32_t *n); >>> + >>> #endif >>> diff --git a/savevm.c b/savevm.c >>> index 80be1ff..304db31 100644 >>> --- a/savevm.c >>> +++ b/savevm.c >>> @@ -2297,3 +2297,29 @@ void vmstate_register_ram_global(MemoryRegion *mr) >>> { >>> vmstate_register_ram(mr, NULL); >>> } >>> + >>> +/* ULEB128 */ >>> +int uleb128_encode_small(uint8_t *out, uint32_t n) >>> +{ >> >> assert(n <= 0x3fff); >> >>> + if (n < 0x80) { >>> + *out++ = n; >>> + return 1; >>> + } else { >>> + *out++ = (n & 0x7f) | 0x80; >>> + *out++ = n >> 7; >> >> return 2? > oops , where did it go ... for some reason it is in patch 5 I will fix the patch series .. > I will fix it asp. >> >>> + } >>> + return 0; >>> +} >>> + >>> +int uleb128_decode_small(const uint8 *in, uint32_t *n) >>> +{ >>> + if (!(*in & 0x80)) { >>> + *n = *in++; >>> + return 1; >>> + } else { >>> + *n = *in++ & 0x7f; >> >> assert(!(*in & 0x80)); >> >>> + *n |= *in++ << 7; >>> + return 0; >> >> return 2? >> >>> + } >>> +} >>> + >> >> >