From patchwork Sat Jun 20 21:05:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71822 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 095C7A051C; Sat, 20 Jun 2020 23:05:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 259DD1BFBC; Sat, 20 Jun 2020 23:05:23 +0200 (CEST) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by dpdk.org (Postfix) with ESMTP id 1B6CF1BFAE for ; Sat, 20 Jun 2020 23:05:20 +0200 (CEST) Received: by mail-lf1-f65.google.com with SMTP id d7so7487190lfi.12 for ; Sat, 20 Jun 2020 14:05:20 -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=ENUhdIfK4CmepfQyGTyZI9cxe4Jmh3NvhWeWsAAo2iA=; b=WAVCmfdVyg/gHpmP180kmr4MyaxzfNl8droNZA3CvbYZhzpTEgTSnrDX4z9jf2Wiqc O/xL5UpACf0FOvEeUSoO326KMkYQcAOe3Qebu+4V5drmqfc54/Xm6OCmHyrjeVUJsFas 8FPC1VSW9+CY6yPmngJ/O9UdNd4GiqKtIpIiDL/fSseDioK7jhoyIEVdTGeVYkvIJ05i tY21+IuDEi2O4d0KQ0OGFDWMfW93R862VWQXe0iVlhcrpuJUFXVREYpJuMbd5ELmEYLo NzOjkllRUZeU8fc8pwkoETuOtIYyG/diZ2rzcdzMiAkj0W4dHNoJcRA/VXbUwf6PKXn5 sifA== 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=ENUhdIfK4CmepfQyGTyZI9cxe4Jmh3NvhWeWsAAo2iA=; b=nn3C/dTzt9MVmCGXCTCbgCcOQ6CVCZq7rpt7bbHUiIbOAGxvLSe4R0wY8TOEWLHU8C Mk5EkG7X6Ltlz0vsJHbIqDngmKbS0lkouVSND90Gt1Z/J9P0tzPlBghE1f39cW94Mn1F 3CzdaLBZWWWAkF53dsPqmXNUW+qSSeaio4uZVFUUnoA14CPjWOGSv95B7wmV3iOPVhVn YRYsf7nWyypsnZHxeZa0I9/eFAAdu26ivYDdMveiAR5GvAUaAi1Rg4t9uz32fSm/FMTb 3nhZd3icQt6UuFLilmjqnK3iXL53DvWEcZe7krX8lVey77DgVImCZCgR1g2seW4WvIRD I4Gw== X-Gm-Message-State: AOAM533pQJhKPwpJ87nqFKiF+2YfQHmAssKPcL30+C4ZMljSZdaPDScx mHJ1IApwhVMW9yQWBHZyPsK8sjN5Y1B1sw== X-Google-Smtp-Source: ABdhPJyI9CZV+y8k7vBj+wA8YJaVSBxzNZijiV/0xN9bzmK0yo3p9wIdOkTIKvWSqWInC4vuyWZMPg== X-Received: by 2002:ac2:5e29:: with SMTP id o9mr5317610lfg.196.1592687119422; Sat, 20 Jun 2020 14:05:19 -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 d8sm2653359lfk.27.2020.06.20.14.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:18 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz , Ray Kinsella , Neil Horman Date: Sun, 21 Jun 2020 00:05:04 +0300 Message-Id: <20200620210511.13134-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/7] cmdline: make implementation opaque 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" struct cmdline exposes platform-specific members it contains, most notably struct termios that is only available on Unix. Make the structure opaque. Remove tests checking struct cmdline content as meaningless. Add cmdline_get_rdline() to access history buffer. The new function is currently used only in tests. Signed-off-by: Dmitry Kozlyuk --- app/test-cmdline/commands.c | 8 +++-- app/test/test_cmdline_lib.c | 42 +++++++++------------- lib/librte_cmdline/cmdline.c | 10 ++++-- lib/librte_cmdline/cmdline.h | 15 ++++---- lib/librte_cmdline/cmdline_parse.c | 4 +-- lib/librte_cmdline/cmdline_private.h | 22 ++++++++++++ lib/librte_cmdline/cmdline_socket.c | 6 ++-- lib/librte_cmdline/rte_cmdline_version.map | 8 +++++ 8 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 lib/librte_cmdline/cmdline_private.h diff --git a/app/test-cmdline/commands.c b/app/test-cmdline/commands.c index d67c0ca6a..ff7ac973e 100644 --- a/app/test-cmdline/commands.c +++ b/app/test-cmdline/commands.c @@ -294,8 +294,10 @@ cmd_get_history_bufsize_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { + struct rdline *rdl = cmdline_get_rdline(cl); + cmdline_printf(cl, "History buffer size: %zu\n", - sizeof(cl->rdl.history_buf)); + sizeof(rdl->history_buf)); } cmdline_parse_token_string_t cmd_get_history_bufsize_tok = @@ -326,7 +328,9 @@ cmd_clear_history_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { - rdline_clear_history(&cl->rdl); + struct rdline *rdl = cmdline_get_rdline(cl); + + rdline_clear_history(rdl); } cmdline_parse_token_string_t cmd_clear_history_tok = diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c index dec465da5..a7f5a7f7f 100644 --- a/app/test/test_cmdline_lib.c +++ b/app/test/test_cmdline_lib.c @@ -46,22 +46,29 @@ complete_buffer(__rte_unused struct rdline *rdl, static int test_cmdline_parse_fns(void) { - struct cmdline cl; + struct cmdline *cl; + cmdline_parse_ctx_t ctx; int i = 0; char dst[CMDLINE_TEST_BUFSIZE]; + cl = cmdline_new(&ctx, "prompt", -1, -1); + if (cl == NULL) { + printf("Error: cannot create cmdline to test parse fns!\n"); + return -1; + } + if (cmdline_parse(NULL, "buffer") >= 0) goto error; - if (cmdline_parse(&cl, NULL) >= 0) + if (cmdline_parse(cl, NULL) >= 0) goto error; if (cmdline_complete(NULL, "buffer", &i, dst, sizeof(dst)) >= 0) goto error; - if (cmdline_complete(&cl, NULL, &i, dst, sizeof(dst)) >= 0) + if (cmdline_complete(cl, NULL, &i, dst, sizeof(dst)) >= 0) goto error; - if (cmdline_complete(&cl, "buffer", NULL, dst, sizeof(dst)) >= 0) + if (cmdline_complete(cl, "buffer", NULL, dst, sizeof(dst)) >= 0) goto error; - if (cmdline_complete(&cl, "buffer", &i, NULL, sizeof(dst)) >= 0) + if (cmdline_complete(cl, "buffer", &i, NULL, sizeof(dst)) >= 0) goto error; return 0; @@ -166,11 +173,11 @@ static int test_cmdline_fns(void) { cmdline_parse_ctx_t ctx; - struct cmdline cl, *tmp; + struct cmdline *cl; memset(&ctx, 0, sizeof(ctx)); - tmp = cmdline_new(&ctx, "test", -1, -1); - if (tmp == NULL) + cl = cmdline_new(&ctx, "test", -1, -1); + if (cl == NULL) goto error; if (cmdline_new(NULL, "prompt", 0, 0) != NULL) @@ -179,7 +186,7 @@ test_cmdline_fns(void) goto error; if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >= 0) goto error; - if (cmdline_in(&cl, NULL, CMDLINE_TEST_BUFSIZE) >= 0) + if (cmdline_in(cl, NULL, CMDLINE_TEST_BUFSIZE) >= 0) goto error; if (cmdline_write_char(NULL, 0) >= 0) goto error; @@ -188,31 +195,14 @@ test_cmdline_fns(void) cmdline_set_prompt(NULL, "prompt"); cmdline_free(NULL); cmdline_printf(NULL, "format"); - /* this should fail as stream handles are invalid */ - cmdline_printf(tmp, "format"); cmdline_interact(NULL); cmdline_quit(NULL); - /* check if void calls change anything when they should fail */ - cl = *tmp; - - cmdline_printf(&cl, NULL); - if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch; - cmdline_set_prompt(&cl, NULL); - if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch; - cmdline_in(&cl, NULL, CMDLINE_TEST_BUFSIZE); - if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch; - - cmdline_free(tmp); - return 0; error: printf("Error: function accepted null parameter!\n"); return -1; -mismatch: - printf("Error: data changed!\n"); - return -1; } /* test library functions. the point of these tests is not so much to test diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index cfd703e5b..6f3fdd598 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -13,14 +13,12 @@ #include #include #include -#include #include #include -#include "cmdline_parse.h" -#include "cmdline_rdline.h" #include "cmdline.h" +#include "cmdline_private.h" static void cmdline_valid_buffer(struct rdline *rdl, const char *buf, @@ -103,6 +101,12 @@ cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out) return cl; } +struct rdline* +cmdline_get_rdline(struct cmdline *cl) +{ + return &cl->rdl; +} + void cmdline_free(struct cmdline *cl) { diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h index 243f99d20..96674dfda 100644 --- a/lib/librte_cmdline/cmdline.h +++ b/lib/librte_cmdline/cmdline.h @@ -8,8 +8,8 @@ #define _CMDLINE_H_ #include +#include -#include #include #include @@ -23,14 +23,7 @@ extern "C" { #endif -struct cmdline { - int s_in; - int s_out; - cmdline_parse_ctx_t *ctx; - struct rdline rdl; - char prompt[RDLINE_PROMPT_SIZE]; - struct termios oldterm; -}; +struct cmdline; struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out); void cmdline_set_prompt(struct cmdline *cl, const char *prompt); @@ -40,6 +33,10 @@ void cmdline_printf(const struct cmdline *cl, const char *fmt, ...) int cmdline_in(struct cmdline *cl, const char *buf, int size); int cmdline_write_char(struct rdline *rdl, char c); +__rte_experimental +struct rdline * +cmdline_get_rdline(struct cmdline *cl); + /** * This function is nonblocking equivalent of ``cmdline_interact()``. It polls * *cl* for one character and interpret it. If return value is *RDLINE_EXITED* diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index b57b30e8f..ea0979158 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -10,15 +10,13 @@ #include #include #include -#include #include #include -#include "cmdline_rdline.h" -#include "cmdline_parse.h" #include "cmdline.h" +#include "cmdline_private.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h new file mode 100644 index 000000000..3b1c70e9f --- /dev/null +++ b/lib/librte_cmdline/cmdline_private.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _CMDLINE_PRIVATE_H_ +#define _CMDLINE_PRIVATE_H_ + +#include + +#include +#include + +struct cmdline { + int s_in; + int s_out; + cmdline_parse_ctx_t *ctx; + struct rdline rdl; + char prompt[RDLINE_PROMPT_SIZE]; + struct termios oldterm; +}; + +#endif diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c index ecb3d82b6..5e4b734d6 100644 --- a/lib/librte_cmdline/cmdline_socket.c +++ b/lib/librte_cmdline/cmdline_socket.c @@ -11,12 +11,10 @@ #include #include #include -#include -#include "cmdline_parse.h" -#include "cmdline_rdline.h" -#include "cmdline_socket.h" #include "cmdline.h" +#include "cmdline_private.h" +#include "cmdline_socket.h" struct cmdline * cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path) diff --git a/lib/librte_cmdline/rte_cmdline_version.map b/lib/librte_cmdline/rte_cmdline_version.map index 95fce812f..135ecc71f 100644 --- a/lib/librte_cmdline/rte_cmdline_version.map +++ b/lib/librte_cmdline/rte_cmdline_version.map @@ -69,3 +69,11 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + cmdline_get_rdline; + + local: *; +}; From patchwork Sat Jun 20 21:05:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71823 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08A75A051C; Sat, 20 Jun 2020 23:05:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3B7941BFC4; Sat, 20 Jun 2020 23:05:24 +0200 (CEST) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id CB2D11BFB4 for ; Sat, 20 Jun 2020 23:05:20 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id q19so15299487lji.2 for ; Sat, 20 Jun 2020 14:05:20 -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=XYCaABoYdedZPSIo4qVlr3ueWLydrJpQ6CzLrsrSUPc=; b=OWta57S2jjUk6vpSfbmVEIaMYEfVHjL6mAOmufu/c90/VfRd5AkRIjvznTHRu5Ooqa NSIbm7xG8ecV6ors37grHWNbYGW5X6YVyn6sKiUVJb7z6dlf7oc5hnAyxkQGd0r0OGM0 pCbtcfYoHDgKQ1SS+EJOR37GLQezV3gy7lIOO0H345Gs94f2y/6voBrY6NP8Dq9xA0nL eJ/iawrtd4ZGXplSiPo6nyWmXihbr7a5UwUCMBohl2WjqNbtKKWExS8EfYKCQSMCrY4f 7xsrQ0sFLKU+DqsuI5VcfLffnjDuXlth9l+pol2InGQsChw8F+euvopYEmwRPIP5Y0Iu fNEg== 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=XYCaABoYdedZPSIo4qVlr3ueWLydrJpQ6CzLrsrSUPc=; b=tQyC8i2c1vS8t1HRtbyRinHyF3jGV+yhhsKaBoQJS9tpITrEIExXXwk6ZaBRIt1u1B zmdUyVu+20I72VeWXJXwckDdtUT4CILX3BJ/8R1Inyyiqj0f8OHjIdW4HGomInDVq3Im ONoJrewxB7IeUqdKVk0RX4tpA3Ez3Va3sZ6FFD4Ca9KwbddUN/eY8nM7tFwy4OQmpIqg xBQ9tEeFl3TDatvsLzW4q7G6KNvSMVQyJwB3W1OrmE1P27SAckQaS/c+K36ty8l2do5U panfGjvv/1ROoRQ5WjdOO0xPh0MNHgjJ3BnNKXfX1OgDYd5k/+vrIwRYPfNMlrFHYBjt 4oVw== X-Gm-Message-State: AOAM530yZZFe67GljBTFHtINgb6gOzBflhBsuHl1OEXoC0hTiClYjD7G QsOAPTfRm3yQl8yKom2xlDspN1YyedwDEw== X-Google-Smtp-Source: ABdhPJwa4AV++SBsTrXb4w4BgMBtVD3Tl0OiCMNCMgG8D0au0/T0nCRNFKUH2+eLv3CxAXezCvrd+g== X-Received: by 2002:a2e:7107:: with SMTP id m7mr4625112ljc.342.1592687120253; Sat, 20 Jun 2020 14:05:20 -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 d8sm2653359lfk.27.2020.06.20.14.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:19 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz Date: Sun, 21 Jun 2020 00:05:05 +0300 Message-Id: <20200620210511.13134-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/7] cmdline: add internal wrappers for terminal handling 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" Extract struct terminal and associated functions that set up, save, and restore terminal parameters. Use existing code as Unix implementation. Signed-off-by: Dmitry Kozlyuk --- lib/librte_cmdline/Makefile | 4 ++++ lib/librte_cmdline/cmdline_os_unix.c | 27 +++++++++++++++++++++++++++ lib/librte_cmdline/cmdline_private.h | 12 +++++++++++- lib/librte_cmdline/cmdline_socket.c | 15 ++++----------- lib/librte_cmdline/cmdline_vt100.c | 1 - lib/librte_cmdline/meson.build | 4 ++++ 6 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 lib/librte_cmdline/cmdline_os_unix.c diff --git a/lib/librte_cmdline/Makefile b/lib/librte_cmdline/Makefile index 619d9a242..3d8e84c07 100644 --- a/lib/librte_cmdline/Makefile +++ b/lib/librte_cmdline/Makefile @@ -23,6 +23,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_vt100.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_socket.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_parse_portlist.c +ifneq ($(CONFIG_RTE_EXEC_ENV_WINDOWS),y) +SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_os_unix.c +endif + LDLIBS += -lrte_net -lrte_eal # install includes diff --git a/lib/librte_cmdline/cmdline_os_unix.c b/lib/librte_cmdline/cmdline_os_unix.c new file mode 100644 index 000000000..ca47bd19f --- /dev/null +++ b/lib/librte_cmdline/cmdline_os_unix.c @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#include + +#include "cmdline_private.h" + +void +terminal_adjust(struct terminal *oldterm) +{ + struct termios term; + + tcgetattr(0, &oldterm->termios); + + memcpy(&term, &oldterm->termios, sizeof(term)); + term.c_lflag &= ~(ICANON | ECHO | ISIG); + tcsetattr(0, TCSANOW, &term); + + setbuf(stdin, NULL); +} + +void +terminal_restore(const struct terminal *oldterm) +{ + tcsetattr(fileno(stdin), TCSANOW, &oldterm->termios); +} diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index 3b1c70e9f..adc552845 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -10,13 +10,23 @@ #include #include +struct terminal { + struct termios termios; +}; + +/* Disable buffering and echoing, save previous settings to oldterm. */ +void terminal_adjust(struct terminal *oldterm); + +/* Restore terminal settings form oldterm. */ +void terminal_restore(const struct terminal *oldterm); + struct cmdline { int s_in; int s_out; cmdline_parse_ctx_t *ctx; struct rdline rdl; char prompt[RDLINE_PROMPT_SIZE]; - struct termios oldterm; + struct terminal oldterm; }; #endif diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c index 5e4b734d6..e73666f15 100644 --- a/lib/librte_cmdline/cmdline_socket.c +++ b/lib/librte_cmdline/cmdline_socket.c @@ -37,18 +37,11 @@ struct cmdline * cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt) { struct cmdline *cl; - struct termios oldterm, term; - - tcgetattr(0, &oldterm); - memcpy(&term, &oldterm, sizeof(term)); - term.c_lflag &= ~(ICANON | ECHO | ISIG); - tcsetattr(0, TCSANOW, &term); - setbuf(stdin, NULL); cl = cmdline_new(ctx, prompt, 0, 1); - if (cl) - memcpy(&cl->oldterm, &oldterm, sizeof(term)); + if (cl != NULL) + terminal_adjust(&cl->oldterm); return cl; } @@ -56,8 +49,8 @@ cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt) void cmdline_stdin_exit(struct cmdline *cl) { - if (!cl) + if (cl == NULL) return; - tcsetattr(fileno(stdin), TCSANOW, &cl->oldterm); + terminal_restore(&cl->oldterm); } diff --git a/lib/librte_cmdline/cmdline_vt100.c b/lib/librte_cmdline/cmdline_vt100.c index 662fc7345..bb968dd5f 100644 --- a/lib/librte_cmdline/cmdline_vt100.c +++ b/lib/librte_cmdline/cmdline_vt100.c @@ -10,7 +10,6 @@ #include #include #include -#include #include "cmdline_vt100.h" diff --git a/lib/librte_cmdline/meson.build b/lib/librte_cmdline/meson.build index 7fc54ff1a..5c9e8886d 100644 --- a/lib/librte_cmdline/meson.build +++ b/lib/librte_cmdline/meson.build @@ -25,4 +25,8 @@ headers = files('cmdline.h', 'cmdline_cirbuf.h', 'cmdline_parse_portlist.h') +if not is_windows + sources += files('cmdline_os_unix.c') +endif + deps += ['net'] From patchwork Sat Jun 20 21:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71824 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6A99DA051C; Sat, 20 Jun 2020 23:05:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A51841BFCA; Sat, 20 Jun 2020 23:05:25 +0200 (CEST) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 927D21BFBA for ; Sat, 20 Jun 2020 23:05:21 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id 9so15267202ljc.8 for ; Sat, 20 Jun 2020 14:05:21 -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=9KBD5tDXCqm5NI+e5AeRBqTs67CJlCSTNrTUeRSPhGk=; b=dof9+x13oX6Tg2s7FFvW4s2FLPusZBYOcrnErGm7Bq0mZBqYBa8CgjeqD5TIR/RlF7 iqu5L4oJnunCLmU+vt2VGpOqItXIRbjA2j+shMf3rvpU+ykE+Q2tVNIVRgFt4NeFtPpR WgkDvcW/ELqg3a79yRexTMVoEs0rmKC9FkkYG5xaNxs7x5DC7+0MgQXmU24GmOexO1KX 6+++2e0m8AsUB8p/OcJPYTGigWgSGWOA3f1mzzpRpasN0AunsnBOfwRqZB12trs1FeYG ny52zsFM+Wam6+BlFnrgEB3F7eZ1VHhTPxM5GOnlnsCshpSetNjBZIN9UAUZqb1tZP1x Gx/w== 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=9KBD5tDXCqm5NI+e5AeRBqTs67CJlCSTNrTUeRSPhGk=; b=dIUZFW2iOA0l25oOdMFb6gm3QYPUo1Ngdki8Vl7KidfAgVktRze8N51nEnjbX+KEEq TXGmGqFDr+IS/qAER2GDr6f4vYc9dGzOXvZ7lnPyAHcRmS94z/b7Gf2k7YOMr+DHzI1t jVM8ZNBLrRLeH8kX16tlgsYzoqlfZkLY7QPXueIIa2157iY1wDDn4+1QeuboDnRuUax2 16/Bg8Ws1MBuzDHyWOXcaiecR9LWCKrWsM6MDS0+iXImeWhC07g8kOJ4v6vFcCJWiepS gBWUU2nUhijHWGJuZ3TmT6dpokbJc6Ae+MC6H+1eKXgtwOZqVbaURDA1QKr7eOMV6eWY 36Pw== X-Gm-Message-State: AOAM530rbM3OHN5Z7VzE5iFDQD8m4/1GUt4VFkjbqhyn4jZSCra2yIK3 tOdNFKWRqP9t8t+tp1Ua5bnPAtIoBZIK/w== X-Google-Smtp-Source: ABdhPJw60aG+8Q+7BH+5U1mZufo6jWtVHaQArBMJvmmz7IR9DbfgulY4veGu9OLeDhLHa+yCc0FwVA== X-Received: by 2002:a2e:9dd8:: with SMTP id x24mr5226076ljj.304.1592687121165; Sat, 20 Jun 2020 14:05:21 -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 d8sm2653359lfk.27.2020.06.20.14.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:20 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz Date: Sun, 21 Jun 2020 00:05:06 +0300 Message-Id: <20200620210511.13134-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/7] cmdline: add internal wrappers for character input 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" poll(3) is a purely Unix facility, so it cannot be directly used by common code. read(2) is limited in device support outside of Unix. Create wrapper functions and implement them for Unix. Signed-off-by: Dmitry Kozlyuk --- lib/librte_cmdline/cmdline.c | 12 +++--------- lib/librte_cmdline/cmdline_os_unix.c | 20 ++++++++++++++++++++ lib/librte_cmdline/cmdline_private.h | 6 ++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 6f3fdd598..a04719998 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -185,7 +184,6 @@ cmdline_quit(struct cmdline *cl) int cmdline_poll(struct cmdline *cl) { - struct pollfd pfd; int status; ssize_t read_status; char c; @@ -195,16 +193,12 @@ cmdline_poll(struct cmdline *cl) else if (cl->rdl.status == RDLINE_EXITED) return RDLINE_EXITED; - pfd.fd = cl->s_in; - pfd.events = POLLIN; - pfd.revents = 0; - - status = poll(&pfd, 1, 0); + status = cmdline_poll_char(cl); if (status < 0) return status; else if (status > 0) { c = -1; - read_status = read(cl->s_in, &c, 1); + read_status = cmdline_read_char(cl, &c); if (read_status < 0) return read_status; @@ -226,7 +220,7 @@ cmdline_interact(struct cmdline *cl) c = -1; while (1) { - if (read(cl->s_in, &c, 1) <= 0) + if (cmdline_read_char(cl, &c) <= 0) break; if (cmdline_in(cl, &c, 1) < 0) break; diff --git a/lib/librte_cmdline/cmdline_os_unix.c b/lib/librte_cmdline/cmdline_os_unix.c index ca47bd19f..865a89ddd 100644 --- a/lib/librte_cmdline/cmdline_os_unix.c +++ b/lib/librte_cmdline/cmdline_os_unix.c @@ -2,7 +2,9 @@ * Copyright (c) 2020 Dmitry Kozlyuk */ +#include #include +#include #include "cmdline_private.h" @@ -25,3 +27,21 @@ terminal_restore(const struct terminal *oldterm) { tcsetattr(fileno(stdin), TCSANOW, &oldterm->termios); } + +int +cmdline_poll_char(struct cmdline *cl) +{ + struct pollfd pfd; + + pfd.fd = cl->s_in; + pfd.events = POLLIN; + pfd.revents = 0; + + return poll(&pfd, 1, 0); +} + +ssize_t +cmdline_read_char(struct cmdline *cl, char *c) +{ + return read(cl->s_in, c, 1); +} diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index adc552845..ecfeb89f6 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -29,4 +29,10 @@ struct cmdline { struct terminal oldterm; }; +/* Check if a single character can be read from input. */ +int cmdline_poll_char(struct cmdline *cl); + +/* Read one character from input. */ +ssize_t cmdline_read_char(struct cmdline *cl, char *c); + #endif From patchwork Sat Jun 20 21:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71825 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FE89A051C; Sat, 20 Jun 2020 23:05:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 232A51BFE3; Sat, 20 Jun 2020 23:05:27 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id EE5E71BFBA for ; Sat, 20 Jun 2020 23:05:22 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id c21so7502230lfb.3 for ; Sat, 20 Jun 2020 14:05:22 -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=KbYqZN0ClR4nsYNdtYEr+bqQUXtWxm/P5uBfGcIfH4w=; b=gixy1Rn+5XHXxjNwcM5dZ6ElyhrLOIc8HA3JCgbPGkXaLHnZWwq27i7wr9eONMZ7gb 83vjHR160sawjX0O3BDJPlXQ4zEnVGKggvhgaIgl2fF30HOt1SR/DV+aR9U/7kAEAQBA ruF79ny/MNJ/8XgyJmE950HcMPf/ovoqtvr4+Mjr2ygEYPcvVMZVl3rvK4ftOwYyZQTS Lj3C8zyrJ2juTpycJ6qpmLaoNN1hHE90o4DMRp1EvdLtkoA+0/MElEIEDpT9KveQVUEm zZj523VYvcaqgYQSrul3ayRgzK11gQdsCKHlnaMwXGjUWrPJgjUJSWGjcFThyvKneO7g 2gEg== 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=KbYqZN0ClR4nsYNdtYEr+bqQUXtWxm/P5uBfGcIfH4w=; b=oQ7DoiWWXEMEZOTtQqIXZxoiUKeujPHtoQJVO2Yzz5juzdB7zS8PWUqem6DcGOGCp5 plF5+BaTj6ommF0g2QwI7y5jtNYlE7hel4Lc3sOOEmintO6/8l85UMM0ayd2MroA75WO vVzBH6En5uXjqgptrsJxnIeZPUcaBQQCa1WUiDFsNHdILSk23l7vOOuVNCI9mY50PNpV xJT7nlnwGmhX+aEfPYlP6vTUsZKsVRZmRQRB9LnxelL6lZ84S7v8UrQASbj4Gd9Sdt8z XKBI77cWPlce0tbELBJnVY9XAHY5D6VpJfr3CeD3BIzzvSVbkG+Pw/wOv4MBf0o2Gl9b CfPA== X-Gm-Message-State: AOAM531jLdj/II3JI06vr65zxwsdP77Qn2GWQTbUf+nXatJoymmACuNO R+/eD+tzgsd9Qh09rDCF5MxDUmRXjd2EZA== X-Google-Smtp-Source: ABdhPJwFof98WqRw7epemVtyUOAZBkAfa8ofC2LK6sVCKdagpmaAKuAYHcdPdT+NL9VBHyeS7Gf+LQ== X-Received: by 2002:a19:381a:: with SMTP id f26mr5507982lfa.110.1592687122117; Sat, 20 Jun 2020 14:05:22 -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 d8sm2653359lfk.27.2020.06.20.14.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:21 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz Date: Sun, 21 Jun 2020 00:05:07 +0300 Message-Id: <20200620210511.13134-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/7] cmdline: add internal wrapper for vdprintf 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" Add internal wrapper for vdprintf(3) that is only available on Unix. Signed-off-by: Dmitry Kozlyuk --- lib/librte_cmdline/cmdline.c | 2 +- lib/librte_cmdline/cmdline_os_unix.c | 6 ++++++ lib/librte_cmdline/cmdline_private.h | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index a04719998..00b9e6b2e 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -132,7 +132,7 @@ cmdline_printf(const struct cmdline *cl, const char *fmt, ...) if (cl->s_out < 0) return; va_start(ap, fmt); - vdprintf(cl->s_out, fmt, ap); + cmdline_vdprintf(cl->s_out, fmt, ap); va_end(ap); } diff --git a/lib/librte_cmdline/cmdline_os_unix.c b/lib/librte_cmdline/cmdline_os_unix.c index 865a89ddd..2052cd254 100644 --- a/lib/librte_cmdline/cmdline_os_unix.c +++ b/lib/librte_cmdline/cmdline_os_unix.c @@ -45,3 +45,9 @@ cmdline_read_char(struct cmdline *cl, char *c) { return read(cl->s_in, c, 1); } + +int +cmdline_vdprintf(int fd, const char *format, va_list op) +{ + return vdprintf(fd, format, op); +} diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index ecfeb89f6..338d3d55c 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -7,6 +7,10 @@ #include +#include + +#include + #include #include @@ -35,4 +39,8 @@ int cmdline_poll_char(struct cmdline *cl); /* Read one character from input. */ ssize_t cmdline_read_char(struct cmdline *cl, char *c); +/* vdprintf(3) */ +__rte_format_printf(2, 0) +int cmdline_vdprintf(int fd, const char *format, va_list op); + #endif From patchwork Sat Jun 20 21:05:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71826 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 927FAA051C; Sat, 20 Jun 2020 23:06:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D6451BFE9; Sat, 20 Jun 2020 23:05:28 +0200 (CEST) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 224021BFC1 for ; Sat, 20 Jun 2020 23:05:24 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id x18so15253072lji.1 for ; Sat, 20 Jun 2020 14:05:24 -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=gTLG786xFivQ5GmDWx/v/yz2lXwdNb6DlgX07r/LV1E=; b=K273KsdwfKr4h8+akFX0s5nL4Vhz5b05DbinlXV73zcPTCnmbjR3JsmPlJzpQr46WE 20tqdjvgRmBTUDvO8ElqasXDgxld/xau86Td7yJfhBbG0BoQCgPQTjtTVtXSCyF4KruP 7IkPn56LMU+ToFocTDyVypVLugzOIOvg+3i8xw048ycsUZzT6lX1KtTTnZy9uZyXG4jj l841ndqjIcARq0Bl3lspr5RMOuzw/D3N3J8D/8+Rw8iMx+SmK2wGZ0AZcF5fT7z8AE3a X3lBqA0s30ASLjqgDkGHi0JT0mJuHl1fo3g6vCSgfeEDWZAWrgBYktWNkoAjFBJShShQ G7IQ== 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=gTLG786xFivQ5GmDWx/v/yz2lXwdNb6DlgX07r/LV1E=; b=paqOZiR3K+d+0aTnqVBCHwqspOzQ6yT5ChTprTLu8AhnEDxY0+R52yAKFX73SDo7na ZnDOd00TDNYOSsH6l0cFEAMl+pRXzliMcRpII1HEZcB+/kA+LIO2s5jvL8A9VPgmhT/S wD2wq1At5DOowqnm5ow0zsoty4ty+yWympaYAvpTPpe/EaASukmIXSB8vCKkVQ/w9QZ3 2uY+/R+ziSkHTw05AybJjA6FzzZpEHkPzQJpR4WHkxfaktwaa7p2e4ZTrCkkE37xMSkB tSwZ6nDfMu8S9RxOPbkwWE3OE8l8TNU5OEUhhyMW6vmC+CZ5YY2Cg5xZbBKFNegF3yI8 RcAQ== X-Gm-Message-State: AOAM5326AxeHrAiKwhsKS42bSjQ+CiyeO9c3Xa6IxAs48J7u5387NxfJ fZ1kiB/+k9TdEIQW9KwDf+ghKY2fm8UCdA== X-Google-Smtp-Source: ABdhPJzUyfjDS5P9Ac80b3I7jyI/9fIfF99PGhtUy+muRq2lrIPFVZ8CjIzGi6KxY/3mS9Am49rEnw== X-Received: by 2002:a2e:8e85:: with SMTP id z5mr4659302ljk.330.1592687123442; Sat, 20 Jun 2020 14:05:23 -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 d8sm2653359lfk.27.2020.06.20.14.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:22 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon Date: Sun, 21 Jun 2020 00:05:08 +0300 Message-Id: <20200620210511.13134-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/7] eal/windows: improve compatibility networking headers 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" Extend compatibility header system to support librte_cmdline. pthread.h has to include windows.h, which exposes struct in_addr, etc. conflicting with compatibility headers. WIN32_LEAN_AND_MEAN macro is required to disable this behavior. Use rte_windows.h to define WIN32_LEAN_AND_MEAN for pthread library. Signed-off-by: Dmitry Kozlyuk --- Assumming __attribute__((stdcall)) is rare enough so that the following checkpatch complaint can be ignored: Warning in /lib/librte_eal/windows/include/arpa/inet.h: Using compiler attribute directly lib/librte_eal/windows/include/arpa/inet.h | 30 +++++++++++++++++++++ lib/librte_eal/windows/include/netinet/in.h | 11 ++++++++ lib/librte_eal/windows/include/pthread.h | 2 +- lib/librte_eal/windows/include/sys/socket.h | 24 +++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/windows/include/arpa/inet.h create mode 100644 lib/librte_eal/windows/include/sys/socket.h diff --git a/lib/librte_eal/windows/include/arpa/inet.h b/lib/librte_eal/windows/include/arpa/inet.h new file mode 100644 index 000000000..96b698438 --- /dev/null +++ b/lib/librte_eal/windows/include/arpa/inet.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _ARPA_INET_H_ +#define _ARPA_INET_H_ + +/** + * @file + * + * Compatibility header + * + * Although symbols declared here are present on Windows, + * including would expose too much macros breaking common code. + */ + +#include +#include + +/* defined in ws2_32.dll */ +__attribute__((stdcall)) +int +inet_pton(int af, const char *src, void *dst); + +/* defined in ws2_32.dll */ +__attribute__((stdcall)) +const char * +inet_ntop(int af, const void *src, char *dst, socklen_t size); + +#endif /* _ARPA_INET_H_ */ diff --git a/lib/librte_eal/windows/include/netinet/in.h b/lib/librte_eal/windows/include/netinet/in.h index 489b587c3..ed46163b5 100644 --- a/lib/librte_eal/windows/include/netinet/in.h +++ b/lib/librte_eal/windows/include/netinet/in.h @@ -5,6 +5,8 @@ #ifndef _IN_H_ #define _IN_H_ +#include + #define IPPROTO_IP 0 #define IPPROTO_HOPOPTS 0 #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ @@ -21,5 +23,14 @@ #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ #define IPPROTO_SCTP 132 /* Stream Control Transmission Protocol */ +#define INET6_ADDRSTRLEN 46 + +struct in_addr { + uint32_t s_addr; +}; + +struct in6_addr { + uint8_t s6_addr[16]; +}; #endif diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h index e2274cf4e..b4dbee9d8 100644 --- a/lib/librte_eal/windows/include/pthread.h +++ b/lib/librte_eal/windows/include/pthread.h @@ -16,8 +16,8 @@ extern "C" { #endif -#include #include +#include #define PTHREAD_BARRIER_SERIAL_THREAD TRUE diff --git a/lib/librte_eal/windows/include/sys/socket.h b/lib/librte_eal/windows/include/sys/socket.h new file mode 100644 index 000000000..9536cf8e6 --- /dev/null +++ b/lib/librte_eal/windows/include/sys/socket.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +/** + * @file + * + * Compatibility header + * + * Although symbols declared here are present on Windows, + * including would expose too much macros breaking common code. + */ + +#include + +#define AF_INET 2 +#define AF_INET6 23 + +typedef size_t socklen_t; + +#endif /* _SYS_SOCKET_H_ */ From patchwork Sat Jun 20 21:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71827 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB0BDA051C; Sat, 20 Jun 2020 23:06:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB37A1BFF0; Sat, 20 Jun 2020 23:05:29 +0200 (CEST) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id 9EEF21BFC8 for ; Sat, 20 Jun 2020 23:05:25 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id e4so15270444ljn.4 for ; Sat, 20 Jun 2020 14:05:25 -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=srR2ZfMMiXbnvaiEILh7GxgL3Kpio0NQ4NFnoqEOgl0=; b=aOGLEO5CKNfNUgD+sZ4v9S0sa4TslYpPy5WpNRnX5dB5s2g+FzrdmT8wPjKSyhD2sN gd3cYyxWfjSPHQBQ56bq9Z8qLSthvTNgBslJJBTctWj8lTq5tor5UvYm8BELqTHgrcmH DiT1iK/FAG5b9WiBer68LzsHM1T7xBYBi25gGeOnp9geDIJyiw1NO7fnGm1nJ/NmW9xn li7PUZ12YL0Dhd/9QJ9g+xC9Seeg9pQJ2WHTmqGDF22U9ZVZY5PHx/uugiTdbIY7I3p/ c8uWDAIam60pXAWMlXysHnEBcJcQdLk66cdMN/Jy62GA+FXWht5jNyhjPKNwkhrrwpkV OouA== 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=srR2ZfMMiXbnvaiEILh7GxgL3Kpio0NQ4NFnoqEOgl0=; b=XusiKi+FZ2+5GuFcrSPa4cBiaRzk5vaYVEd4IcNIBz673f8OQFnVVbThZ29+h6WVER 7OFouf0CR6JnOZdNID4t21brUKurItNeKWJ5HpcjD8GUcyWX61H5PJRn5nvWRTP8q5eo 1ebOlVmvlz8mEcAf9ZPQQzVqVBJb2TQ2NF3ufvnauGbb8yNNObIGFf+zSS4nL5tQbhB4 E0TsqL11RL8GJyzrhp1/+/UICg3npEefoMBXcDrDj+bSa8cclq8BEKMhinimYqgkLcGB PZf84q0i6znqZXgGoi6UYbOTQxV1ibL/VcgAH6ooKfxMnenj9QcE330VA9uLr3Wodpkc EPQg== X-Gm-Message-State: AOAM531RtbJtLwG5IW/66Ii43AugAyPnORp3VaP56u59bhLAvJbKUMgN +BLaAj7gt2i0U5lq9YksR/an27vjw8EWIQ== X-Google-Smtp-Source: ABdhPJyw0QUa8icotvFC9ApJxxURyRzkYOaCY2U2lNnMPBMAP0gHBjZRSWm1XpsYqR3x8Y44YrAAWA== X-Received: by 2002:a2e:859a:: with SMTP id b26mr5030034lji.191.1592687124723; Sat, 20 Jun 2020 14:05:24 -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 d8sm2653359lfk.27.2020.06.20.14.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:24 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Thomas Monjalon , Olivier Matz Date: Sun, 21 Jun 2020 00:05:09 +0300 Message-Id: <20200620210511.13134-7-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 6/7] cmdline: support Windows 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" Implement terminal handling, input polling, and vdprintf() for Windows. Because Windows I/O model differs fundamentally from Unix and there is no concept of character device, polling is simulated depending on the underlying inpue device. Supporting non-terminal input is useful for automated testing. Windows emulation of VT100 uses "ESC [ E" for newline instead of standard "ESC E", so a workaround is added. Signed-off-by: Dmitry Kozlyuk --- config/meson.build | 2 + lib/librte_cmdline/cmdline.c | 5 + lib/librte_cmdline/cmdline_os_windows.c | 207 ++++++++++++++++++++++++ lib/librte_cmdline/cmdline_private.h | 15 ++ lib/librte_cmdline/cmdline_socket.c | 4 + lib/librte_cmdline/cmdline_vt100.h | 4 + lib/librte_cmdline/meson.build | 4 +- lib/meson.build | 1 + 8 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 lib/librte_cmdline/cmdline_os_windows.c diff --git a/config/meson.build b/config/meson.build index d3f05f878..733b5e310 100644 --- a/config/meson.build +++ b/config/meson.build @@ -269,6 +269,8 @@ if is_windows add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c') endif + add_project_link_arguments('-lws2_32', language: 'c') + # Contrary to docs, VirtualAlloc2() is exported by mincore.lib # in Windows SDK, while MinGW exports it by advapi32.a. if is_ms_linker diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 00b9e6b2e..c0ddb5f23 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -13,9 +13,14 @@ #include #include #include +#include #include +#ifdef RTE_EXEC_ENV_WINDOWS +#define write _write +#endif + #include "cmdline.h" #include "cmdline_private.h" diff --git a/lib/librte_cmdline/cmdline_os_windows.c b/lib/librte_cmdline/cmdline_os_windows.c new file mode 100644 index 000000000..9736f6531 --- /dev/null +++ b/lib/librte_cmdline/cmdline_os_windows.c @@ -0,0 +1,207 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#include + +#include + +#include "cmdline_private.h" + +/* Missing from some MinGW-w64 distributions. */ +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif + +#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT +#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 +#endif + +void +terminal_adjust(struct terminal *oldterm) +{ + HANDLE handle; + DWORD mode; + + ZeroMemory(oldterm, sizeof(*oldterm)); + + /* Detect console input, set it up and make it emulate VT100. */ + handle = GetStdHandle(STD_INPUT_HANDLE); + if (GetConsoleMode(handle, &mode)) { + oldterm->is_console_input = 1; + oldterm->input_mode = mode; + + mode &= ~( + ENABLE_LINE_INPUT | /* no line buffering */ + ENABLE_ECHO_INPUT | /* no echo */ + ENABLE_PROCESSED_INPUT | /* pass Ctrl+C to program */ + ENABLE_MOUSE_INPUT | /* no mouse events */ + ENABLE_WINDOW_INPUT); /* no window resize events */ + mode |= ENABLE_VIRTUAL_TERMINAL_INPUT; + SetConsoleMode(handle, mode); + } + + /* Detect console output and make it emulate VT100. */ + handle = GetStdHandle(STD_OUTPUT_HANDLE); + if (GetConsoleMode(handle, &mode)) { + oldterm->is_console_output = 1; + oldterm->output_mode = mode; + + mode &= ~ENABLE_WRAP_AT_EOL_OUTPUT; + mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(handle, mode); + } +} + +void +terminal_restore(const struct terminal *oldterm) +{ + if (oldterm->is_console_input) { + HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); + SetConsoleMode(handle, oldterm->input_mode); + } + + if (oldterm->is_console_output) { + HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleMode(handle, oldterm->output_mode); + } +} + +static int +cmdline_is_key_down(const INPUT_RECORD *record) +{ + return (record->EventType == KEY_EVENT) && + record->Event.KeyEvent.bKeyDown; +} + +static int +cmdline_poll_char_console(HANDLE handle) +{ + INPUT_RECORD record; + DWORD events; + + if (!PeekConsoleInput(handle, &record, 1, &events)) { + /* Simulate poll(3) behavior on EOF. */ + return (GetLastError() == ERROR_HANDLE_EOF) ? 1 : -1; + } + + if ((events == 0) || !cmdline_is_key_down(&record)) + return 0; + + return 1; +} + +static int +cmdline_poll_char_file(struct cmdline *cl, HANDLE handle) +{ + DWORD type = GetFileType(handle); + + /* Since console is handled by cmdline_poll_char_console(), + * this is either a serial port or input handle had been replaced. + */ + if (type == FILE_TYPE_CHAR) + return cmdline_poll_char_console(handle); + + /* PeekNamedPipe() can handle all pipes and also sockets. */ + if (type == FILE_TYPE_PIPE) { + DWORD bytes_avail; + if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytes_avail, NULL)) + return (GetLastError() == ERROR_BROKEN_PIPE) ? 1 : -1; + return bytes_avail ? 1 : 0; + } + + /* There is no straightforward way to peek a file in Windows + * I/O model. Read the byte, if it is not the end of file, + * buffer it for subsequent read. This will not work with + * a file being appended and probably some other edge cases. + */ + if (type == FILE_TYPE_DISK) { + char c; + int ret; + + ret = _read(cl->s_in, &c, sizeof(c)); + if (ret == 1) { + cl->repeat_count = 1; + cl->repeated_char = c; + } + return ret; + } + + /* GetFileType() failed or file of unknown type, + * which we do not know how to peek anyway. + */ + return -1; +} + +int +cmdline_poll_char(struct cmdline *cl) +{ + HANDLE handle = (HANDLE)_get_osfhandle(cl->s_in); + return cl->oldterm.is_console_input ? + cmdline_poll_char_console(handle) : + cmdline_poll_char_file(cl, handle); +} + +ssize_t +cmdline_read_char(struct cmdline *cl, char *c) +{ + HANDLE handle; + INPUT_RECORD record; + KEY_EVENT_RECORD *key; + DWORD events; + + if (!cl->oldterm.is_console_input) + return _read(cl->s_in, c, 1); + + /* Return repeated strokes from previous event. */ + if (cl->repeat_count > 0) { + *c = cl->repeated_char; + cl->repeat_count--; + return 1; + } + + handle = (HANDLE)_get_osfhandle(cl->s_in); + key = &record.Event.KeyEvent; + do { + if (!ReadConsoleInput(handle, &record, 1, &events)) { + if (GetLastError() == ERROR_HANDLE_EOF) { + *c = EOF; + return 0; + } + return -1; + } + } while (!cmdline_is_key_down(&record)); + + *c = key->uChar.AsciiChar; + + /* Save repeated strokes from a single event. */ + if (key->wRepeatCount > 1) { + cl->repeated_char = *c; + cl->repeat_count = key->wRepeatCount - 1; + } + + return 1; +} + +int +cmdline_vdprintf(int fd, const char *format, va_list op) +{ + int copy, ret; + FILE *file; + + copy = _dup(fd); + if (copy < 0) + return -1; + + file = _fdopen(copy, "a"); + if (file == NULL) { + _close(copy); + return -1; + } + + ret = vfprintf(file, format, op); + + fclose(file); /* also closes copy */ + + return ret; +} diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index 338d3d55c..1e05ec376 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -5,7 +5,11 @@ #ifndef _CMDLINE_PRIVATE_H_ #define _CMDLINE_PRIVATE_H_ +#ifdef RTE_EXEC_ENV_WINDOWS +#include +#else #include +#endif #include @@ -15,7 +19,14 @@ #include struct terminal { +#ifndef RTE_EXEC_ENV_WINDOWS struct termios termios; +#else + DWORD input_mode; + DWORD output_mode; + int is_console_input; + int is_console_output; +#endif }; /* Disable buffering and echoing, save previous settings to oldterm. */ @@ -31,6 +42,10 @@ struct cmdline { struct rdline rdl; char prompt[RDLINE_PROMPT_SIZE]; struct terminal oldterm; +#ifdef RTE_EXEC_ENV_WINDOWS + char repeated_char; + WORD repeat_count; +#endif }; /* Check if a single character can be read from input. */ diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c index e73666f15..c5f483413 100644 --- a/lib/librte_cmdline/cmdline_socket.c +++ b/lib/librte_cmdline/cmdline_socket.c @@ -16,6 +16,10 @@ #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_cmdline/cmdline_vt100.h b/lib/librte_cmdline/cmdline_vt100.h index e33e67ed8..be9ae8e1c 100644 --- a/lib/librte_cmdline/cmdline_vt100.h +++ b/lib/librte_cmdline/cmdline_vt100.h @@ -31,7 +31,11 @@ extern "C" { #define vt100_multi_right "\033\133%uC" #define vt100_multi_left "\033\133%uD" #define vt100_suppr "\033\133\063\176" +#ifndef RTE_EXEC_ENV_WINDOWS #define vt100_home "\033M\033E" +#else +#define vt100_home "\033M\033[E" +#endif #define vt100_word_left "\033\142" #define vt100_word_right "\033\146" diff --git a/lib/librte_cmdline/meson.build b/lib/librte_cmdline/meson.build index 5c9e8886d..5009b3354 100644 --- a/lib/librte_cmdline/meson.build +++ b/lib/librte_cmdline/meson.build @@ -25,7 +25,9 @@ headers = files('cmdline.h', 'cmdline_cirbuf.h', 'cmdline_parse_portlist.h') -if not is_windows +if is_windows + sources += files('cmdline_os_windows.c') +else sources += files('cmdline_os_unix.c') endif diff --git a/lib/meson.build b/lib/meson.build index 40e452025..5b72a2d9e 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -40,6 +40,7 @@ if is_windows 'kvargs','eal', 'ring', 'mempool', 'mbuf', 'pci', 'net', + 'cmdline', ] # only supported libraries for windows endif From patchwork Sat Jun 20 21:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 71828 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7404A051C; Sat, 20 Jun 2020 23:06:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F38151BFF7; Sat, 20 Jun 2020 23:05:30 +0200 (CEST) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id 07ACC1BFCE for ; Sat, 20 Jun 2020 23:05:26 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id k15so500067lfc.4 for ; Sat, 20 Jun 2020 14:05:25 -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=J5iEc9t1iePggB+1kNJ0VxK0Lzh7n1ZC4/4oYNFlzTs=; b=Hn2nDhEYy/WsrHT7bz+Fpqfk6273isMuoBAteS3kFiBgW7qExeCD3HoH2Tf/m/XCTu npO7ouaHjtXjpeIbzfxHgXPRMLLxi/bLR7q6vt0QyBKxZkNSNbxRKBQ3zowDdtNWbBxf 0NadJ8++BIxKkv3//F9Sp7ZkkmM0eFyRzR+5OuQc9sQ+NQc/XeVMBKID7X2+N9PQ5XOH 4IcDDQgzKdi8NIeMt72Dpc2ENJUMhJUwQ/1eKuM/f0pwj6n4VkkeKoag59juY+Ok+NOZ r5j+w6+gkjBo+30PQOTmPr3F3QGvADlNxEOt7B3xWLZQJYPRl1qe43QjUhnr9VA4nu+1 433g== 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=J5iEc9t1iePggB+1kNJ0VxK0Lzh7n1ZC4/4oYNFlzTs=; b=tLnNP1rAd0HPXOvIE+41SNWU+kxcMktWbe68K1nkLyxjEFOm1Vwfp1uWITIKEVtffM mL/f3AB6Eu3ZeHEIlVOQ0kt272kNHZk3R8mdnK5EX7Xsy7Yeh9dHZ8tXRTmksHzuhR2q JUHCFQ5+Tpy5DsK3+DIVdymZ62FHh9dUrk3v/EzkRmrslujoMamD086VDENuDShXUmwW ESdwD9eYBrrCFQhXsYviRHzw8KPFy4lOuNIsE99YvsSIL4QxBVVb8MSOcoBHJg4sOXm1 dvXC+C/U9GQf8QeK+eIMjYDHxmdWj5JsZ6+58Crgjt3ENFmSgr1S50Hu8WlViFIQrBv3 Ce+g== X-Gm-Message-State: AOAM533dut+XJexberCJyP7bX1437yWDiUj31XYVGTl+K7M3UcEBCJH8 9KLj76JbbkPl9GiIH3B0eu61CfMQa1nHZg== X-Google-Smtp-Source: ABdhPJzGR4hRFw1V7HwJKYIjPRQOpQImze98TUdnbuSe8q+WJLqQ486qcO4pAIlFyQgpacmz3KFhMQ== X-Received: by 2002:a05:6512:49d:: with SMTP id v29mr5485482lfq.134.1592687125557; Sat, 20 Jun 2020 14:05:25 -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 d8sm2653359lfk.27.2020.06.20.14.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:25 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz Date: Sun, 21 Jun 2020 00:05:10 +0300 Message-Id: <20200620210511.13134-8-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 7/7] examples/cmdline: build on Windows 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" Enable cmdline sample application as all dependencies are met. Signed-off-by: Dmitry Kozlyuk --- examples/cmdline/commands.c | 1 - examples/cmdline/main.c | 1 - examples/meson.build | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/cmdline/commands.c b/examples/cmdline/commands.c index 0e2232f03..f43eacfba 100644 --- a/examples/cmdline/commands.c +++ b/examples/cmdline/commands.c @@ -11,7 +11,6 @@ #include #include #include -#include #ifdef RTE_EXEC_ENV_FREEBSD #include #endif diff --git a/examples/cmdline/main.c b/examples/cmdline/main.c index f2f2e5a2f..bb7954245 100644 --- a/examples/cmdline/main.c +++ b/examples/cmdline/main.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/examples/meson.build b/examples/meson.build index 3b540012f..96920219d 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -81,9 +81,9 @@ foreach example: examples ext_deps = [execinfo] includes = [include_directories(example)] - deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] - if is_windows - deps = ['eal'] # only supported lib on Windows currently + deps = ['eal', 'mempool', 'net', 'mbuf', 'cmdline'] + if not is_windows + deps += ['ethdev'] # not currently supported endif subdir(example)