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 7B4C6A0C40; Fri, 16 Apr 2021 00:11:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 684871624AC; Fri, 16 Apr 2021 00:11:06 +0200 (CEST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id 4F32916245A for ; Fri, 16 Apr 2021 00:11:05 +0200 (CEST) Received: by mail-lf1-f44.google.com with SMTP id f41so18232969lfv.8 for ; Thu, 15 Apr 2021 15:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bp8AWExAnj/FZK2qvo5LceFEBMvqPw8P8+S8v5eKQxA=; b=n6usKvaWaM+9GCq1hby1OsdKNBSxZfXkXpTJlhQZ/n1jcy6y9/QEdy55m5v39UKgTM XA4eqT+mIm7KSPKmk5kZqW6JegUwN4d0g70z6UrUR7SAV46Uk0PZJgA/tId1i5EUFgAA 1Hwfc/5V+X39rFXqnplVIQaif6CGM6eeUz3eboBjJP5G/uLvYa4JOX/e32DT0UTo7W7r nDZ40fJ1rAsUEBw/dqKNdbabFaijZPVL5rqw5wNu32yVGyT1oeWFN2SNBAnyTcBECLAB Ooz0SXxOwUVq1UnaGj4Mr8QjBwKEEcTYcQ7xumPWUEWwLmGU9QYODWKY5YqH3gr9Yu+E O0cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bp8AWExAnj/FZK2qvo5LceFEBMvqPw8P8+S8v5eKQxA=; b=ErEWKM3J8sqvA2ROVxcuiZ7pA33zWoZ3OiGxIStDH2s5LAnzMcA/PCHALswmUEjfre qBcxVYKGbzU0dmZBrAgV7eQ1l4eze4hNZ9jwE9IxszUyphKjRm5aSP+NapBnFL0HJb0S flZX5pBK8CqAhnyAUnOILA6s7WDyIwJLnxBKvA9D8zRtj9yn0kWK/LcbcZT4hu8bOTjK gg+6YkJHSBUx+JyuTH8Pwu5zIz08P5TJ/VCt4RiX+1A2eeKF7TE6HNqOaoKN3ZI17sEZ tJVkz5nZhpjwBzCrlQDUxdOpyDZ8azfK+t9nXNeesasExGcZRWwgfklOjbG7cSN54CHp jrXw== X-Gm-Message-State: AOAM531LbGZ9d66GtH46c2NHW4d+T3X8f+CCq2xaK+MTdDTiy2XH9M9Y 89REDkWFYFNh5qDHeFOh4piPTTOdM8c1yqz0 X-Google-Smtp-Source: ABdhPJzjB+vdZj5+7oAtYzVDWk9Q6JV6Hzzo1ytabDMkKgDBCEQW+tRcMnQfw5uUHIIsQVp2kbu8vA== X-Received: by 2002:a05:6512:11cb:: with SMTP id h11mr838427lfr.100.1618524664683; Thu, 15 Apr 2021 15:11:04 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id d17sm105591lfb.148.2021.04.15.15.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 15:11:04 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Jie Zhou , Nick Connolly , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Fri, 16 Apr 2021 01:10:53 +0300 Message-Id: <20210415221055.1575-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210415221055.1575-1-dmitry.kozliuk@gmail.com> References: <20210324005008.24705-1-dmitry.kozliuk@gmail.com> <20210415221055.1575-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 1/3] eal/windows: add timespec_get shim for MinGW 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" MinGW-w64 does not currently implement C11 timespec_get. Add an internal shim until this is fixed on MinGW side. Signed-off-by: Dmitry Kozlyuk Acked-by: Jie Zhou Acked-by: Nick Connolly --- lib/librte_eal/windows/include/rte_os_shim.h | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/librte_eal/windows/include/rte_os_shim.h b/lib/librte_eal/windows/include/rte_os_shim.h index f40fb62d1d..e50895fd83 100644 --- a/lib/librte_eal/windows/include/rte_os_shim.h +++ b/lib/librte_eal/windows/include/rte_os_shim.h @@ -3,7 +3,10 @@ #ifndef _RTE_OS_SHIM_ #define _RTE_OS_SHIM_ +#include + #include +#include /** * @file @@ -33,4 +36,33 @@ #define IPPROTO_SCTP 132 #endif +#ifdef RTE_TOOLCHAIN_GCC + +#define TIME_UTC 1 + +static inline int +rte_timespec_get(struct timespec *now, int base) +{ + /* 100ns ticks from 1601-01-01 to 1970-01-01 */ + static const uint64_t EPOCH = 116444736000000000ULL; + static const uint64_t TICKS_PER_SEC = 10000000; + static const uint64_t NS_PER_TICK = 100; + + FILETIME ft; + uint64_t ticks; + + if (base != TIME_UTC) + return 0; + + GetSystemTimePreciseAsFileTime(&ft); + ticks = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime; + ticks -= EPOCH; + now->tv_sec = ticks / TICKS_PER_SEC; + now->tv_nsec = (ticks - now->tv_sec * TICKS_PER_SEC) * NS_PER_TICK; + return base; +} + +#define timespec_get(ts, base) rte_timespec_get(ts, base) + +#endif /* RTE_TOOLCHAIN_GCC */ #endif /* _RTE_OS_SHIM_ */ -- 2.29.3