From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5ED5A0547; Mon, 21 Jun 2021 01:30:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8717240040; Mon, 21 Jun 2021 01:30:40 +0200 (CEST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by mails.dpdk.org (Postfix) with ESMTP id 5BC944003F; Mon, 21 Jun 2021 01:30:39 +0200 (CEST) Received: by mail-lf1-f48.google.com with SMTP id h15so8466484lfv.12; Sun, 20 Jun 2021 16:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8FRI0y3ot0F4gQaNC2rZ7drYeHqMy1ptc+PGKdIyNCI=; b=u/jGXPXmdAO+7H9KPwotgjiwpb2U2EXps2oADGuwz7Lx1wf2YA1O94eeOkg4/tHEna gOEnP3TOL0Ah/j+ObHAG7ngv8XnweVpGlfedkQM/04S9fyUfgymLkyvb8qIoRL9//2GD 73n8mDsJ1cksNsx/SZa4mDGRMDBcqH/kjTNJiUCO7x9bKulmUi1XFBfZ/dQ3fVDQE6aH 8j9fId4pHZprRDlKMBc3WBFgV0KAtzcPNl5DM5K6Y++2FglDbAnPCEGcRUYa2RQ5e3a4 w4X0SBa+3ptg1d0lfvQeeyo+hx0tbAmx2R5t4GtjokiAwax/6aZIlQdd00ow/WURmP/E fRuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8FRI0y3ot0F4gQaNC2rZ7drYeHqMy1ptc+PGKdIyNCI=; b=jTU+efU0nJ9Twr3Xwq08ocUD51aNvVvOHwAgueV5vrcU3rWfDLiWrlD0694AUFNqIy 1LmszBrls6aygmFKhvnUsFeliCxOLsym/RMl3yve8ZXI3kLHyEQhZMUaQ1MuX7M0F9Gj j+EGCdnRjFwInTIGuGrGcwkhxjdTXb4gRbIRjQZrxtmY/Md0lWVdrfwoL+gxLzX+VX6l vYxbmTWL20SyVjSzJlXJEcaFvu3NCPv+LTCewh0ZHm3R477WL/5OHIHKjvtRBG42Gb21 ApaHUiRpxpocj67eThluTsd5jgYSPRQvY4d/JDUqapiK2USqAMBXIn4hOlJfeqP3X/gX /k8A== X-Gm-Message-State: AOAM533DmUab3os1OL3UHdHAelqg66ozbKIeQvQG6m0nZp9hcWKGrtM1 P4529vsErl3R0q2wFRcA5wk= X-Google-Smtp-Source: ABdhPJwjdmBUMo2iVlpNHKreFYGLptFsKAvSQd+5BPrCB/oO5mpWB89wXw8IODeusqObwDF4bbdNZg== X-Received: by 2002:ac2:4219:: with SMTP id y25mr11850921lfh.400.1624231838903; Sun, 20 Jun 2021 16:30:38 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id d15sm1673170lfl.199.2021.06.20.16.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 16:30:38 -0700 (PDT) Date: Mon, 21 Jun 2021 02:30:36 +0300 From: Dmitry Kozlyuk To: Jie Zhou Cc: dev@dpdk.org, xiaoyun.li@intel.com, roretzla@microsoft.com, talshn@nvidia.com, pallavi.kadam@intel.com, thomas@monjalon.net, bruce.richardson@intel.com, ferruh.yigit@intel.com, konstantin.ananyev@intel.com, stable@dpdk.org Message-ID: <20210621023036.61f982ca@sovereign> In-Reply-To: <1620241931-28435-5-git-send-email-jizh@linux.microsoft.com> References: <1620236174-10676-1-git-send-email-jizh@linux.microsoft.com> <1620241931-28435-1-git-send-email-jizh@linux.microsoft.com> <1620241931-28435-5-git-send-email-jizh@linux.microsoft.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v13 04/10] eal/Windows: add clock_gettime on Windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2021-05-05 12:12 (UTC-0700), Jie Zhou: > Add clock_gettime on Windows in rte_os_shim.h > > Signed-off-by: Jie Zhou > Signed-off-by: Jie Zhou > --- > lib/eal/windows/include/rte_os_shim.h | 38 +++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h > index 3763cae62..cd1f53dfa 100644 > --- a/lib/eal/windows/include/rte_os_shim.h > +++ b/lib/eal/windows/include/rte_os_shim.h > @@ -77,4 +77,42 @@ rte_timespec_get(struct timespec *now, int base) > > #endif /* RTE_TOOLCHAIN_GCC */ > > +/* Identifier for system-wide realtime clock. */ > +#define CLOCK_REALTIME 0 > +/* Monotonic system-wide clock. */ > +#define CLOCK_MONOTONIC 1 > +/* High-resolution timer from the CPU. */ > +#define CLOCK_PROCESS_CPUTIME_ID 2 > +/* Thread-specific CPU-time clock. */ > +#define CLOCK_THREAD_CPUTIME_ID 3 Are the last two constants needed? > + > +#define NS_PER_SEC 1E9 NS_PER_SEC isn't provided by any interface that we shim, but it can be defined by applications (like testpmd does), so it's better to make this constant private to rte_clock_gettime(). IMO, we should provide such constants with RTE_ prefix someday. rte_time.h provides NSEC_PER_SEC without RTE_ prefix already. > + > +typedef int clockid_t; > + > +static inline int > +rte_clock_gettime(clockid_t clock_id, struct timespec *tp) > +{ > + LARGE_INTEGER pf, pc; > + LONGLONG nsec; > + switch (clock_id) { > + case CLOCK_REALTIME: > + if (timespec_get(tp, TIME_UTC) != TIME_UTC) > + return -1; > + return 0; > + case CLOCK_MONOTONIC: > + if (QueryPerformanceFrequency(&pf) == 0) > + return -1; > + if (QueryPerformanceCounter(&pc) == 0) > + return -1; These calls never fail on any supported Windows version. > + nsec = pc.QuadPart * NS_PER_SEC / pf.QuadPart; > + tp->tv_sec = nsec / NS_PER_SEC; > + tp->tv_nsec = nsec - tp->tv_sec * NS_PER_SEC; > + return 0; > + default: > + return -1; By clock_getttime() contract, errno must be set to ENOTSUP here. > + } > +} > +#define clock_gettime(clock_id, tp) rte_clock_gettime(clock_id, tp) > + > #endif /* _RTE_OS_SHIM_ */