From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C95E4A0524; Fri, 31 Jan 2020 06:24:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4057C1C0B9; Fri, 31 Jan 2020 06:24:31 +0100 (CET) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by dpdk.org (Postfix) with ESMTP id D12631C042 for ; Fri, 31 Jan 2020 06:24:29 +0100 (CET) Received: by mail-lj1-f173.google.com with SMTP id q8so5834367ljb.2 for ; Thu, 30 Jan 2020 21:24:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eLKrOq+d5qYM+jHyjFZssfyBD1SHpQl331WR15vF8FM=; b=ORX91xOQ0bwjo/fn/L+AzLPABt+vXuAjKyzyqrVRPwELq8QqAfvQpXosp32c2gBpV2 dtfhZjdIdE9GpS/xKgJG49mNcVzw5b7OnEiJldCxinQVBpktLEzzPM87riGsS8Vuj3g4 MCjYz7hSVr6SRn9PLpAleCdRZr5c+kLGpjdARXKJotDfD2I4febjv6L6o6r4KGfqMmJS V7QSBFREYYD4Srawb2VB7HfOy3BSDdqXAwtPAoO1GrdJTTVFKgBf0Jn/3iZEaDOLIN7v 6EgO03kz3H5hDPI8F6UNdZQXGLkHDVx9xr3Ueg6Kc//cyD3wjAaARs4mBF3kE3GUlxdU adgQ== 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:mime-version :content-transfer-encoding; bh=eLKrOq+d5qYM+jHyjFZssfyBD1SHpQl331WR15vF8FM=; b=QluA0dAHv/a7iPKz+y7A/sfNzzY8YG8NRd95KwWloVfZItXS7VBn19MgE5sUIKWLKy gSHF7tN3r2/8GyvoT6zuhMPXea9juk4DKRXaDejmzvY1wGY+ZjSG1eIrUcaEY2vQekPp P5KCL8dIoMH8WCbrJt2HLyrJ3BbdYfXdepl+tG7zjno/cVtfYSvrJYdvxpO97i7LSRkm +ZeT1LNk0XP+FMRH+UHP5nidpAoZC1N+j4XTqHq70PWUY1HGbXX6YKjXbg5A/ZRLHXTw fA8SBGs+9fkOh0GoulP7VPc4DegXgr6zY3YrdGI2wOxVRX1Vh1Vm6W5K8yak/tHEN6fS fd7w== X-Gm-Message-State: APjAAAXBhbAFj9AJygjStfS6fyE+dJ2bzUxmN07zjY0Dboyc1GQ7PvYr GdhPFh0oyI9dYSchGlZ/k+hAfmfDWMhY9A== X-Google-Smtp-Source: APXvYqz3OWmp5EmaqoKFIv1F8MqyLTFzoqPrtib8bvHC9Z8jSe/BbWtxjHm4S/66kH5ljSCxbiGMOw== X-Received: by 2002:a2e:b0f5:: with SMTP id h21mr5083316ljl.9.1580448268912; Thu, 30 Jan 2020 21:24:28 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id l16sm3865228lfh.74.2020.01.30.21.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 21:24:28 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon Date: Fri, 31 Jan 2020 08:24:20 +0300 Message-Id: <20200131052421.33525-1-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal/windows: refine public interface X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" The goal of rte_os.h is to mitigate OS differences for EAL users. In Windows EAL, rte_os.h did excessive things: 1. It included platform SDK headers (windows.h, etc). Those files are huge, require specific inclusion order, and are generally unused by the code including rte_os.h. Declarations from platform SDK may break otherwise platform-independent code, e.g. min, max, ERROR. 2. It included pthread.h, which is clearly not always required. 3. It defined functions private to Windows EAL. Reorganize Windows EAL includes in the following way: 1. Create rte_windows.h to properly import Windows-specific facilities. Primary users are bus drivers, tests, and external applications. 2. Remove platform SDK includes from rte_os.h to make it portable. Copy necessary definitions to avoid including those headers. 3. Remove pthread.h include from rte_os.h. 4. Move declarations private to Windows EAL into eal_windows.h. Fixes: 428eb983 ("eal: add OS specific header file") Signed-off-by: Dmitry Kozlyuk --- lib/librte_eal/windows/eal/eal.c | 2 ++ lib/librte_eal/windows/eal/eal_lcore.c | 3 ++ lib/librte_eal/windows/eal/eal_thread.c | 1 + lib/librte_eal/windows/eal/eal_windows.h | 29 +++++++++++++++++++ lib/librte_eal/windows/eal/include/pthread.h | 2 ++ lib/librte_eal/windows/eal/include/rte_os.h | 26 ++--------------- .../windows/eal/include/rte_windows.h | 24 +++++++++++++++ lib/librte_eal/windows/eal/meson.build | 1 + 8 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 lib/librte_eal/windows/eal/eal_windows.h create mode 100644 lib/librte_eal/windows/eal/include/rte_windows.h diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c index ce460481f..25b0c341c 100644 --- a/lib/librte_eal/windows/eal/eal.c +++ b/lib/librte_eal/windows/eal/eal.c @@ -11,6 +11,8 @@ #include #include +#include "eal_windows.h" + /* Address of global and public configuration */ static struct rte_config rte_config; diff --git a/lib/librte_eal/windows/eal/eal_lcore.c b/lib/librte_eal/windows/eal/eal_lcore.c index d39f348a3..7a81127d3 100644 --- a/lib/librte_eal/windows/eal/eal_lcore.c +++ b/lib/librte_eal/windows/eal/eal_lcore.c @@ -2,10 +2,13 @@ * Copyright(c) 2019 Intel Corporation */ +#include #include #include +#include "eal_windows.h" + /* global data structure that contains the CPU map */ static struct _wcpu_map { unsigned int total_procs; diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c index 0591d4c7f..0d9127804 100644 --- a/lib/librte_eal/windows/eal/eal_thread.c +++ b/lib/librte_eal/windows/eal/eal_thread.c @@ -13,6 +13,7 @@ #include #include "eal_private.h" +#include "eal_windows.h" RTE_DEFINE_PER_LCORE(unsigned int, _lcore_id) = LCORE_ID_ANY; diff --git a/lib/librte_eal/windows/eal/eal_windows.h b/lib/librte_eal/windows/eal/eal_windows.h new file mode 100644 index 000000000..fadd676b2 --- /dev/null +++ b/lib/librte_eal/windows/eal/eal_windows.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _EAL_WINDOWS_H_ +#define _EAL_WINDOWS_H_ + +/** + * @file Facilities private to Windows EAL + */ + +#include + +/** + * Create a map of processors and cores on the system. + */ +void eal_create_cpu_map(void); + +/** + * Create a thread. + * + * @param thread + * The location to store the thread id if successful. + * @return + * 0 for success, -1 if the thread is not created. + */ +int eal_thread_create(pthread_t *thread); + +#endif /* _EAL_WINDOWS_H_ */ diff --git a/lib/librte_eal/windows/eal/include/pthread.h b/lib/librte_eal/windows/eal/include/pthread.h index 503329266..c181a59f7 100644 --- a/lib/librte_eal/windows/eal/include/pthread.h +++ b/lib/librte_eal/windows/eal/include/pthread.h @@ -5,6 +5,8 @@ #ifndef _PTHREAD_H_ #define _PTHREAD_H_ +#include + /** * This file is required to support the common code in eal_common_proc.c, * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc diff --git a/lib/librte_eal/windows/eal/include/rte_os.h b/lib/librte_eal/windows/eal/include/rte_os.h index fdeae0c8f..d9485d44d 100644 --- a/lib/librte_eal/windows/eal/include/rte_os.h +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -8,43 +8,23 @@ /** * This is header should contain any function/macro definition * which are not supported natively or named differently in the - * Windows OS. Functions will be added in future releases. + * Windows OS. It must not include Windows-specific headers. */ #ifdef __cplusplus extern "C" { #endif -#include -#include -#include - #define strerror_r(a, b, c) strerror_s(b, c, a) /* strdup is deprecated in Microsoft libc and _strdup is preferred */ #define strdup(str) _strdup(str) -typedef SSIZE_T ssize_t; +/* as in */ +typedef long long ssize_t; #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) -/** - * Create a thread. - * This function is private to EAL. - * - * @param thread - * The location to store the thread id if successful. - * @return - * 0 for success, -1 if the thread is not created. - */ -int eal_thread_create(pthread_t *thread); - -/** - * Create a map of processors and cores on the system. - * This function is private to EAL. - */ -void eal_create_cpu_map(void); - #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/windows/eal/include/rte_windows.h b/lib/librte_eal/windows/eal/include/rte_windows.h new file mode 100644 index 000000000..1cc9ddc35 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/rte_windows.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _RTE_WINDOWS_H_ +#define _RTE_WINDOWS_H_ + +/** + * @file Windows-specific facilities + * + * This file should be included by DPDK libraries and applications + * that need access to Windows API. It includes platform SDK headers + * in compatible order and with proper options. + * + * Future versions may include macros for Windows-specific error handling. + */ + +#define WIN32_LEAN_AND_MEAN /* Disable excessive libraries. */ +#define INITGUID /* Have GUIDs defined. */ + +#include +#include + +#endif /* _RTE_WINDOWS_H_ */ diff --git a/lib/librte_eal/windows/eal/meson.build b/lib/librte_eal/windows/eal/meson.build index af4f70f00..dd6721c57 100644 --- a/lib/librte_eal/windows/eal/meson.build +++ b/lib/librte_eal/windows/eal/meson.build @@ -6,6 +6,7 @@ eal_inc += include_directories('include') env_objs = [] env_headers = files( 'include/rte_os.h', + 'include/rte_windows.h', ) common_sources = files( '../../common/eal_common_errno.c', -- 2.25.0