diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 11:12:33 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-19 03:26:34 -0400 |
commit | 5a116dd2797677cad48fee2f42267e3cb69f5502 (patch) | |
tree | 94bc08d8c234e26c8b8caa156815964e0a56f159 /tools/perf/util/include/linux/kernel.h | |
parent | 11018201b831e19304c0d639f105ad6c27e120b1 (diff) |
perf tools: Use kernel bitmap library
Use the kernel bitmap library for internal perf tools uses.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1255792354-11304-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/include/linux/kernel.h')
-rw-r--r-- | tools/perf/util/include/linux/kernel.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index a6b87390cb52..4b9204d9b266 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h | |||
@@ -1,6 +1,16 @@ | |||
1 | #ifndef PERF_LINUX_KERNEL_H_ | 1 | #ifndef PERF_LINUX_KERNEL_H_ |
2 | #define PERF_LINUX_KERNEL_H_ | 2 | #define PERF_LINUX_KERNEL_H_ |
3 | 3 | ||
4 | #include <stdarg.h> | ||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <assert.h> | ||
8 | |||
9 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | ||
10 | |||
11 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) | ||
12 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) | ||
13 | |||
4 | #ifndef offsetof | 14 | #ifndef offsetof |
5 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | 15 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |
6 | #endif | 16 | #endif |
@@ -26,4 +36,53 @@ | |||
26 | _max1 > _max2 ? _max1 : _max2; }) | 36 | _max1 > _max2 ? _max1 : _max2; }) |
27 | #endif | 37 | #endif |
28 | 38 | ||
39 | #ifndef min | ||
40 | #define min(x, y) ({ \ | ||
41 | typeof(x) _min1 = (x); \ | ||
42 | typeof(y) _min2 = (y); \ | ||
43 | (void) (&_min1 == &_min2); \ | ||
44 | _min1 < _min2 ? _min1 : _min2; }) | ||
45 | #endif | ||
46 | |||
47 | #ifndef BUG_ON | ||
48 | #define BUG_ON(cond) assert(!(cond)) | ||
49 | #endif | ||
50 | |||
51 | /* | ||
52 | * Both need more care to handle endianness | ||
53 | * (Don't use bitmap_copy_le() for now) | ||
54 | */ | ||
55 | #define cpu_to_le64(x) (x) | ||
56 | #define cpu_to_le32(x) (x) | ||
57 | |||
58 | static inline int | ||
59 | vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | ||
60 | { | ||
61 | int i; | ||
62 | ssize_t ssize = size; | ||
63 | |||
64 | i = vsnprintf(buf, size, fmt, args); | ||
65 | |||
66 | return (i >= ssize) ? (ssize - 1) : i; | ||
67 | } | ||
68 | |||
69 | static inline int scnprintf(char * buf, size_t size, const char * fmt, ...) | ||
70 | { | ||
71 | va_list args; | ||
72 | ssize_t ssize = size; | ||
73 | int i; | ||
74 | |||
75 | va_start(args, fmt); | ||
76 | i = vsnprintf(buf, size, fmt, args); | ||
77 | va_end(args); | ||
78 | |||
79 | return (i >= ssize) ? (ssize - 1) : i; | ||
80 | } | ||
81 | |||
82 | static inline unsigned long | ||
83 | simple_strtoul(const char *nptr, char **endptr, int base) | ||
84 | { | ||
85 | return strtoul(nptr, endptr, base); | ||
86 | } | ||
87 | |||
29 | #endif | 88 | #endif |