mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
Convert ffs() != 0 callers to ctz32()
There are a number of ffs(3) callers that do roughly: bit = ffs(val); if (bit) { do_something(bit - 1); } This pattern can be converted to ctz32() like this: zeroes = ctz32(val); if (zeroes != 32) { do_something(zeroes); } Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1427124571-28598-6-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
786a4ea82e
commit
bd2a88840e
6 changed files with 26 additions and 27 deletions
|
@ -1141,18 +1141,18 @@ static int kvm_irqchip_get_virq(KVMState *s)
|
|||
{
|
||||
uint32_t *word = s->used_gsi_bitmap;
|
||||
int max_words = ALIGN(s->gsi_count, 32) / 32;
|
||||
int i, bit;
|
||||
int i, zeroes;
|
||||
bool retry = true;
|
||||
|
||||
again:
|
||||
/* Return the lowest unused GSI in the bitmap */
|
||||
for (i = 0; i < max_words; i++) {
|
||||
bit = ffs(~word[i]);
|
||||
if (!bit) {
|
||||
zeroes = ctz32(~word[i]);
|
||||
if (zeroes == 32) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return bit - 1 + i * 32;
|
||||
return zeroes + i * 32;
|
||||
}
|
||||
if (!s->direct_msi && retry) {
|
||||
retry = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue