diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2016-11-22 13:00:31 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-11-23 08:44:02 -0500 |
commit | bb5a7316b909612a382b30b568c6b0345b4b6768 (patch) | |
tree | d69b26584747f9d01550e280050c10df52c2089b /tools | |
parent | 763d8960a17126e73e7d9cd6b66e390196f48894 (diff) |
tools lib traceevent: Use USECS_PER_SEC instead of hardcoded number
Instead of using 1000000, use the define in time64.h instead.
Also remove the the duplicate defines for NSECS_PER_SEC.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20161121114149.67111981@gandalf.local.home
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 11 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 3 |
2 files changed, 6 insertions, 8 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 664c90c8e22b..c1ad1ffa7335 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <stdint.h> | 33 | #include <stdint.h> |
34 | #include <limits.h> | 34 | #include <limits.h> |
35 | #include <linux/string.h> | 35 | #include <linux/string.h> |
36 | #include <linux/time64.h> | ||
36 | 37 | ||
37 | #include <netinet/in.h> | 38 | #include <netinet/in.h> |
38 | #include "event-parse.h" | 39 | #include "event-parse.h" |
@@ -5424,8 +5425,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, | |||
5424 | use_usec_format = is_timestamp_in_us(pevent->trace_clock, | 5425 | use_usec_format = is_timestamp_in_us(pevent->trace_clock, |
5425 | use_trace_clock); | 5426 | use_trace_clock); |
5426 | if (use_usec_format) { | 5427 | if (use_usec_format) { |
5427 | secs = record->ts / NSECS_PER_SEC; | 5428 | secs = record->ts / NSEC_PER_SEC; |
5428 | nsecs = record->ts - secs * NSECS_PER_SEC; | 5429 | nsecs = record->ts - secs * NSEC_PER_SEC; |
5429 | } | 5430 | } |
5430 | 5431 | ||
5431 | if (pevent->latency_format) { | 5432 | if (pevent->latency_format) { |
@@ -5437,10 +5438,10 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, | |||
5437 | usecs = nsecs; | 5438 | usecs = nsecs; |
5438 | p = 9; | 5439 | p = 9; |
5439 | } else { | 5440 | } else { |
5440 | usecs = (nsecs + 500) / NSECS_PER_USEC; | 5441 | usecs = (nsecs + 500) / NSEC_PER_USEC; |
5441 | /* To avoid usecs larger than 1 sec */ | 5442 | /* To avoid usecs larger than 1 sec */ |
5442 | if (usecs >= 1000000) { | 5443 | if (usecs >= USEC_PER_SEC) { |
5443 | usecs -= 1000000; | 5444 | usecs -= USEC_PER_SEC; |
5444 | secs++; | 5445 | secs++; |
5445 | } | 5446 | } |
5446 | p = 6; | 5447 | p = 6; |
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 9ffde377e89d..783c842d6517 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -172,9 +172,6 @@ struct pevent_plugin_option { | |||
172 | #define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS) | 172 | #define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS) |
173 | #define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS) | 173 | #define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS) |
174 | 174 | ||
175 | #define NSECS_PER_SEC 1000000000ULL | ||
176 | #define NSECS_PER_USEC 1000ULL | ||
177 | |||
178 | enum format_flags { | 175 | enum format_flags { |
179 | FIELD_IS_ARRAY = 1, | 176 | FIELD_IS_ARRAY = 1, |
180 | FIELD_IS_POINTER = 2, | 177 | FIELD_IS_POINTER = 2, |