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 333B1A0547; Sat, 6 Mar 2021 01:05:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A03522A34D; Sat, 6 Mar 2021 01:05:17 +0100 (CET) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mails.dpdk.org (Postfix) with ESMTP id 201CF22A333 for ; Sat, 6 Mar 2021 01:05:15 +0100 (CET) Received: by mail-lj1-f180.google.com with SMTP id u4so5190477ljh.6 for ; Fri, 05 Mar 2021 16:05:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=mcfdSJWyeF4z+RYkBk4URyhUzLsKML9bNmS3ZaQ1Q2A=; b=kUDcTK1p+YtYU3Rm6cHS/dGrOHcOt7X7TAZZ1l6fJGqbJWRu+E29otOJc1NWuSCsXB 5a8eJ3/rWekWlYV14AHxEJuyhN4X5UvBEd1ags5mFrdCTxJ1Wm+KoMYdVw2WPf4MoMop bci/CUmpXzAv0DJazHy3CkYHEVAJ5Tz1w0p97Bw+vufmCr1dEC1HQMltkrZZV/LMXvHb nzcaN/GESiQdbexxpRyTjabmhAFbWXmeoj2dw4tDWVq40MIC7paBVJ9a0OncMq9dMo+x EWOwuX1t0DFR4TN+UbqT57RsiUSIBiIPW5jr7h/u35+TdMK84FQvYlP00GZCQZ80fRBG 8KnQ== 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=mcfdSJWyeF4z+RYkBk4URyhUzLsKML9bNmS3ZaQ1Q2A=; b=YLT3LnqzRD8iTOjtuBMN/PhMNuugUjBKXE99XG7omdEsnFYRKYmWEPLudvu68/gRW3 9oazythw/r9fG1DyNYvZFz/qs5d30Qbqx4sR6uGiXZ1wpPVlhEgGQwlGlumUtG4NuKxm zuCqL6l8YEXQvcGg/h3TvytjmqFVxiN8wOBzgj0DfgMLm2jwfeOR+9EGw0wO0Xt0CavR 2/0zaAL3opE8y0KF5WW6Ffanzask1FlIgdcB2jylCmfO81kFL/GUvxRJ2pzXdZU61DwI WhjY9GEQPujpgwjaft5oe9Bqop7FjNO2gVdvhhjaanbk01kdPoIyaSgxuqOS0nLecnqQ Himw== X-Gm-Message-State: AOAM533AzEGh1e/nhLyVT6TDeC5bA0VY+OPbPE3pBI0frNXUHwTYF/S9 gytbGNVLnTkvNfU0zDO4axOEwMweo0Nm1w== X-Google-Smtp-Source: ABdhPJxw4FIS3bIegv1B+MH9hRcDB+F68266YNtjNfLt6YvBywovkwq7QTca3A8TVdV5vUYPqzHFYA== X-Received: by 2002:a2e:a318:: with SMTP id l24mr6693625lje.399.1614989114454; Fri, 05 Mar 2021 16:05:14 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id s22sm494645ljd.28.2021.03.05.16.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 16:05:13 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Nick Connolly , Khoa To , Dmitry Kozlyuk , Olivier Matz , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Sat, 6 Mar 2021 03:05:00 +0300 Message-Id: <20210306000500.8698-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210306000500.8698-1-dmitry.kozliuk@gmail.com> References: <20210221142819.6769-1-dmitry.kozliuk@gmail.com> <20210306000500.8698-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 4/4] eal/windows: do not expose POSIX symbols 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" Exposing POSIX symbols could break consumer POSIX compatibility code. Export POSIX names for commonly used symbols only to internal consumers. Move definitions used only by EAL inside EAL. Replace deprecated [r]index() with standard str[r]chr(). Signed-off-by: Dmitry Kozlyuk --- doc/guides/rel_notes/release_21_05.rst | 3 + lib/librte_cmdline/cmdline.c | 4 - lib/librte_cmdline/cmdline_socket.c | 4 - lib/librte_eal/common/eal_common_errno.c | 4 + lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/windows/include/rte_os.h | 103 ++++----------------- 6 files changed, 27 insertions(+), 93 deletions(-) diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 5aa9ed7db..f606186ec 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -84,6 +84,9 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* eal/windows: Removed POSIX symbol export from ````. + It has been incorrect and could conflict with consumer POSIX implementations. + ABI Changes ----------- diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 79ea5f98c..49770869b 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -18,10 +18,6 @@ #include "cmdline_private.h" -#ifdef RTE_EXEC_ENV_WINDOWS -#define write _write -#endif - static void cmdline_valid_buffer(struct rdline *rdl, const char *buf, __rte_unused unsigned int size) diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c index 0fe149700..998e8ade2 100644 --- a/lib/librte_cmdline/cmdline_socket.c +++ b/lib/librte_cmdline/cmdline_socket.c @@ -16,10 +16,6 @@ #include "cmdline_private.h" #include "cmdline_socket.h" -#ifdef RTE_EXEC_ENV_WINDOWS -#define open _open -#endif - struct cmdline * cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path) { diff --git a/lib/librte_eal/common/eal_common_errno.c b/lib/librte_eal/common/eal_common_errno.c index 2a10fb823..f86802705 100644 --- a/lib/librte_eal/common/eal_common_errno.c +++ b/lib/librte_eal/common/eal_common_errno.c @@ -15,6 +15,10 @@ #include #include +#ifdef RTE_EXEC_ENV_WINDOWS +#define strerror_r(errnum, buf, buflen) strerror_s(buf, buflen, errnum) +#endif + RTE_DEFINE_PER_LCORE(int, _rte_errno); const char * diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 230bac9f3..6d4d6ff19 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1936,7 +1936,7 @@ eal_check_common_options(struct internal_config *internal_cfg) RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n"); return -1; } - if (index(eal_get_hugefile_prefix(), '%') != NULL) { + if (strchr(eal_get_hugefile_prefix(), '%') != NULL) { RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" " "option\n"); return -1; diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h index 7ef38ff06..d97e07890 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -11,7 +11,6 @@ * Windows OS. It must not include Windows-specific headers. */ -#include #include #include #include @@ -20,100 +19,36 @@ extern "C" { #endif -/* limits.h replacement, value as in */ -#ifndef PATH_MAX -#define PATH_MAX _MAX_PATH -#endif - -#ifndef sleep -#define sleep(x) Sleep(1000 * (x)) -#endif - -#ifndef strerror_r -#define strerror_r(a, b, c) strerror_s(b, c, a) -#endif - -#ifndef strdup -/* strdup is deprecated in Microsoft libc and _strdup is preferred */ -#define strdup(str) _strdup(str) -#endif - -#ifndef strtok_r -#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) -#endif - -#ifndef index -#define index(a, b) strchr(a, b) -#endif - -#ifndef rindex -#define rindex(a, b) strrchr(a, b) -#endif - -#ifndef strncasecmp -#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count) -#endif - -#ifndef close -#define close _close -#endif - -#ifndef unlink -#define unlink _unlink -#endif - /* 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) -/* as in */ -typedef long long ssize_t; - -#ifndef RTE_TOOLCHAIN_GCC - -static inline int -asprintf(char **buffer, const char *format, ...) -{ - int size, ret; - va_list arg; - - va_start(arg, format); - size = vsnprintf(NULL, 0, format, arg); - va_end(arg); - if (size < 0) - return -1; - size++; +/* Allow DPDK to call common functions by POSIX names. */ +#ifdef RTE_BUILD_INTERNAL - *buffer = (char *)malloc(size); - if (*buffer == NULL) - return -1; - - va_start(arg, format); - ret = vsnprintf(*buffer, size, format, arg); - va_end(arg); - if (ret != size - 1) { - free(*buffer); - return -1; - } - return ret; -} +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif -static inline const char * -eal_strerror(int code) -{ - static char buffer[128]; +#define strdup(str) _strdup(str) +#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) +#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count) - strerror_s(buffer, sizeof(buffer), code); - return buffer; -} +#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__) +#define read(fd, buf, n) _read(fd, buf, n) +#define write(fd, buf, n) _write(fd, buf, n) +#define close(fd) _close(fd) +#define unlink(path) _unlink(path) -#ifndef strerror -#define strerror eal_strerror -#endif +#endif /* RTE_BUILD_INTERNAL */ -#endif /* RTE_TOOLCHAIN_GCC */ +/* This is an exception without "rte_" prefix, because Windows does have + * ssize_t, but it's defined in which we avoid to expose. + * If ssize_t is defined in user code, it necessarily has the same type. + */ +typedef long long ssize_t; #ifdef __cplusplus } -- 2.29.2