qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 02/29] Introduce QInt


From: Paolo Bonzini
Subject: [Qemu-devel] Re: [PATCH 02/29] Introduce QInt
Date: Thu, 20 Aug 2009 11:22:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3

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 <stdint.h>

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);
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]