]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/tools-include-adopt-linux-bits.h.patch
drop rdma-cma-consider-scope_id-while-binding-to-ipv6-ll-.patch from 4.4, 4.9, and...
[thirdparty/kernel/stable-queue.git] / queue-4.4 / tools-include-adopt-linux-bits.h.patch
1 From 8f5e9ea4ea676344ee84908bbead31776dd86cde Mon Sep 17 00:00:00 2001
2 From: Arnaldo Carvalho de Melo <acme@redhat.com>
3 Date: Tue, 25 Sep 2018 10:55:59 -0300
4 Subject: tools include: Adopt linux/bits.h
5
6 From: Arnaldo Carvalho de Melo <acme@redhat.com>
7
8 commit ba4aa02b417f08a0bee5e7b8ed70cac788a7c854 upstream.
9
10 So that we reduce the difference of tools/include/linux/bitops.h to the
11 original kernel file, include/linux/bitops.h, trying to remove the need
12 to define BITS_PER_LONG, to avoid clashes with asm/bitsperlong.h.
13
14 And the things removed from tools/include/linux/bitops.h are really in
15 linux/bits.h, so that we can have a copy and then
16 tools/perf/check_headers.sh will tell us when new stuff gets added to
17 linux/bits.h so that we can check if it is useful and if any adjustment
18 needs to be done to the tools/{include,arch}/ copies.
19
20 Cc: Adrian Hunter <adrian.hunter@intel.com>
21 Cc: Alexander Sverdlin <alexander.sverdlin@nokia.com>
22 Cc: David Ahern <dsahern@gmail.com>
23 Cc: Jiri Olsa <jolsa@kernel.org>
24 Cc: Namhyung Kim <namhyung@kernel.org>
25 Cc: Wang Nan <wangnan0@huawei.com>
26 Link: https://lkml.kernel.org/n/tip-y1sqyydvfzo0bjjoj4zsl562@git.kernel.org
27 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
28 [bwh: Backported to 4.4 as dependency of "x86/msr-index: Cleanup bit defines":
29 - Drop change in check-headers.sh
30 - Adjust context]
31 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33 ---
34 tools/include/linux/bitops.h | 7 ++-----
35 tools/include/linux/bits.h | 26 ++++++++++++++++++++++++++
36 2 files changed, 28 insertions(+), 5 deletions(-)
37 create mode 100644 tools/include/linux/bits.h
38
39 --- a/tools/include/linux/bitops.h
40 +++ b/tools/include/linux/bitops.h
41 @@ -3,17 +3,14 @@
42
43 #include <asm/types.h>
44 #include <linux/kernel.h>
45 -#include <linux/compiler.h>
46 -
47 #ifndef __WORDSIZE
48 #define __WORDSIZE (__SIZEOF_LONG__ * 8)
49 #endif
50
51 #define BITS_PER_LONG __WORDSIZE
52 +#include <linux/bits.h>
53 +#include <linux/compiler.h>
54
55 -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
56 -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
57 -#define BITS_PER_BYTE 8
58 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
59 #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
60 #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
61 --- /dev/null
62 +++ b/tools/include/linux/bits.h
63 @@ -0,0 +1,26 @@
64 +/* SPDX-License-Identifier: GPL-2.0 */
65 +#ifndef __LINUX_BITS_H
66 +#define __LINUX_BITS_H
67 +#include <asm/bitsperlong.h>
68 +
69 +#define BIT(nr) (1UL << (nr))
70 +#define BIT_ULL(nr) (1ULL << (nr))
71 +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
72 +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
73 +#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
74 +#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
75 +#define BITS_PER_BYTE 8
76 +
77 +/*
78 + * Create a contiguous bitmask starting at bit position @l and ending at
79 + * position @h. For example
80 + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
81 + */
82 +#define GENMASK(h, l) \
83 + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
84 +
85 +#define GENMASK_ULL(h, l) \
86 + (((~0ULL) - (1ULL << (l)) + 1) & \
87 + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
88 +
89 +#endif /* __LINUX_BITS_H */