All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/5] tst_timer: Add nano second conversions
Date: Tue, 28 Aug 2018 11:30:00 +0200	[thread overview]
Message-ID: <20180828093002.20368-4-rpalethorpe@suse.com> (raw)
In-Reply-To: <20180828093002.20368-1-rpalethorpe@suse.com>

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/tst_timer.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/tst_timer.h b/include/tst_timer.h
index 3e4f611b0..29d5dad40 100644
--- a/include/tst_timer.h
+++ b/include/tst_timer.h
@@ -54,6 +54,11 @@ struct tst_timer {
 	struct timespec start_time;
 };
 
+static inline long long tst_timespec_to_ns(struct timespec t)
+{
+	return t.tv_sec * 1000000000 + t.tv_nsec;
+}
+
 /*
  * Converts timespec to microseconds.
  */
@@ -199,6 +204,12 @@ static inline struct timespec tst_timespec_diff(struct timespec t1,
 	return res;
 }
 
+static inline long long tst_timespec_diff_ns(struct timespec t1,
+					     struct timespec t2)
+{
+	return t1.tv_nsec - t2.tv_nsec + 1000000000LL * (t1.tv_sec - t2.tv_sec);
+}
+
 static inline long long tst_timespec_diff_us(struct timespec t1,
                                              struct timespec t2)
 {
-- 
2.18.0


  parent reply	other threads:[~2018-08-28  9:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28  9:29 [LTP] [PATCH 0/5] New fuzzy sync library API Richard Palethorpe
2018-08-28  9:29 ` [LTP] [PATCH 1/5] lib: Allow user to easily get LTP_TIMEOUT_MUL value Richard Palethorpe
2018-08-28  9:29 ` [LTP] [PATCH 2/5] tst_timer: Create interface for using multiple timers Richard Palethorpe
2018-08-28 14:23   ` Cyril Hrubis
2018-08-28  9:30 ` Richard Palethorpe [this message]
2018-08-28  9:30 ` [LTP] [PATCH 4/5] fzsync: Simplify API with start/end race calls and limit exec time Richard Palethorpe
2018-08-28 16:24   ` Cyril Hrubis
2018-08-29  8:45     ` Richard Palethorpe
2018-08-29  9:17       ` Cyril Hrubis
2018-08-30 13:03         ` Richard Palethorpe
2018-08-30  5:58   ` Li Wang
2018-08-30  8:53     ` Richard Palethorpe
2018-08-28  9:30 ` [LTP] [PATCH 5/5] Convert tests to use fzsync_{start, end}_race API Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180828093002.20368-4-rpalethorpe@suse.com \
    --to=rpalethorpe@suse.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.