linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
0001-Avoid-__builtin_ffs.patch
(1324B)
1 From 09e21bb5d6714687705dc8f2d00a09b3ff3b2436 Mon Sep 17 00:00:00 2001
2 From: Michael Forney <mforney@mforney.org>
3 Date: Fri, 7 Jun 2019 11:55:26 -0700
4 Subject: [PATCH] Avoid __builtin_ffs
5
6 ---
7 src/common.h | 5 +----
8 src/core.c | 2 +-
9 2 files changed, 2 insertions(+), 5 deletions(-)
10
11 diff --git a/src/common.h b/src/common.h
12 index 80a3d6e..3c77f48 100644
13 --- a/src/common.h
14 +++ b/src/common.h
15 @@ -77,12 +77,9 @@ static inline int bitcount(unsigned v)
16 return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24;
17 }
18
19 -/* Return index of first bit [0-31], -1 on zero */
20 -#define firstbit(v) (__builtin_ffs(v) - 1)
21 -
22 /* boost-style foreach bit */
23 #define foreach_bit(i, m) \
24 - for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << (i + 1))))
25 + for (i = -1; (m) & ~0U << (i + 1);) if ((m) & 1U << ++i)
26
27 /* robust system ioctl calls */
28 #define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
29 diff --git a/src/core.c b/src/core.c
30 index 0d91c0b..20ce0c6 100644
31 --- a/src/core.c
32 +++ b/src/core.c
33 @@ -304,7 +304,7 @@ static void apply_typeA_changes(struct mtdev_state *state,
34 break;
35 }
36 if (id != MT_ID_NULL) {
37 - slot = firstbit(unused);
38 + foreach_bit(slot, unused) break;
39 push_slot_changes(state, &data[i], prop[i], slot, syn);
40 SETBIT(used, slot);
41 CLEARBIT(unused, slot);
42 --
43 2.25.0
44