qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] Fix compilation of check-qint.c by using a l


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH v2] Fix compilation of check-qint.c by using a long long integer constant
Date: Sat, 5 Sep 2009 02:58:42 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

malc wrote:
> > > -    const int64_t value = 0xffffffffffffffff;
> > > +    const int64_t value = 0xffffffffffffffffLL;
> > 
> > Hm, well it does not really fit in a signed long long either (so from that
> > aspect it should be ULL).
> > Should it not be simply -1 (does qemu assume all architectures
> > use two's complement?)?
> 
> Yes.

Yes, but be aware that GCC nowadays does some optimisations which
assume calculations do not wraparound when using signed types.  See
-fwrapv and -fno-strict-overflow.  They tripped up the Linux kernel
recently, causing some range tests to be optimised away.  Those
optimisations warrant caution when thinking in two's complement while
using signed types.

For unsigned types, the ANSI C language uses arithmetic (mod 2^bits)
for unsigned types.  You can always write 0ULL-1, even theoretically
on non-two's complement machines: that's well-defined in C to have all
one bits set.

-- Jamie




reply via email to

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