MinGW does not always provide ffs(3). My MinGW 4.9.2 cannot link QEMU when ./configure --enable-debug was used due to the missing ffs(3) function.
In the past we already got rid of ffsl(3) calls, so getting rid of ffs(3) is a logical next step. This series replaces ffs(3) calls with ctz32(). Their semantics differ as follows: 1. ffs(0) == 0 but ctz32(0) == 32 2. Otherwise, ffs(val) - 1 == ctz32(val) The first patch fixes a bug that was discovered when auditing ffs(3) callers. The final patch adds checkpatch.pl support to prevent ffs(3), ffsl(3), and ffsll(3) from being introduced into the codebase again in the future. Note that there are instances of 64-bit values being passed to ffs(3). I have mechanically converted them to ctz32() and not worried about whether the original code is buggy or not. Stefan Hajnoczi (7): bt-sdp: fix broken uuids power-of-2 calculation Convert (ffs(val) - 1) to ctz32(val) Convert ffs() != 0 callers to ctz32() sd: convert sd_normal_command() ffs(3) call to ctz32() omap_intc: convert ffs(3) to ctz32() in omap_inth_sir_update() os-win32: drop ffs(3) prototype checkpatch: complain about ffs(3) calls block.c | 2 +- block/qcow2-refcount.c | 2 +- block/qcow2.c | 4 ++-- block/qed.c | 4 ++-- block/rbd.c | 2 +- block/sheepdog.c | 2 +- hw/acpi/pcihp.c | 2 +- hw/arm/nseries.c | 2 +- hw/arm/omap1.c | 6 ++---- hw/arm/pxa2xx_gpio.c | 2 +- hw/arm/strongarm.c | 4 ++-- hw/bt/sdp.c | 2 +- hw/char/virtio-serial-bus.c | 8 ++++---- hw/display/tc6393xb.c | 2 +- hw/gpio/max7310.c | 2 +- hw/gpio/omap_gpio.c | 13 +++++-------- hw/gpio/zaurus.c | 2 +- hw/i2c/omap_i2c.c | 10 +++++++--- hw/intc/allwinner-a10-pic.c | 8 ++++---- hw/intc/omap_intc.c | 7 ++++--- hw/pci-host/bonito.c | 2 +- hw/pci-host/uninorth.c | 2 +- hw/pci/msi.c | 12 ++++++------ hw/pci/pcie_aer.c | 2 +- hw/pci/shpc.c | 10 +++++----- hw/pci/slotid_cap.c | 2 +- hw/ppc/ppce500_spin.c | 2 +- hw/scsi/megasas.c | 2 +- hw/sd/sd.c | 3 ++- include/hw/pci/pci.h | 16 ++++++++-------- include/hw/pci/pcie_regs.h | 18 +++++++++--------- include/sysemu/os-win32.h | 3 --- kvm-all.c | 8 ++++---- scripts/checkpatch.pl | 11 +++++++++++ target-ppc/cpu.h | 4 ++-- 35 files changed, 96 insertions(+), 87 deletions(-) -- 2.1.0