Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf time-utils: Adopt rdclock() from perf.h

Seems to be a better place for this function to live, further shrinking
the hodge-podge that perf.h was.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-0zzt1u9rpyjukdy1ccr2u5r9@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+11 -9
+1
tools/perf/builtin-stat.c
··· 62 62 #include "util/string2.h" 63 63 #include "util/metricgroup.h" 64 64 #include "util/target.h" 65 + #include "util/time-utils.h" 65 66 #include "util/top.h" 66 67 #include "asm/bug.h" 67 68
-9
tools/perf/perf.h
··· 2 2 #ifndef _PERF_PERF_H 3 3 #define _PERF_PERF_H 4 4 5 - #include <time.h> 6 5 #include <stdbool.h> 7 - 8 - static inline unsigned long long rdclock(void) 9 - { 10 - struct timespec ts; 11 - 12 - clock_gettime(CLOCK_MONOTONIC, &ts); 13 - return ts.tv_sec * 1000000000ULL + ts.tv_nsec; 14 - } 15 6 16 7 #ifndef MAX_NR_CPUS 17 8 #define MAX_NR_CPUS 2048
+1
tools/perf/util/event.c
··· 21 21 #include "strlist.h" 22 22 #include "thread.h" 23 23 #include "thread_map.h" 24 + #include "time-utils.h" 24 25 #include <linux/ctype.h> 25 26 #include "map.h" 26 27 #include "symbol.h"
+9
tools/perf/util/time-utils.h
··· 3 3 #define _TIME_UTILS_H_ 4 4 5 5 #include <stddef.h> 6 + #include <time.h> 6 7 #include <linux/types.h> 7 8 8 9 struct perf_time_interval { ··· 34 33 int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz); 35 34 36 35 int fetch_current_timestamp(char *buf, size_t sz); 36 + 37 + static inline unsigned long long rdclock(void) 38 + { 39 + struct timespec ts; 40 + 41 + clock_gettime(CLOCK_MONOTONIC, &ts); 42 + return ts.tv_sec * 1000000000ULL + ts.tv_nsec; 43 + } 37 44 38 45 #endif