[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions

From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields
Date: Sun, 08 Jul 2012 14:37:56 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/28/2012 08:58 AM, Markus Armbruster wrote:
>>> Better code is an argument only if the effect can be demonstrated.
>> I don't know even for which compilers or CPUs this is true so it's
>> unlikely I could demonstrate it. However, googling finds a few
>> articles in defense of this.
> Hearsay.  Your honor, I rest my case :)

On x86_64, conversion from unsigned to unsigned long takes zero
instructions, but conversion from int to long takes one instruction.  So
expressions like a[i] are one instruction shorter if the index is unsigned.

unsigned is also slightly safer from a security perspective, since you
only need to consider overflow, not underflow.

I used to be an int fan but I have been converted.  My fingers still
prefer int though.

error compiling committee.c: too many arguments to function

reply via email to

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