From patchwork Tue Dec 15 11:03:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 58426 Delivered-To: patch@linaro.org Received: by 10.112.129.4 with SMTP id ns4csp120168lbb; Tue, 15 Dec 2015 03:04:15 -0800 (PST) X-Received: by 10.140.101.41 with SMTP id t38mr49761999qge.53.1450177455265; Tue, 15 Dec 2015 03:04:15 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 137si646685qhs.122.2015.12.15.03.04.14; Tue, 15 Dec 2015 03:04:15 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 778CA61981; Tue, 15 Dec 2015 11:04:14 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=TToSJaAE; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 7939261094; Tue, 15 Dec 2015 11:04:07 +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 7A0B7611F8; Tue, 15 Dec 2015 11:04:02 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id E49FF6107B for ; Tue, 15 Dec 2015 11:03:57 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id p203so3750911lfa.0 for ; Tue, 15 Dec 2015 03:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=R4aTK0ZJ3dmvQxCA/f9/GyVLIgUMRDk8YpUp1l9O7s0=; b=TToSJaAEMhM9GfsHG6I6AhkJZot+wO2p6g5PGjPsdVEuZgUZR2L295RMbfPwDPPVZq 75ZQap7vwVl8He5oFOYFIjcOCHPYdFnpGlE7XzK0BsB8E4VaaINDyRJYvauhFFUUQEKv ADtv2MPyRzIssP8cP1edKbeTCJ1j/u4IXtFuc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=R4aTK0ZJ3dmvQxCA/f9/GyVLIgUMRDk8YpUp1l9O7s0=; b=TVFQ/rnh11JPUrEyVZKhgAns4vAHu+GkqKpwRPlatCQ+y5r7Yi6g8JboPXnZ1rk5ZF MRkUigIX5RHAOmvW825Y23DpAyNl/N81bJG5hDBCioVxN4U5/P9X7uWO9GM475rPZmU2 nvZjzjdnWybAO0Qj52UQ/8xBkr5XWf9PXBlaB8CzyDLR/UnMFAmtBJVFM+P9APs1ppwI 1ovZ5vkPDHBYdC6V+xtJbKzTyWBg8HxR/srQ9yuXRYjmmcr4bf5rlYeezGLkR0HIOlsO gI86CgvFWnGrZHegF6HcJCBksDhUm1s4aduqKwoNRFKxc65tI18yh88Au5f4mpc8AJ3O n/WQ== X-Gm-Message-State: ALoCoQlpk2TFagyVkTMREZhVllM+iGKRQiJMIAMxw+X3iVw7VpPodokEQouratR4XXGxlZD/UgVV9GyEEAeSpcW8FrwtLdaDnQ== X-Received: by 10.25.152.133 with SMTP id a127mr15242581lfe.152.1450177436719; Tue, 15 Dec 2015 03:03:56 -0800 (PST) Received: from [193.168.1.37] (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.googlemail.com with ESMTPSA id p69sm123546lfe.42.2015.12.15.03.03.55 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Dec 2015 03:03:55 -0800 (PST) To: lng-odp@lists.linaro.org References: <1450131276-16659-1-git-send-email-bill.fischofer@linaro.org> From: Maxim Uvarov Message-ID: <566FF39C.2050302@linaro.org> Date: Tue, 15 Dec 2015 14:03:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: X-Topics: patch Subject: Re: [lng-odp] [API-NEXT PATCHv3] linux-generic: time: remove posix bleed through on odp_time_t 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" On 12/15/2015 01:15, Bill Fischofer wrote: > v3 posted to fix doxygen issues. 1. In generated doc it looks like comment should go under @note. It will be good to put notes to the latest string in the section like other api do, but I don't know how to do it. 2. Time structure Used to.." 3. Might be it's reasonable to hide sec and nsec in doc. > > On Mon, Dec 14, 2015 at 4:14 PM, Bill Fischofer > > wrote: > > The linux-generic implementation of odp_time_t makes use of POSIX > APIs that are sensitive to the _POSIX_C_SOURCE level. Use an > indirection > mechanism so that these dependencies do not "bleed through" the > ODP API. > This means that ODP applications can be independent of _POSIX_C_SOURCE > level. > > Signed-off-by: Bill Fischofer > > --- > .../linux-generic/include/odp/plat/time_types.h | 14 +++++++--- > platform/linux-generic/odp_time.c | 30 > +++++++++++----------- > 2 files changed, 25 insertions(+), 19 deletions(-) > > diff --git a/platform/linux-generic/include/odp/plat/time_types.h > b/platform/linux-generic/include/odp/plat/time_types.h > index e5765ec..6269e40 100644 > --- a/platform/linux-generic/include/odp/plat/time_types.h > +++ b/platform/linux-generic/include/odp/plat/time_types.h > @@ -21,11 +21,17 @@ extern "C" { > * @{ > **/ > > -typedef struct timespec odp_time_t; > - > -odp_time_t odp_time_null(void); > +/** > + * Time structure > + * Used to isolate linux-generic implementation from the linux > + * timespec structure, which is dependent on _POSIX_C_SOURCE level. > + */ > +typedef struct odp_time_t { > + int64_t tv_sec; /**< Seconds */ > + int64_t tv_nsec; /**< Nanoseconds */ > +} odp_time_t; > > -#define ODP_TIME_NULL odp_time_null() > +#define ODP_TIME_NULL ((odp_time_t){0, 0}) > > /** > * @} > diff --git a/platform/linux-generic/odp_time.c > b/platform/linux-generic/odp_time.c > index 1c7c214..9b64b37 100644 > --- a/platform/linux-generic/odp_time.c > +++ b/platform/linux-generic/odp_time.c > @@ -11,7 +11,12 @@ > #include > #include > > -static struct timespec start_time; > +typedef union { > + odp_time_t ex; > + struct timespec in; > +} _odp_time_t; > + > +static odp_time_t start_time; > > static inline > uint64_t time_to_ns(odp_time_t time) > @@ -27,7 +32,7 @@ uint64_t time_to_ns(odp_time_t time) > static inline > odp_time_t time_diff(odp_time_t t2, odp_time_t t1) > { > - struct timespec time; > + odp_time_t time; > > time.tv_sec = t2.tv_sec - t1.tv_sec; > time.tv_nsec = t2.tv_nsec - t1.tv_nsec; > @@ -43,13 +48,13 @@ odp_time_t time_diff(odp_time_t t2, odp_time_t t1) > odp_time_t odp_time_local(void) > { > int ret; > - struct timespec time; > + _odp_time_t time; > > - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); > + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time.in > ); > if (odp_unlikely(ret != 0)) > ODP_ABORT("clock_gettime failed\n"); > > - return time_diff(time, start_time); > + return time_diff(time.ex, start_time); > } > > odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1) > @@ -64,7 +69,7 @@ uint64_t odp_time_to_ns(odp_time_t time) > > odp_time_t odp_time_local_from_ns(uint64_t ns) > { > - struct timespec time; > + odp_time_t time; > > time.tv_sec = ns / ODP_TIME_SEC_IN_NS; > time.tv_nsec = ns - time.tv_sec * ODP_TIME_SEC_IN_NS; > @@ -85,7 +90,7 @@ int odp_time_cmp(odp_time_t t2, odp_time_t t1) > > odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2) > { > - struct timespec time; > + odp_time_t time; > > time.tv_sec = t2.tv_sec + t1.tv_sec; > time.tv_nsec = t2.tv_nsec + t1.tv_nsec; > @@ -113,18 +118,13 @@ uint64_t odp_time_to_u64(odp_time_t time) > return time_to_ns(time) / resolution; > } > > -odp_time_t odp_time_null(void) > -{ > - return (struct timespec) {0, 0}; > -} > - > int odp_time_global_init(void) > { > int ret; > - struct timespec time; > + _odp_time_t time; > > - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); > - start_time = ret ? odp_time_null() : time; > + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time.in > ); > + start_time = ret ? ODP_TIME_NULL : time.ex; > > return ret; > } > -- > 2.1.4 > > > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp --- a/platform/linux-generic/include/odp/plat/time_types.h +++ b/platform/linux-generic/include/odp/plat/time_types.h @@ -22,13 +22,13 @@ extern "C" { **/ /** - * Time structure - * Used to isolate linux-generic implementation from the linux - * timespec structure, which is dependent on _POSIX_C_SOURCE level. + * @note Time structure used to isolate linux-generic implementation + * from the linux timespec structure, which is dependent on + * _POSIX_C_SOURCE level. */ typedef struct odp_time_t { - int64_t tv_sec; /**< Seconds */ - int64_t tv_nsec; /**< Nanoseconds */ + int64_t tv_sec; /**< @internal Seconds */ + int64_t tv_nsec; /**< @internal Nanoseconds */ } odp_time_t; #define ODP_TIME_NULL ((odp_time_t){0, 0})