aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-11-21 11:19:57 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-26 10:36:14 -0400
commit20cb87df8710eef56722e214a1f9958c9d7c21e2 (patch)
tree92378390b880e0cc74e54c5d0bc515f6a57c2813
parent6e56f83c99f2661734f65dc1d7065b9c3c66af43 (diff)
downloadtrace-cmd-20cb87df8710eef56722e214a1f9958c9d7c21e2.tar.gz
trace-cmd: Add time64.h to be like the kernel
Add time64.h and use the time conversion macros there to keep parse-event.h similar to the kernel tree. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--event-parse.c11
-rw-r--r--event-parse.h5
-rw-r--r--include/linux/time64.h12
-rw-r--r--trace-input.c4
-rw-r--r--trace-profile.c6
5 files changed, 25 insertions, 13 deletions
diff --git a/event-parse.c b/event-parse.c
index 2b85b339..82062278 100644
--- a/event-parse.c
+++ b/event-parse.c
@@ -33,6 +33,7 @@
#include <stdint.h>
#include <limits.h>
#include <linux/string.h>
+#include <linux/time64.h>
#include <netinet/in.h>
#include "event-parse.h"
@@ -5450,8 +5451,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
use_usec_format = is_timestamp_in_us(pevent->trace_clock,
use_trace_clock);
if (use_usec_format) {
- secs = record->ts / NSECS_PER_SEC;
- nsecs = record->ts - secs * NSECS_PER_SEC;
+ secs = record->ts / NSEC_PER_SEC;
+ nsecs = record->ts - secs * NSEC_PER_SEC;
}
if (pevent->latency_format) {
@@ -5463,10 +5464,10 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
usecs = nsecs;
p = 9;
} else {
- usecs = (nsecs + 500) / NSECS_PER_USEC;
+ usecs = (nsecs + 500) / NSEC_PER_USEC;
/* To avoid usecs larger than 1 sec */
- if (usecs >= USECS_PER_SEC) {
- usecs -= USECS_PER_SEC;
+ if (usecs >= USEC_PER_SEC) {
+ usecs -= USEC_PER_SEC;
secs++;
}
p = 6;
diff --git a/event-parse.h b/event-parse.h
index a3fd9b28..3f5bb6c0 100644
--- a/event-parse.h
+++ b/event-parse.h
@@ -172,11 +172,6 @@ struct pevent_plugin_option {
#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
-#define NSECS_PER_SEC 1000000000ULL
-#define NSECS_PER_USEC 1000ULL
-
-#define USECS_PER_SEC 1000000ULL
-
enum format_flags {
FIELD_IS_ARRAY = 1,
FIELD_IS_POINTER = 2,
diff --git a/include/linux/time64.h b/include/linux/time64.h
new file mode 100644
index 00000000..df926548
--- /dev/null
+++ b/include/linux/time64.h
@@ -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 */
diff --git a/trace-input.c b/trace-input.c
index eee581f3..e7d447b4 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -36,6 +36,8 @@
#include <ctype.h>
#include <errno.h>
+#include <linux/time64.h>
+
#include "trace-cmd-local.h"
#include "trace-local.h"
#include "kbuffer.h"
@@ -2090,7 +2092,7 @@ void tracecmd_set_ts2secs(struct tracecmd_input *handle,
{
double ts2secs;
- ts2secs = (double)NSECS_PER_SEC / (double)hz;
+ ts2secs = (double)NSEC_PER_SEC / (double)hz;
handle->ts2secs = ts2secs;
handle->use_trace_clock = false;
}
diff --git a/trace-profile.c b/trace-profile.c
index 0b0444db..507a0c35 100644
--- a/trace-profile.c
+++ b/trace-profile.c
@@ -29,6 +29,8 @@
#include "trace-local.h"
#include "trace-hash.h"
+#include <linux/time64.h>
+
#ifdef WARN_NO_AUDIT
# warning "lib audit not found, using raw syscalls " \
"(install libaudit-devel and try again)"
@@ -46,12 +48,12 @@
static unsigned long long nsecs_per_sec(unsigned long long ts)
{
- return ts / NSECS_PER_SEC;
+ return ts / NSEC_PER_SEC;
}
static unsigned long long mod_to_usec(unsigned long long ts)
{
- return ((ts % NSECS_PER_SEC) + NSECS_PER_USEC / 2) / NSECS_PER_USEC;
+ return ((ts % NSEC_PER_SEC) + NSEC_PER_USEC / 2) / NSEC_PER_USEC;
}
struct handle_data;