diff options
Diffstat (limited to 'tools/perf/util/util.h')
-rw-r--r-- | tools/perf/util/util.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c8f362daba87..6995d66f225c 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -71,8 +71,9 @@ | |||
71 | #include <linux/magic.h> | 71 | #include <linux/magic.h> |
72 | #include "types.h" | 72 | #include "types.h" |
73 | #include <sys/ttydefaults.h> | 73 | #include <sys/ttydefaults.h> |
74 | #include <lk/debugfs.h> | 74 | #include <api/fs/debugfs.h> |
75 | #include <termios.h> | 75 | #include <termios.h> |
76 | #include <linux/bitops.h> | ||
76 | 77 | ||
77 | extern const char *graph_line; | 78 | extern const char *graph_line; |
78 | extern const char *graph_dotted_line; | 79 | extern const char *graph_dotted_line; |
@@ -185,6 +186,8 @@ static inline void *zalloc(size_t size) | |||
185 | return calloc(1, size); | 186 | return calloc(1, size); |
186 | } | 187 | } |
187 | 188 | ||
189 | #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) | ||
190 | |||
188 | static inline int has_extension(const char *filename, const char *ext) | 191 | static inline int has_extension(const char *filename, const char *ext) |
189 | { | 192 | { |
190 | size_t len = strlen(filename); | 193 | size_t len = strlen(filename); |
@@ -253,7 +256,8 @@ bool strlazymatch(const char *str, const char *pat); | |||
253 | int strtailcmp(const char *s1, const char *s2); | 256 | int strtailcmp(const char *s1, const char *s2); |
254 | char *strxfrchar(char *s, char from, char to); | 257 | char *strxfrchar(char *s, char from, char to); |
255 | unsigned long convert_unit(unsigned long value, char *unit); | 258 | unsigned long convert_unit(unsigned long value, char *unit); |
256 | int readn(int fd, void *buf, size_t size); | 259 | ssize_t readn(int fd, void *buf, size_t n); |
260 | ssize_t writen(int fd, void *buf, size_t n); | ||
257 | 261 | ||
258 | struct perf_event_attr; | 262 | struct perf_event_attr; |
259 | 263 | ||
@@ -280,6 +284,17 @@ static inline unsigned next_pow2(unsigned x) | |||
280 | return 1ULL << (32 - __builtin_clz(x - 1)); | 284 | return 1ULL << (32 - __builtin_clz(x - 1)); |
281 | } | 285 | } |
282 | 286 | ||
287 | static inline unsigned long next_pow2_l(unsigned long x) | ||
288 | { | ||
289 | #if BITS_PER_LONG == 64 | ||
290 | if (x <= (1UL << 31)) | ||
291 | return next_pow2(x); | ||
292 | return (unsigned long)next_pow2(x >> 32) << 32; | ||
293 | #else | ||
294 | return next_pow2(x); | ||
295 | #endif | ||
296 | } | ||
297 | |||
283 | size_t hex_width(u64 v); | 298 | size_t hex_width(u64 v); |
284 | int hex2u64(const char *ptr, u64 *val); | 299 | int hex2u64(const char *ptr, u64 *val); |
285 | 300 | ||
@@ -307,4 +322,11 @@ char *get_srcline(struct dso *dso, unsigned long addr); | |||
307 | void free_srcline(char *srcline); | 322 | void free_srcline(char *srcline); |
308 | 323 | ||
309 | int filename__read_int(const char *filename, int *value); | 324 | int filename__read_int(const char *filename, int *value); |
325 | int filename__read_str(const char *filename, char **buf, size_t *sizep); | ||
326 | int perf_event_paranoid(void); | ||
327 | |||
328 | void mem_bswap_64(void *src, int byte_size); | ||
329 | void mem_bswap_32(void *src, int byte_size); | ||
330 | |||
331 | const char *get_filename_for_perf_kvm(void); | ||
310 | #endif /* GIT_COMPAT_UTIL_H */ | 332 | #endif /* GIT_COMPAT_UTIL_H */ |