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 1DD20A0562; Mon, 30 Mar 2020 06:10:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA9061C033; Mon, 30 Mar 2020 06:10:43 +0200 (CEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by dpdk.org (Postfix) with ESMTP id A474F1BFDF for ; Mon, 30 Mar 2020 06:10:39 +0200 (CEST) Received: by mail-lf1-f41.google.com with SMTP id t11so531296lfe.4 for ; Sun, 29 Mar 2020 21:10:39 -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=o9RGsVnkzc71K8NQSttLjQ5gIO5ZGC4FNfsSKAXb6Pk=; b=N3o2nSMhXgMHHpZD/CABEF0AQZ/hoONPG8zGdV+tfap1RDbvl0DuOmzrl8qRXurQoB Cy4CesiWsFrn2IINj6UkeA8lN/n1b29EPGBQJR/LY63vdm0yNd2ScniDg+gpZ6zrmZBb bLysTVpUo6v7lcbR2UaigSlJIHddeJq7YBylp4VU2NrGrtcU/d8AJYGFL1rYWoDTPDfb ubORJ4MNiegstFJ1iXLzyyF0mN4y8RN7zL8ByddU/+us9uSq78VoH8atbV6nDCkWOYXR szJEkb9DGUYtMfHtKO4YehCvC81EhXp9BGd9WFfrp2Jt6qlNiNpNqLVl0FhKd+5skDrm 4GHQ== 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=o9RGsVnkzc71K8NQSttLjQ5gIO5ZGC4FNfsSKAXb6Pk=; b=j9fTx5xPNKcA5Epg8RShNjCvnSHMQ4mn0kqoNnLA+Oq7V4tXXNG/NhXh5ooD7gJo3x 2CwR7U4EoJmSnSs7zh/0miEepGvdySDz3fV+ri6xa9p3kV5e/MTEBWue7fcf8zEG87is sJHXitXbDj2D3zyrKntFNG2XCu0QqT4ts845k/5osOV/NQQIKauYgBm2/41Y3q/by1Yl XGgHySnHSYeNoJDmTJ8ZVNgO/AghtJo4olBLjSMKJhiD6JnQ/XqqUL5BNmRtQYt0vUVD MBX/KwiS6t1xRQ0pQuvqPZRBa16ozwgoP72y3Su6fkKUZYBXIP1So1pBOyfouI4gERa/ o0dw== X-Gm-Message-State: AGi0PuYpEOxTq0XMthCAzHutI5lAa81KFK00/K+aIT41neQvDS3pfHGj mSCzGT0avSVx83h+sOwvdc4/uBDQbVBi+Q== X-Google-Smtp-Source: APiQypJwTkPrblG3oQTmhoDcJIn1n7GOoYEcUkui1ezAkkZR4F6cMO6YrRwlhLgv6vATAt4EXDtdDA== X-Received: by 2002:a19:6144:: with SMTP id m4mr6696015lfk.192.1585541438805; Sun, 29 Mar 2020 21:10:38 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id c22sm6210036lja.86.2020.03.29.21.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 21:10:38 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: "Dmitry Malloy (MESHCHANINOV)" , Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon , Thomas Monjalon , Anand Rawat Date: Mon, 30 Mar 2020 07:10:19 +0300 Message-Id: <20200330041026.784624-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200330041026.784624-1-dmitry.kozliuk@gmail.com> References: <20200330041026.784624-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC PATCH 2/9] eal/windows: do not expose private EAL facilities 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 prevent breaking otherwise portable code by including rte_os.h on Windows. 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: 428eb983f5f7 ("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 | 2 + 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 | 44 ++++++------------- .../windows/eal/include/rte_windows.h | 41 +++++++++++++++++ lib/librte_eal/windows/eal/meson.build | 1 + 8 files changed, 91 insertions(+), 31 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 e4b50df3b..2cf7a04ef 100644 --- a/lib/librte_eal/windows/eal/eal.c +++ b/lib/librte_eal/windows/eal/eal.c @@ -18,6 +18,8 @@ #include #include +#include "eal_windows.h" + /* Allow the application to print its usage message too if set */ static rte_usage_hook_t rte_application_usage_hook; diff --git a/lib/librte_eal/windows/eal/eal_lcore.c b/lib/librte_eal/windows/eal/eal_lcore.c index b3a6c63af..82ee45413 100644 --- a/lib/librte_eal/windows/eal/eal_lcore.c +++ b/lib/librte_eal/windows/eal/eal_lcore.c @@ -2,12 +2,14 @@ * Copyright(c) 2019 Intel Corporation */ +#include #include #include #include "eal_private.h" #include "eal_thread.h" +#include "eal_windows.h" /* global data structure that contains the CPU map */ static struct _wcpu_map { diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c index 9e4bbaa08..e149199a6 100644 --- a/lib/librte_eal/windows/eal/eal_thread.c +++ b/lib/librte_eal/windows/eal/eal_thread.c @@ -14,6 +14,7 @@ #include #include "eal_private.h" +#include "eal_windows.h" RTE_DEFINE_PER_LCORE(unsigned int, _lcore_id) = LCORE_ID_ANY; RTE_DEFINE_PER_LCORE(unsigned int, _socket_id) = (unsigned int)SOCKET_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 b9dd18e56..cfd53f0b8 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 e1e0378e6..510e39e03 100644 --- a/lib/librte_eal/windows/eal/include/rte_os.h +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -8,20 +8,18 @@ /** * 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. */ +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include -#include -#include -#include - -/* limits.h replacement */ -#include +/* limits.h replacement, value as in */ #ifndef PATH_MAX #define PATH_MAX _MAX_PATH #endif @@ -31,8 +29,6 @@ extern "C" { /* strdup is deprecated in Microsoft libc and _strdup is preferred */ #define strdup(str) _strdup(str) -typedef SSIZE_T ssize_t; - #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) #define index(a, b) strchr(a, b) @@ -40,22 +36,14 @@ typedef SSIZE_T ssize_t; #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count) -/** - * 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); +/* cpu_set macros implementation */ +#define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2) +#define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2) +#define RTE_CPU_FILL(set) CPU_FILL(set) +#define RTE_CPU_NOT(dst, src) CPU_NOT(dst, src) -/** - * Create a map of processors and cores on the system. - * This function is private to EAL. - */ -void eal_create_cpu_map(void); +/* as in */ +typedef long long ssize_t; #ifndef RTE_TOOLCHAIN_GCC static inline int @@ -86,12 +74,6 @@ asprintf(char **buffer, const char *format, ...) } #endif /* RTE_TOOLCHAIN_GCC */ -/* cpu_set macros implementation */ -#define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2) -#define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2) -#define RTE_CPU_FILL(set) CPU_FILL(set) -#define RTE_CPU_NOT(dst, src) CPU_NOT(dst, src) - #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..ed6e4c148 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/rte_windows.h @@ -0,0 +1,41 @@ +/* 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 with proper options and defines error-handling macros. + */ + +/* Disable excessive libraries. */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +/* Must come first. */ +#include + +#include +#include + +/* Have GUIDs defined. */ +#ifndef INITGUID +#define INITGUID +#endif +#include + +/** + * Log GetLastError() with context, usually a Win32 API function and arguments. + */ +#define RTE_LOG_WIN32_ERR(...) \ + RTE_LOG(DEBUG, EAL, RTE_FMT("GetLastError()=%lu: " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", GetLastError(), \ + RTE_FMT_TAIL(__VA_ARGS__,))) + +#endif /* _RTE_WINDOWS_H_ */ diff --git a/lib/librte_eal/windows/eal/meson.build b/lib/librte_eal/windows/eal/meson.build index 2a062c365..21cd84459 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_bus.c', -- 2.25.1