From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Me3rL-0006kX-3F for qemu-devel@nongnu.org; Thu, 20 Aug 2009 05:23:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Me3rF-0006e1-8t for qemu-devel@nongnu.org; Thu, 20 Aug 2009 05:23:01 -0400 Received: from [199.232.76.173] (port=53500 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Me3rF-0006dn-1H for qemu-devel@nongnu.org; Thu, 20 Aug 2009 05:22:57 -0400 Received: from mail-qy0-f174.google.com ([209.85.221.174]:55475) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Me3rE-0008Mj-Lw for qemu-devel@nongnu.org; Thu, 20 Aug 2009 05:22:56 -0400 Received: by qyk4 with SMTP id 4so3648512qyk.4 for ; Thu, 20 Aug 2009 02:22:56 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4A8D15EA.6050403@gnu.org> Date: Thu, 20 Aug 2009 11:22:50 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> <1250723280-3509-3-git-send-email-lcapitulino@redhat.com> <4A8D0094.6040901@redhat.com> In-Reply-To: <4A8D0094.6040901@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 02/29] Introduce QInt List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, Luiz Capitulino On 08/20/2009 09:51 AM, Avi Kivity wrote: > On 08/20/2009 02:07 AM, Luiz Capitulino wrote: >> QInt is a high-level data type that can be used to store integers >> and perform type-safe conversions. >> >> The following functions are available: >> >> - qint_from_int() Create a new QInt from an int >> - qint_from_int64() Create a new QInt from an int64_t >> - qint_to_int() Export QInt to int >> - qint_to_uint64() Export QInt to uint64_t >> - qint_to_uint32() Export QInt to uint32_t > > Why aren't the conversion functions symmetrical? I guess because an uint32_t would extend directly to uint64_t. But, the solution would be to drop qint_from_int (since also an int32_t extends correctly to uint64_t [1]) and rename qint_from_int64: Paolo [1] example program to avoid getting into C standardese: #include int f(uint64_t i) { printf ("%lld\n", i); } int main() { int32_t i = -1<<31; uint32_t j = 1 << 31; f(i); f(j); }