tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 5 Aug 2016 18:40:30 +0000 (15:40 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 23 Aug 2016 18:37:33 +0000 (15:37 -0300)
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>
12 files changed:
tools/include/linux/time64.h [new file with mode: 0644]
tools/perf/MANIFEST
tools/perf/builtin-kvm.c
tools/perf/builtin-script.c
tools/perf/builtin-stat.c
tools/perf/builtin-trace.c
tools/perf/perf.h
tools/perf/util/debug.c
tools/perf/util/scripting-engines/trace-event-perl.c
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/util.c
tools/perf/util/util.h

diff --git a/tools/include/linux/time64.h b/tools/include/linux/time64.h
new file mode 100644 (file)
index 0000000..df92654
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _TOOLS_LINUX_TIME64_H
+#define _TOOLS_LINUX_TIME64_H
+
+#define MSEC_PER_SEC   1000L
+#define USEC_PER_MSEC  1000L
+#define NSEC_PER_USEC  1000L
+#define NSEC_PER_MSEC  1000000L
+#define USEC_PER_SEC   1000000L
+#define NSEC_PER_SEC   1000000000L
+#define FSEC_PER_SEC   1000000000000000LL
+
+#endif /* _LINUX_TIME64_H */
index ad2534df4ba6ce988429510b5c35360c253299cf..f23a5e72aaa581a449d5f3263ef4ce9377237457 100644 (file)
@@ -77,4 +77,5 @@ tools/include/linux/stringify.h
 tools/include/linux/types.h
 tools/include/linux/err.h
 tools/include/linux/bitmap.h
+tools/include/linux/time64.h
 tools/arch/*/include/uapi/asm/perf_regs.h
index 5e2127e04f8386c4aa92b62e0370afff08d9e9b5..a0040f74e935f0626171c23852f6b9e1b6248884 100644 (file)
@@ -24,6 +24,7 @@
 #include <sys/timerfd.h>
 #endif
 
+#include <linux/time64.h>
 #include <termios.h>
 #include <semaphore.h>
 #include <pthread.h>
index c859e59dfe3e7efae711fa056967c910a987d989..6b3c8b0d327633c39136bc71ba2474b35f734a2b 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/thread-stack.h"
 #include <linux/bitmap.h>
 #include <linux/stringify.h>
+#include <linux/time64.h>
 #include "asm/bug.h"
 #include "util/mem-events.h"
 
@@ -464,9 +465,9 @@ static void print_sample_start(struct perf_sample *sample,
 
        if (PRINT_FIELD(TIME)) {
                nsecs = sample->time;
-               secs = nsecs / NSECS_PER_SEC;
-               nsecs -= secs * NSECS_PER_SEC;
-               usecs = nsecs / NSECS_PER_USEC;
+               secs = nsecs / NSEC_PER_SEC;
+               nsecs -= secs * NSEC_PER_SEC;
+               usecs = nsecs / NSEC_PER_USEC;
                if (nanosecs)
                        printf("%5lu.%09llu: ", secs, nsecs);
                else
index 3c7452b39f57649b05d675db3d19395fb765df2d..e33a66bffbdb1d4a6d9f18dd9461252ab97c3747 100644 (file)
@@ -65,6 +65,7 @@
 #include "util/group.h"
 #include "asm/bug.h"
 
+#include <linux/time64.h>
 #include <api/fs/fs.h>
 #include <stdlib.h>
 #include <sys/prctl.h>
@@ -354,7 +355,7 @@ static void process_interval(void)
        diff_timespec(&rs, &ts, &ref_time);
 
        if (STAT_RECORD) {
-               if (WRITE_STAT_ROUND_EVENT(rs.tv_sec * NSECS_PER_SEC + rs.tv_nsec, INTERVAL))
+               if (WRITE_STAT_ROUND_EVENT(rs.tv_sec * NSEC_PER_SEC + rs.tv_nsec, INTERVAL))
                        pr_err("failed to write stat round event\n");
        }
 
@@ -2175,8 +2176,8 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
                update_stats(&walltime_nsecs_stats, stat_round->time);
 
        if (stat_config.interval && stat_round->time) {
-               tsh.tv_sec  = stat_round->time / NSECS_PER_SEC;
-               tsh.tv_nsec = stat_round->time % NSECS_PER_SEC;
+               tsh.tv_sec  = stat_round->time / NSEC_PER_SEC;
+               tsh.tv_nsec = stat_round->time % NSEC_PER_SEC;
                ts = &tsh;
        }
 
index b8c6766301db90ddbe1dfa1fb65d2ab0a024ecc7..b4fc1ab3d2a706b3b684d3699988fcb7bd663900 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/audit.h>
 #include <linux/random.h>
 #include <linux/stringify.h>
+#include <linux/time64.h>
 
 #ifndef O_CLOEXEC
 # define O_CLOEXEC             02000000
index cb0f1356ff8149b4d0790e3d181cd6802f6886f0..9a0236a4cf95fb7226af43e33b88e351359b8a2b 100644 (file)
@@ -14,13 +14,6 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 #define HAVE_ATTR_TEST
 #include "perf-sys.h"
 
-#ifndef NSEC_PER_SEC
-# define NSEC_PER_SEC                  1000000000ULL
-#endif
-#ifndef NSEC_PER_USEC
-# define NSEC_PER_USEC                 1000ULL
-#endif
-
 static inline unsigned long long rdclock(void)
 {
        struct timespec ts;
index 8c4212abd19b48b9e84ca1f9978f06561c05576a..c1838b643108bda4d6fc536ae232f20e643a9ce2 100644 (file)
@@ -6,6 +6,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <api/debug.h>
+#include <linux/time64.h>
 
 #include "cache.h"
 #include "color.h"
@@ -14,9 +15,6 @@
 #include "util.h"
 #include "target.h"
 
-#define NSECS_PER_SEC  1000000000ULL
-#define NSECS_PER_USEC 1000ULL
-
 int verbose;
 bool dump_trace = false, quiet = false;
 int debug_ordered_events;
@@ -54,9 +52,9 @@ static int veprintf_time(u64 t, const char *fmt, va_list args)
        int ret = 0;
        u64 secs, usecs, nsecs = t;
 
-       secs   = nsecs / NSECS_PER_SEC;
-       nsecs -= secs  * NSECS_PER_SEC;
-       usecs  = nsecs / NSECS_PER_USEC;
+       secs   = nsecs / NSEC_PER_SEC;
+       nsecs -= secs  * NSEC_PER_SEC;
+       usecs  = nsecs / NSEC_PER_USEC;
 
        ret = fprintf(stderr, "[%13" PRIu64 ".%06" PRIu64 "] ",
                      secs, usecs);
index 5d1eb1ccd96c3e0cf73449c97aaee9246d1f9619..e55a132f69b73e23661bf1a6e21aaac36cbb85ad 100644 (file)
@@ -25,6 +25,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <linux/bitmap.h>
+#include <linux/time64.h>
 
 #include "../util.h"
 #include <EXTERN.h>
@@ -359,8 +360,8 @@ static void perl_process_tracepoint(struct perf_sample *sample,
        if (!test_and_set_bit(event->id, events_defined))
                define_event_symbols(event, handler, event->print_fmt.args);
 
-       s = nsecs / NSECS_PER_SEC;
-       ns = nsecs - s * NSECS_PER_SEC;
+       s = nsecs / NSEC_PER_SEC;
+       ns = nsecs - s * NSEC_PER_SEC;
 
        scripting_context->event_data = data;
        scripting_context->pevent = evsel->tp_format->pevent;
index e0203b97947483d82042c3a568f01c73878eb6a9..089438da1f7f76b2318dd2f5b10bc039441e2fc4 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdbool.h>
 #include <errno.h>
 #include <linux/bitmap.h>
+#include <linux/time64.h>
 
 #include "../../perf.h"
 #include "../debug.h"
@@ -426,8 +427,8 @@ static void python_process_tracepoint(struct perf_sample *sample,
                if (!dict)
                        Py_FatalError("couldn't create Python dict");
        }
-       s = nsecs / NSECS_PER_SEC;
-       ns = nsecs - s * NSECS_PER_SEC;
+       s = nsecs / NSEC_PER_SEC;
+       ns = nsecs - s * NSEC_PER_SEC;
 
        scripting_context->event_data = data;
        scripting_context->pevent = evsel->tp_format->pevent;
index cee559d8c9e8e14ebedbbb5c8de081c00af7f63d..85c56800f17a6018eb080db40e9a08b03f9a460c 100644 (file)
@@ -15,6 +15,7 @@
 #include <byteswap.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
+#include <linux/time64.h>
 #include <unistd.h>
 #include "callchain.h"
 #include "strlist.h"
index e5f55477491d6c60f02053f9b19ae1ba57eb5b80..43899e0d6fa148d80ebc08643d1fa9cf73ef93e9 100644 (file)
@@ -179,10 +179,6 @@ static inline void *zalloc(size_t size)
 #undef tolower
 #undef toupper
 
-#ifndef NSEC_PER_MSEC
-#define NSEC_PER_MSEC  1000000L
-#endif
-
 int parse_nsec_time(const char *str, u64 *ptime);
 
 extern unsigned char sane_ctype[256];