From patchwork Mon Oct 5 12:58:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 54494 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id BF4EE22F05 for ; Mon, 5 Oct 2015 12:59:14 +0000 (UTC) Received: by lbos8 with SMTP id s8sf12866300lbo.2 for ; Mon, 05 Oct 2015 05:59: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:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=8iDNrj3r9zfBN5DCehrdARNeFZMDTuicIXlxoi0mExM=; b=I54S9AeBEITCekBnF5UsG8zlOfjXhtBmtlwpz3ALrP7w/BfucVvPGFGydHO42qE8T+ DQA6Za3bi6+24EO8rr2WiChxn2wS12XC/1r+f7xBYXCV1t+zcijDVP6YG1hMiBhR/651 mo+45EUmubdIfOk+qVSCWbMoGRd58zjIQ53gGv1yoUYgwtff+x4kE7jfuf5JMqdN8y8A 8c7tkoD2egXba4hx+WKaYhGGWlllMet4yhDCHpyCFMgUIkQCq6BHzkXJXBWFC3Qp6jyS 0phalvkVRGGBFuGyct245X+JZ0FEhmPD69AWHvOMAnSagIcCzbqHXVmpgXvI4+lf20RI bUfg== X-Gm-Message-State: ALoCoQkd+JO3VMr7y4YDR/sRmVX91Wx2CnjLIwWeUzMOmibuXnm2YEoWwf50JnZUlEyURqWIaG+C X-Received: by 10.112.181.10 with SMTP id ds10mr4103664lbc.3.1444049953709; Mon, 05 Oct 2015 05:59:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.169.198 with SMTP id s189ls391471lfe.87.gmail; Mon, 05 Oct 2015 05:59:13 -0700 (PDT) X-Received: by 10.25.37.196 with SMTP id l187mr7581190lfl.101.1444049953570; Mon, 05 Oct 2015 05:59:13 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id s5si16844033lbw.89.2015.10.05.05.59.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2015 05:59:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbwr8 with SMTP id r8so57220615lbw.2 for ; Mon, 05 Oct 2015 05:59:13 -0700 (PDT) X-Received: by 10.25.211.201 with SMTP id k192mr7787624lfg.32.1444049953434; Mon, 05 Oct 2015 05:59:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1247402lbq; Mon, 5 Oct 2015 05:59:11 -0700 (PDT) X-Received: by 10.107.6.139 with SMTP id f11mr27293417ioi.61.1444049951680; Mon, 05 Oct 2015 05:59:11 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x9si8445445igl.12.2015.10.05.05.59.11; Mon, 05 Oct 2015 05:59:11 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 190D661C9B; Mon, 5 Oct 2015 12:59:11 +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, URIBL_BLOCKED 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 359F961B64; Mon, 5 Oct 2015 12:58:43 +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 4F54B61B45; Mon, 5 Oct 2015 12:58:39 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by lists.linaro.org (Postfix) with ESMTPS id 180B5619DC for ; Mon, 5 Oct 2015 12:58:38 +0000 (UTC) Received: by lbwr8 with SMTP id r8so57210426lbw.2 for ; Mon, 05 Oct 2015 05:58:37 -0700 (PDT) X-Received: by 10.25.87.9 with SMTP id l9mr5848168lfb.99.1444049916966; Mon, 05 Oct 2015 05:58:36 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id p133sm4253148lfp.16.2015.10.05.05.58.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Oct 2015 05:58:36 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 5 Oct 2015 15:58:12 +0300 Message-Id: <1444049893-28349-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444049893-28349-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1444049893-28349-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 1/2] linux-generic: use cycles_diff for time API also X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Currently, time API reuses cpu API to get ticks, but uses it's own function to count diff but it can differ from cpu diff function. So, better to use the same function in order to eliminate possible difference in counting. Signed-off-by: Ivan Khoronzhuk --- platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/odp_cpu_internal.h | 29 +++++++++++++++++++++++ platform/linux-generic/odp_cpu.c | 6 ++--- platform/linux-generic/odp_time.c | 6 ++--- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 platform/linux-generic/include/odp_cpu_internal.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 202ec6a..2b4a277 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -140,6 +140,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_schedule_internal.h \ ${srcdir}/include/odp_spin_internal.h \ ${srcdir}/include/odp_timer_internal.h \ + ${srcdir}/include/odp_cpu_internal.h \ ${srcdir}/Makefile.inc __LIB__libodp_la_SOURCES = \ diff --git a/platform/linux-generic/include/odp_cpu_internal.h b/platform/linux-generic/include/odp_cpu_internal.h new file mode 100644 index 0000000..28a0a84 --- /dev/null +++ b/platform/linux-generic/include/odp_cpu_internal.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_CPU_INTERNAL_H_ +#define ODP_CPU_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +static inline +uint64_t _odp_cpu_cycles_diff(uint64_t c1, uint64_t c2) +{ + if (odp_likely(c2 >= c1)) + return c2 - c1; + + return c2 + (odp_cpu_cycles_max() - c1); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/odp_cpu.c b/platform/linux-generic/odp_cpu.c index 45a79db..e5ec4f0 100644 --- a/platform/linux-generic/odp_cpu.c +++ b/platform/linux-generic/odp_cpu.c @@ -6,11 +6,9 @@ #include #include +#include uint64_t odp_cpu_cycles_diff(uint64_t c1, uint64_t c2) { - if (odp_likely(c2 >= c1)) - return c2 - c1; - - return c2 + (odp_cpu_cycles_max() - c1); + return _odp_cpu_cycles_diff(c1, c2); } diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index b378c35..74f802b 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -10,6 +10,7 @@ #include #include #include +#include #define GIGA 1000000000 @@ -20,10 +21,7 @@ uint64_t odp_time_cycles(void) uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2) { - if (odp_likely(t2 >= t1)) - return t2 - t1; - - return t2 + (UINT64_MAX - t1); + return _odp_cpu_cycles_diff(t1, t2); } uint64_t odp_time_cycles_to_ns(uint64_t cycles)