From patchwork Wed Oct 10 14:04:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 981895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42VbSh0r9lz9sB7 for ; Thu, 11 Oct 2018 01:04:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 479F23E708A for ; Wed, 10 Oct 2018 16:04:32 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 24B533E6722 for ; Wed, 10 Oct 2018 16:04:31 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 9518C1A0147C for ; Wed, 10 Oct 2018 16:04:30 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B5A40B0C4 for ; Wed, 10 Oct 2018 14:04:29 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Wed, 10 Oct 2018 16:04:02 +0200 Message-Id: <20181010140405.24496-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181010140405.24496-1-rpalethorpe@suse.com> References: <20181010140405.24496-1-rpalethorpe@suse.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: Richard Palethorpe Subject: [LTP] [PATCH v3 1/4] tst_timer: Add nano second conversions X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe Reviewed-by: Petr Vorel --- include/tst_timer.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/tst_timer.h b/include/tst_timer.h index 0fd7ed6cf..577bc88ef 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -34,6 +34,11 @@ #include #include +static inline long long tst_timespec_to_ns(struct timespec t) +{ + return t.tv_sec * 1000000000 + t.tv_nsec; +} + /* * Converts timespec to microseconds. */ @@ -166,6 +171,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) {