diff options
Diffstat (limited to 'pkg/mtdev/patch/0002-Avoid-__builtin_ffs.patch')
| -rw-r--r-- | pkg/mtdev/patch/0002-Avoid-__builtin_ffs.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/pkg/mtdev/patch/0002-Avoid-__builtin_ffs.patch b/pkg/mtdev/patch/0002-Avoid-__builtin_ffs.patch new file mode 100644 index 00000000..37a14ae7 --- /dev/null +++ b/pkg/mtdev/patch/0002-Avoid-__builtin_ffs.patch @@ -0,0 +1,44 @@ +From 365d628a9c944989cab0bfa6ae39d1df0ec5a905 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Fri, 7 Jun 2019 11:55:26 -0700 +Subject: [PATCH] Avoid __builtin_ffs + +--- + src/common.h | 5 +---- + src/core.c | 2 +- + 2 files changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/common.h b/src/common.h +index 80a3d6e..3c77f48 100644 +--- a/src/common.h ++++ b/src/common.h +@@ -77,12 +77,9 @@ static inline int bitcount(unsigned v) + return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24; + } + +-/* Return index of first bit [0-31], -1 on zero */ +-#define firstbit(v) (__builtin_ffs(v) - 1) +- + /* boost-style foreach bit */ + #define foreach_bit(i, m) \ +- for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << (i + 1)))) ++ for (i = -1; (m) & ~0U << (i + 1);) if ((m) & 1U << ++i) + + /* robust system ioctl calls */ + #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) +diff --git a/src/core.c b/src/core.c +index 87ef420..f5b6272 100644 +--- a/src/core.c ++++ b/src/core.c +@@ -298,7 +298,7 @@ static void apply_typeA_changes(struct mtdev_state *state, + break; + } + if (id != MT_ID_NULL) { +- slot = firstbit(unused); ++ foreach_bit(slot, unused) break; + push_slot_changes(state, &data[i], prop[i], slot, syn); + SETBIT(used, slot); + CLEARBIT(unused, slot); +-- +2.20.1 + |
