From patchwork Wed Sep 14 17:16:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 76229 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1982927qgf; Wed, 14 Sep 2016 10:16:20 -0700 (PDT) X-Received: by 10.237.34.47 with SMTP id n44mr4548645qtc.89.1473873380380; Wed, 14 Sep 2016 10:16:20 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s127si3656572qkc.40.2016.09.14.10.16.19; Wed, 14 Sep 2016 10:16:20 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B37D0616D9; Wed, 14 Sep 2016 17:16:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 84A65609D5; Wed, 14 Sep 2016 17:16:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6F79C609DE; Wed, 14 Sep 2016 17:16:14 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 777A36067E for ; Wed, 14 Sep 2016 17:16:13 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id g62so15150409lfe.3 for ; Wed, 14 Sep 2016 10:16:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XKjvrwBH+72YbPBg4s1FXtyLvx3RJ2ibT4n8uM6x4gg=; b=mfxucF010ZQl7verWY2rNeq0jCdrmHx9Dr4k2fDTofI6fPMrWRRXDxkyazWILNAVy4 kuHMd3os3TpcRNaPgwYFx2ECcIH+KhbFYcgbSKf/8iSNgv6x8TC7tDNZ55eE4jd5D8CR j9ik4nstPBXsEmtLHIP9rAftR1VW2ttBx3DzjyXdNi2bpWu/0K3mt4Pg+43la3hvPk+q i/yfDmvuspVKissQQeSfHTxrZkmRUJ8PCMnafLGLa37kfqX2ng17MaYYfaTQz5HFket8 A1iKNBRjfcIMVDVu8eLOazjDdeBPjGjCedkf4JT6XWyl1MFOBpeICHVKvPG4ogAOsGOE sg6Q== X-Gm-Message-State: AE9vXwMHZpPgi358S+zMpHeyPDMMmvCteg3eXTD4V1yYf38C85NqM2Sa0TktiUkCj62/xTtEzN8= X-Received: by 10.25.142.200 with SMTP id q191mr1768157lfd.1.1473873372232; Wed, 14 Sep 2016 10:16:12 -0700 (PDT) Received: from localhost.localdomain ([83.220.239.155]) by smtp.gmail.com with ESMTPSA id 131sm2690044ljj.0.2016.09.14.10.16.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Sep 2016 10:16:11 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 14 Sep 2016 20:16:02 +0300 Message-Id: <1473873362-15242-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2] api: odp_time_sub X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Previously we had odp_time_sum but missing call to subtract some value from odp_time_t. Because on different platforms it can be implemented differently we need this call. Signed-off-by: Maxim Uvarov --- include/odp/api/spec/time.h | 10 ++++++++++ platform/linux-generic/odp_time.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) -- 2.7.1.250.gff4ea60 diff --git a/include/odp/api/spec/time.h b/include/odp/api/spec/time.h index fcc94c9..5e94b70 100644 --- a/include/odp/api/spec/time.h +++ b/include/odp/api/spec/time.h @@ -87,6 +87,16 @@ odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1); odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2); /** + * Time subtract + * + * @param t1 Time stamp to subtract from + * @param t2 Value to subtract + * + * @return Time stamp t1 - t2 + */ +odp_time_t odp_time_sub(odp_time_t t1, odp_time_t t2); + +/** * Convert time to nanoseconds * * @param time Time diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index 81e0522..7fef46f 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -81,6 +81,18 @@ static inline odp_time_t time_sum(odp_time_t t1, odp_time_t t2) return time; } +static inline odp_time_t time_sub(odp_time_t t1, odp_time_t t2) +{ + uint64_t ns; + odp_time_t time; + + ns = time_to_ns(t1) - time_to_ns(t2); + time.tv_sec = ns / ODP_TIME_SEC_IN_NS; + time.tv_nsec = ns - time.tv_sec * ODP_TIME_SEC_IN_NS; + + return time; +} + static inline odp_time_t time_local_from_ns(uint64_t ns) { odp_time_t time; @@ -152,6 +164,11 @@ odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2) return time_sum(t1, t2); } +odp_time_t odp_time_sub(odp_time_t t1, odp_time_t t2) +{ + return time_sub(t1, t2); +} + uint64_t odp_time_local_res(void) { return time_local_res();