]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.114/tools-include-adopt-linux-bits.h.patch
Linux 4.14.114
[thirdparty/kernel/stable-queue.git] / releases / 4.14.114 / tools-include-adopt-linux-bits.h.patch
1 From ba4aa02b417f08a0bee5e7b8ed70cac788a7c854 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 tools/include/linux/bitops.h | 7 ++-----
32 tools/include/linux/bits.h | 26 ++++++++++++++++++++++++++
33 tools/perf/check-headers.sh | 1 +
34 3 files changed, 29 insertions(+), 5 deletions(-)
35
36 --- a/tools/include/linux/bitops.h
37 +++ b/tools/include/linux/bitops.h
38 @@ -3,8 +3,6 @@
39 #define _TOOLS_LINUX_BITOPS_H_
40
41 #include <asm/types.h>
42 -#include <linux/compiler.h>
43 -
44 #ifndef __WORDSIZE
45 #define __WORDSIZE (__SIZEOF_LONG__ * 8)
46 #endif
47 @@ -12,10 +10,9 @@
48 #ifndef BITS_PER_LONG
49 # define BITS_PER_LONG __WORDSIZE
50 #endif
51 +#include <linux/bits.h>
52 +#include <linux/compiler.h>
53
54 -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
55 -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
56 -#define BITS_PER_BYTE 8
57 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
58 #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
59 #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
60 --- /dev/null
61 +++ b/tools/include/linux/bits.h
62 @@ -0,0 +1,26 @@
63 +/* SPDX-License-Identifier: GPL-2.0 */
64 +#ifndef __LINUX_BITS_H
65 +#define __LINUX_BITS_H
66 +#include <asm/bitsperlong.h>
67 +
68 +#define BIT(nr) (1UL << (nr))
69 +#define BIT_ULL(nr) (1ULL << (nr))
70 +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
71 +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
72 +#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
73 +#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
74 +#define BITS_PER_BYTE 8
75 +
76 +/*
77 + * Create a contiguous bitmask starting at bit position @l and ending at
78 + * position @h. For example
79 + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
80 + */
81 +#define GENMASK(h, l) \
82 + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
83 +
84 +#define GENMASK_ULL(h, l) \
85 + (((~0ULL) - (1ULL << (l)) + 1) & \
86 + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
87 +
88 +#endif /* __LINUX_BITS_H */
89 --- a/tools/perf/check-headers.sh
90 +++ b/tools/perf/check-headers.sh
91 @@ -11,6 +11,7 @@ include/uapi/linux/sched.h
92 include/uapi/linux/stat.h
93 include/uapi/linux/vhost.h
94 include/uapi/sound/asound.h
95 +include/linux/bits.h
96 include/linux/hash.h
97 include/uapi/linux/hw_breakpoint.h
98 arch/x86/include/asm/disabled-features.h