diff options
| -rw-r--r-- | tools/include/linux/log2.h | 26 | ||||
| -rw-r--r-- | tools/perf/MANIFEST | 3 | ||||
| -rw-r--r-- | tools/perf/Makefile.perf | 1 | ||||
| -rw-r--r-- | tools/perf/util/evlist.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/util.h | 11 |
5 files changed, 30 insertions, 12 deletions
diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h new file mode 100644 index 000000000000..141b7665d842 --- /dev/null +++ b/tools/include/linux/log2.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | /* Integer base 2 logarithm calculation | ||
| 2 | * | ||
| 3 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. | ||
| 4 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the License, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef _TOOLS_LINUX_LOG2_H | ||
| 13 | #define _TOOLS_LINUX_LOG2_H | ||
| 14 | |||
| 15 | /* | ||
| 16 | * Determine whether some value is a power of two, where zero is | ||
| 17 | * *not* considered a power of two. | ||
| 18 | */ | ||
| 19 | |||
| 20 | static inline __attribute__((const)) | ||
| 21 | bool is_power_of_2(unsigned long n) | ||
| 22 | { | ||
| 23 | return (n != 0 && ((n & (n - 1)) == 0)); | ||
| 24 | } | ||
| 25 | |||
| 26 | #endif /* _TOOLS_LINUX_LOG2_H */ | ||
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 39c08636357b..db7827fd2518 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST | |||
| @@ -7,8 +7,9 @@ tools/lib/symbol/kallsyms.h | |||
| 7 | tools/include/asm/bug.h | 7 | tools/include/asm/bug.h |
| 8 | tools/include/asm-generic/bitops/__ffs.h | 8 | tools/include/asm-generic/bitops/__ffs.h |
| 9 | tools/include/linux/compiler.h | 9 | tools/include/linux/compiler.h |
| 10 | tools/include/linux/hash.h | ||
| 11 | tools/include/linux/export.h | 10 | tools/include/linux/export.h |
| 11 | tools/include/linux/hash.h | ||
| 12 | tools/include/linux/log2.h | ||
| 12 | tools/include/linux/types.h | 13 | tools/include/linux/types.h |
| 13 | include/linux/const.h | 14 | include/linux/const.h |
| 14 | include/linux/perf_event.h | 15 | include/linux/perf_event.h |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index dbf8ca6c13cd..ec2be6404893 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
| @@ -234,6 +234,7 @@ LIB_H += util/include/linux/bitmap.h | |||
| 234 | LIB_H += util/include/linux/bitops.h | 234 | LIB_H += util/include/linux/bitops.h |
| 235 | LIB_H += ../include/asm-generic/bitops/__ffs.h | 235 | LIB_H += ../include/asm-generic/bitops/__ffs.h |
| 236 | LIB_H += ../include/linux/compiler.h | 236 | LIB_H += ../include/linux/compiler.h |
| 237 | LIB_H += ../include/linux/log2.h | ||
| 237 | LIB_H += util/include/linux/const.h | 238 | LIB_H += util/include/linux/const.h |
| 238 | LIB_H += util/include/linux/ctype.h | 239 | LIB_H += util/include/linux/ctype.h |
| 239 | LIB_H += util/include/linux/kernel.h | 240 | LIB_H += util/include/linux/kernel.h |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ac808680e61c..8eb92cf5d552 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include <linux/bitops.h> | 26 | #include <linux/bitops.h> |
| 27 | #include <linux/hash.h> | 27 | #include <linux/hash.h> |
| 28 | #include <linux/log2.h> | ||
| 28 | 29 | ||
| 29 | static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); | 30 | static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); |
| 30 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); | 31 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 008b361b1758..25b22bbea066 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
| @@ -269,17 +269,6 @@ void event_attr_init(struct perf_event_attr *attr); | |||
| 269 | #define _STR(x) #x | 269 | #define _STR(x) #x |
| 270 | #define STR(x) _STR(x) | 270 | #define STR(x) _STR(x) |
| 271 | 271 | ||
| 272 | /* | ||
| 273 | * Determine whether some value is a power of two, where zero is | ||
| 274 | * *not* considered a power of two. | ||
| 275 | */ | ||
| 276 | |||
| 277 | static inline __attribute__((const)) | ||
| 278 | bool is_power_of_2(unsigned long n) | ||
| 279 | { | ||
| 280 | return (n != 0 && ((n & (n - 1)) == 0)); | ||
| 281 | } | ||
| 282 | |||
| 283 | static inline unsigned next_pow2(unsigned x) | 272 | static inline unsigned next_pow2(unsigned x) |
| 284 | { | 273 | { |
| 285 | if (!x) | 274 | if (!x) |
