From 39c0d633f750011b64c0c6a338f9ab79d464e5c2 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 15 Jun 2019 14:04:38 -0700 Subject: [PATCH] Use bitwise test instead of __builtin_popcount __builtin_popcount might not be available on all compilers, so using it requires a configure check and fallback implementation. In fact on gcc without an -march flag, it gets compiled to a function call to libgcc. However, we only need to test whether multiple bits are set, and this can be done easily with a bitwise and. Signed-off-by: Michael Forney --- src/evdev-mt-touchpad.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index e293fe87..a54cc2d3 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -245,10 +245,12 @@ tp_get_touch(struct tp_dispatch *tp, unsigned int slot) static inline unsigned int tp_fake_finger_count(struct tp_dispatch *tp) { + unsigned int fake_touches = + tp->fake_touches & ~(FAKE_FINGER_OVERFLOW|0x1); + /* Only one of BTN_TOOL_DOUBLETAP/TRIPLETAP/... may be set at any * time */ - if (__builtin_popcount( - tp->fake_touches & ~(FAKE_FINGER_OVERFLOW|0x1)) > 1) + if (fake_touches & (fake_touches - 1)) evdev_log_bug_kernel(tp->device, "Invalid fake finger state %#x\n", tp->fake_touches);