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

tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros

And remove it from tools/perf/{perf,util}.h, making code that needs
these macros to include linux/time64.h instead, to match how this is
used in the kernel sources.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-e69fc1pvkgt57yvxqt6eunyg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+34 -27
+12
tools/include/linux/time64.h
··· 1 + #ifndef _TOOLS_LINUX_TIME64_H 2 + #define _TOOLS_LINUX_TIME64_H 3 + 4 + #define MSEC_PER_SEC 1000L 5 + #define USEC_PER_MSEC 1000L 6 + #define NSEC_PER_USEC 1000L 7 + #define NSEC_PER_MSEC 1000000L 8 + #define USEC_PER_SEC 1000000L 9 + #define NSEC_PER_SEC 1000000000L 10 + #define FSEC_PER_SEC 1000000000000000LL 11 + 12 + #endif /* _LINUX_TIME64_H */
+1
tools/perf/MANIFEST
··· 77 77 tools/include/linux/types.h 78 78 tools/include/linux/err.h 79 79 tools/include/linux/bitmap.h 80 + tools/include/linux/time64.h 80 81 tools/arch/*/include/uapi/asm/perf_regs.h
+1
tools/perf/builtin-kvm.c
··· 24 24 #include <sys/timerfd.h> 25 25 #endif 26 26 27 + #include <linux/time64.h> 27 28 #include <termios.h> 28 29 #include <semaphore.h> 29 30 #include <pthread.h>
+4 -3
tools/perf/builtin-script.c
··· 24 24 #include "util/thread-stack.h" 25 25 #include <linux/bitmap.h> 26 26 #include <linux/stringify.h> 27 + #include <linux/time64.h> 27 28 #include "asm/bug.h" 28 29 #include "util/mem-events.h" 29 30 ··· 465 464 466 465 if (PRINT_FIELD(TIME)) { 467 466 nsecs = sample->time; 468 - secs = nsecs / NSECS_PER_SEC; 469 - nsecs -= secs * NSECS_PER_SEC; 470 - usecs = nsecs / NSECS_PER_USEC; 467 + secs = nsecs / NSEC_PER_SEC; 468 + nsecs -= secs * NSEC_PER_SEC; 469 + usecs = nsecs / NSEC_PER_USEC; 471 470 if (nanosecs) 472 471 printf("%5lu.%09llu: ", secs, nsecs); 473 472 else
+4 -3
tools/perf/builtin-stat.c
··· 65 65 #include "util/group.h" 66 66 #include "asm/bug.h" 67 67 68 + #include <linux/time64.h> 68 69 #include <api/fs/fs.h> 69 70 #include <stdlib.h> 70 71 #include <sys/prctl.h> ··· 355 354 diff_timespec(&rs, &ts, &ref_time); 356 355 357 356 if (STAT_RECORD) { 358 - if (WRITE_STAT_ROUND_EVENT(rs.tv_sec * NSECS_PER_SEC + rs.tv_nsec, INTERVAL)) 357 + if (WRITE_STAT_ROUND_EVENT(rs.tv_sec * NSEC_PER_SEC + rs.tv_nsec, INTERVAL)) 359 358 pr_err("failed to write stat round event\n"); 360 359 } 361 360 ··· 2176 2175 update_stats(&walltime_nsecs_stats, stat_round->time); 2177 2176 2178 2177 if (stat_config.interval && stat_round->time) { 2179 - tsh.tv_sec = stat_round->time / NSECS_PER_SEC; 2180 - tsh.tv_nsec = stat_round->time % NSECS_PER_SEC; 2178 + tsh.tv_sec = stat_round->time / NSEC_PER_SEC; 2179 + tsh.tv_nsec = stat_round->time % NSEC_PER_SEC; 2181 2180 ts = &tsh; 2182 2181 } 2183 2182
+1
tools/perf/builtin-trace.c
··· 45 45 #include <linux/audit.h> 46 46 #include <linux/random.h> 47 47 #include <linux/stringify.h> 48 + #include <linux/time64.h> 48 49 49 50 #ifndef O_CLOEXEC 50 51 # define O_CLOEXEC 02000000
-7
tools/perf/perf.h
··· 14 14 #define HAVE_ATTR_TEST 15 15 #include "perf-sys.h" 16 16 17 - #ifndef NSEC_PER_SEC 18 - # define NSEC_PER_SEC 1000000000ULL 19 - #endif 20 - #ifndef NSEC_PER_USEC 21 - # define NSEC_PER_USEC 1000ULL 22 - #endif 23 - 24 17 static inline unsigned long long rdclock(void) 25 18 { 26 19 struct timespec ts;
+4 -6
tools/perf/util/debug.c
··· 6 6 #include <stdarg.h> 7 7 #include <stdio.h> 8 8 #include <api/debug.h> 9 + #include <linux/time64.h> 9 10 10 11 #include "cache.h" 11 12 #include "color.h" ··· 14 13 #include "debug.h" 15 14 #include "util.h" 16 15 #include "target.h" 17 - 18 - #define NSECS_PER_SEC 1000000000ULL 19 - #define NSECS_PER_USEC 1000ULL 20 16 21 17 int verbose; 22 18 bool dump_trace = false, quiet = false; ··· 52 54 int ret = 0; 53 55 u64 secs, usecs, nsecs = t; 54 56 55 - secs = nsecs / NSECS_PER_SEC; 56 - nsecs -= secs * NSECS_PER_SEC; 57 - usecs = nsecs / NSECS_PER_USEC; 57 + secs = nsecs / NSEC_PER_SEC; 58 + nsecs -= secs * NSEC_PER_SEC; 59 + usecs = nsecs / NSEC_PER_USEC; 58 60 59 61 ret = fprintf(stderr, "[%13" PRIu64 ".%06" PRIu64 "] ", 60 62 secs, usecs);
+3 -2
tools/perf/util/scripting-engines/trace-event-perl.c
··· 25 25 #include <ctype.h> 26 26 #include <errno.h> 27 27 #include <linux/bitmap.h> 28 + #include <linux/time64.h> 28 29 29 30 #include "../util.h" 30 31 #include <EXTERN.h> ··· 360 359 if (!test_and_set_bit(event->id, events_defined)) 361 360 define_event_symbols(event, handler, event->print_fmt.args); 362 361 363 - s = nsecs / NSECS_PER_SEC; 364 - ns = nsecs - s * NSECS_PER_SEC; 362 + s = nsecs / NSEC_PER_SEC; 363 + ns = nsecs - s * NSEC_PER_SEC; 365 364 366 365 scripting_context->event_data = data; 367 366 scripting_context->pevent = evsel->tp_format->pevent;
+3 -2
tools/perf/util/scripting-engines/trace-event-python.c
··· 27 27 #include <stdbool.h> 28 28 #include <errno.h> 29 29 #include <linux/bitmap.h> 30 + #include <linux/time64.h> 30 31 31 32 #include "../../perf.h" 32 33 #include "../debug.h" ··· 427 426 if (!dict) 428 427 Py_FatalError("couldn't create Python dict"); 429 428 } 430 - s = nsecs / NSECS_PER_SEC; 431 - ns = nsecs - s * NSECS_PER_SEC; 429 + s = nsecs / NSEC_PER_SEC; 430 + ns = nsecs - s * NSEC_PER_SEC; 432 431 433 432 scripting_context->event_data = data; 434 433 scripting_context->pevent = evsel->tp_format->pevent;
+1
tools/perf/util/util.c
··· 15 15 #include <byteswap.h> 16 16 #include <linux/kernel.h> 17 17 #include <linux/log2.h> 18 + #include <linux/time64.h> 18 19 #include <unistd.h> 19 20 #include "callchain.h" 20 21 #include "strlist.h"
-4
tools/perf/util/util.h
··· 179 179 #undef tolower 180 180 #undef toupper 181 181 182 - #ifndef NSEC_PER_MSEC 183 - #define NSEC_PER_MSEC 1000000L 184 - #endif 185 - 186 182 int parse_nsec_time(const char *str, u64 *ptime); 187 183 188 184 extern unsigned char sane_ctype[256];