Skip to content

Commit cae68d4

Browse files
committed
tools: Move code originally from asm-generic/atomic.h into tools/include/asm-generic/
To match the Linux kernel source code structure from where this code came from. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-1ldjhvioch1uczilno5e1epl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0389cd1 commit cae68d4

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
2+
#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
3+
4+
#include <asm/types.h>
5+
6+
static inline void set_bit(int nr, unsigned long *addr)
7+
{
8+
addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG);
9+
}
10+
11+
static inline void clear_bit(int nr, unsigned long *addr)
12+
{
13+
addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG));
14+
}
15+
16+
static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
17+
{
18+
return ((1UL << (nr % __BITS_PER_LONG)) &
19+
(((unsigned long *)addr)[nr / __BITS_PER_LONG])) != 0;
20+
}
21+
22+
#endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */

‎tools/perf/MANIFEST‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tools/lib/api
55
tools/lib/symbol/kallsyms.c
66
tools/lib/symbol/kallsyms.h
77
tools/include/asm/bug.h
8+
tools/include/asm-generic/bitops/atomic.h
89
tools/include/asm-generic/bitops/__ffs.h
910
tools/include/linux/compiler.h
1011
tools/include/linux/export.h

‎tools/perf/Makefile.perf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ LIB_H += ../include/linux/hash.h
232232
LIB_H += ../../include/linux/stringify.h
233233
LIB_H += util/include/linux/bitmap.h
234234
LIB_H += util/include/linux/bitops.h
235+
LIB_H += ../include/asm-generic/bitops/atomic.h
235236
LIB_H += ../include/asm-generic/bitops/__ffs.h
236237
LIB_H += ../include/linux/compiler.h
237238
LIB_H += ../include/linux/log2.h

‎tools/perf/util/include/linux/bitops.h‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,7 @@
2929
(bit) < (size); \
3030
(bit) = find_next_bit((addr), (size), (bit) + 1))
3131

32-
static inline void set_bit(int nr, unsigned long *addr)
33-
{
34-
addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);
35-
}
36-
37-
static inline void clear_bit(int nr, unsigned long *addr)
38-
{
39-
addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG));
40-
}
41-
42-
static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
43-
{
44-
return ((1UL << (nr % BITS_PER_LONG)) &
45-
(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
46-
}
32+
#include <asm-generic/bitops/atomic.h>
4733

4834
static inline unsigned long hweight_long(unsigned long w)
4935
{

0 commit comments

Comments
 (0)