diff options
author | Michael Forney <mforney@mforney.org> | 2019-06-15 14:04:38 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-06-15 15:24:10 -0700 |
commit | 39c0d633f750011b64c0c6a338f9ab79d464e5c2 (patch) | |
tree | 963d642c50fe66d04f49c473acd50cdb5849d589 /src | |
parent | 7160db054af95a8eef1707929b5a54da1e23340d (diff) | |
download | libinput-39c0d633f750011b64c0c6a338f9ab79d464e5c2.tar.gz |
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 <mforney@mforney.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev-mt-touchpad.c | 6 |
1 files 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); |