From patchwork Thu Jul 30 21:06:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75080 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 340F3A052B; Thu, 30 Jul 2020 23:07:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 232041BFFA; Thu, 30 Jul 2020 23:07: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 E4E3B37B7 for ; Thu, 30 Jul 2020 23:07:23 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id m15so15053150lfp.7 for ; Thu, 30 Jul 2020 14:07:23 -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=kbx25d5EpO/l5Pf7nfZhBzfSqsnlqTHuiKgnbolzB6TQXNhTFAd6RaAxqSiVG/ncie 8TrMHQOeSvEo3xz+qa4ilxb5hvKR3W40SWDWeTJ01o4XU+MrWO23h5MoVG0RJU0cGRHr 4aF02j3qA2I7AykRGHdlvO6TIO2jnrTNDgFC5cTU+5zKfp1GeoaexsM8xVHQFcV5RU5v Vr1DAnFKxFBObiok22vc3cDxDJ0zpJHsIpaNNhT3QxB3/mME3biz8qWmiRGJ8ttmBJG+ EFQUPETOFdXcblsNtef7slSCOPIP9v++ox7i9Q6Y/9CNenQumPBA3INxdyADfOBiJ2UZ NNVQ== 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=Sz4skIZNb87HqQFaIiF5Sqe19WNUnzARfOjX9b6OFTE8fXdbfT60zPyw7/vPS1Xfvl YJJzvEipPR86LpKkGxZbqy9ZZ2f+mBoMvxrdtQ1SHZTuIJR7+fJ1Gx4f+NZ7TLFlnDd7 GGru8lPosy/LLrvNAuQl8PsPuOmxgCxGiDrbjlF0lREZ/6lf9IEkUB4UsEDeTaCdFXtK 5Gf9NEmbISU05oA7KdNcflnMZUSK8nvfI4Gt3wVI3DMxEeAe063aonGh7Ct7h4XUw843 IRhyJOw0MQ39fIiYdwz2s7tzTADb89RJylysWZyM/4TJrdChe1LehskIukq+N59xGiau 53Gw== X-Gm-Message-State: AOAM530YeZF+/fipY91KWVo79Y+9iq6RFlpB8qYOoqhLvpCWXA2+heew ZB2OOy1lQjkpaTS0LvelJ4b6O0qwGUQjSw== X-Google-Smtp-Source: ABdhPJz/DZGTv7JE2ko59CEx7O2yvLNsbqc2qfKk7vdswYyKQZECr9+lnvc7kUSe4F5XfjoT0wmVjw== X-Received: by 2002:ac2:5335:: with SMTP id f21mr256839lfh.114.1596143242973; Thu, 30 Jul 2020 14:07: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 y9sm1257763lji.49.2020.07.30.14.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:22 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Olivier Matz , Ray Kinsella , Neil Horman Date: Fri, 31 Jul 2020 00:06:45 +0300 Message-Id: <20200730210652.14568-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Thu Jul 30 21:06:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75081 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 DF2D5A052B; Thu, 30 Jul 2020 23:07:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 981EB1C012; Thu, 30 Jul 2020 23:07:28 +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 E12AD4C93 for ; Thu, 30 Jul 2020 23:07:24 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id j22so9828686lfm.2 for ; Thu, 30 Jul 2020 14:07: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=XYCaABoYdedZPSIo4qVlr3ueWLydrJpQ6CzLrsrSUPc=; b=WJt8x5x5SkucYxlMm8LamdakOGmgC3J6LGadUKF036LeyBhS5xwZLNRijUQoewV//j 5FeKfT0YK+CyfKky7LwHxoGmJysAEmFdtueQftMTCnw3eVo8q2ic9iiz0jpfeF/f/6/D LMrv88dMEFQWEDiD4LXT8pbwMlGHX7lUNuMCYV3a5ajIUdyGcUKMlSuWEW6S/cx+NASZ VA9LMk0hOc15xlhh+2AJt6r0VVRDvBlqFnuxymdINDIeIPUSoNNc9rr9VdEE5GxsR7gA /IdCjoQGZwbsBKoFFZ8OvJJnJmujotC71XqQ1U4IUCW7QoubzOinFfkxSfr0V2Cviifc hN+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=XYCaABoYdedZPSIo4qVlr3ueWLydrJpQ6CzLrsrSUPc=; b=UQCXDWvJfBFUwsg93QRiDitE+u4hUDO/c6nzmUZhFZKrm+16ZnoviUSCNi2weZco7Q ZZ28RMiF7LVyxesEAE3A5PbH36WNmrYo075LLEI8md6tkce0q4Olzwk0/J51pmN5tviB FyaJGbbIe2+Cr1AWgObwlLX4vJg02ca8owTQdmifgiIPkdLLB6NyGPFJqvfdFdnTk6i9 ecrZM3eUTKds1+G7UBLezvn9VQF6F6JLbqLi75z1Y956Ezo2p7xoRs6d/t8XJcB31Ca0 IVxH3cFzyE4rHU0O7uSr1RykR+xqEtBgFTmi6GoXjjv7qfBoftn2Woy58BJ9V22i4ZvK xqKQ== X-Gm-Message-State: AOAM532+zZ8IRLR0w136tU2hdEnfzUQi6AIwaqjDK+jM2niwuc4qfHwK mZZzx7VXryxeUiO2EGWGtIe/2hfKqCswSQ== X-Google-Smtp-Source: ABdhPJz6Uk1jSXNEJv0iGFfNyV6r24IN38nNDPdBi9jCu4UJRgrFE6NT8Ls75nd3SGNgk/8LWD/4Qw== X-Received: by 2002:a19:228a:: with SMTP id i132mr255178lfi.178.1596143244184; Thu, 30 Jul 2020 14:07: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 y9sm1257763lji.49.2020.07.30.14.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:23 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Olivier Matz Date: Fri, 31 Jul 2020 00:06:46 +0300 Message-Id: <20200730210652.14568-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Thu Jul 30 21:06:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75082 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 DDA96A052B; Thu, 30 Jul 2020 23:07:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 462DA1C02E; Thu, 30 Jul 2020 23:07:32 +0200 (CEST) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id 1463A4C93 for ; Thu, 30 Jul 2020 23:07:26 +0200 (CEST) Received: by mail-lf1-f66.google.com with SMTP id s9so15744188lfs.4 for ; Thu, 30 Jul 2020 14:07:26 -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=ASNVWaHxEJN+A/4Jc5LAIlAXilIwrPJgq5wShK5MvjkB8i0qbZ0bzVbd0Hl6vl1pGw dhIBqs7ZNQ3+WOhdUfHsSk8JCZFRtXpaI2+VntjI4zbWupQYc+5UcePxUJOMuTN+OOYC s42LzeVvJvZpZy8T98CUQwDeWM3ZM2a1t1mL9N8AKQjcNuxXMjnMBTg/iG0OssCzVjmn RINPcRxi/FzAUNyG0rj86EJYEd0RECKgd8RRjbSg1oO/pqTkjQ3GnbufVskI5aNRmIG4 r3DIPsxd666lOoSZqOkzxZyL8zME5FABkNMLPIi3ZWn9hhgB6sNXTMuD9JyTe1vJekEs azNQ== 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=ByQQVBSwljh15fo8UUM8IaBNYlSRWaYb3Xk/fH6omVPqAXDEge4hQOtxWUePXN1jAF QSZSJqeM/drMjwevN+AYv13XkmmNhq26z7VN77y/DzX0oadapDHYhVxO7tUvbLhikBO1 NUOFphCP15c1mm0cxePrtt7H+EHWVyHxLq6bNfw1qSBHkkU1kW1HpZ9xyVjTnT3vRy7S zyWRLxwbkm7wy06XPlb4HllruP+0oGW4g+BQqRfYeyR4Ofo3gz9CL6o3Jri1B0Y09Gk4 4TgVYxOofpvqK5oC+SawLaIqwhy6ogr2mmI0sxfJKc+FbF0Z5uujd047WniGMnYYuCPI +Rlg== X-Gm-Message-State: AOAM532a0Yx0FFMBSys4Gns5Ns821gLvcCc5q+HjxxuDce2I698aehGS M/4yKDxGhEoflUcfZ0uVlyRYuTAHue69Gg== X-Google-Smtp-Source: ABdhPJzwz0N7/NUzURv5frTuiNfqlaRRoJK+STTUS9gGTCbBophSNOFAzrrt43RYI8XxX9Bzbnl8tQ== X-Received: by 2002:a05:6512:358c:: with SMTP id m12mr264324lfr.18.1596143245418; Thu, 30 Jul 2020 14:07: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 y9sm1257763lji.49.2020.07.30.14.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:24 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Olivier Matz Date: Fri, 31 Jul 2020 00:06:47 +0300 Message-Id: <20200730210652.14568-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Thu Jul 30 21:06:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75083 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 35742A052B; Thu, 30 Jul 2020 23:07:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 793AE1C042; Thu, 30 Jul 2020 23:07:33 +0200 (CEST) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id 2F21E1BFFD for ; Thu, 30 Jul 2020 23:07:27 +0200 (CEST) Received: by mail-lf1-f66.google.com with SMTP id j22so9828751lfm.2 for ; Thu, 30 Jul 2020 14:07:27 -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=bWq6EWBFWYyjFt1LIsWieBE9ZG6euKgkNE6ncrFqNvMW7eP2UeZoq8IXavv/kEioXl Z6ynZKYr58kmsTvT/A/cZuGoEHbHF6aT0BpvXjHNuzdIPpByzSaUdnldb7dCYJD2RsY1 0RSpGxlnel1HkEydrKCvYUvhSRHhxooVVPzUMtOOLghaIcSExzCqtY44rKS36bDL5O8d ObHJLhtRETLpSK2QFEXfEKnhFQe61hvJFk/qLiRLdDVNjWkrpxS2Ae8n+HXKizU7hYIl uyQ+IilH74Jng/O3i3LiM45LTS+wBAKIgrNkLutglP/aXyXGTOSMM0XE52V6JvJqIcEv 3hNA== 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=aYC/qPm/1Z2K2sXdH+RE6zTJrz38mUS/x3wWR/VGtZqU0GL7MO5u0nQZ8abHN7Pxah JexvjRLAsiMUoZSR4eOEhNWpkdQ2EuGK/cTg4FoYjCBz6/D/tg+y6sm99nFc2kritlFN +pT3mB2Sdn8PV5X6MiumcyXiwVKAOoHfS/g1NSiE6vgn8csx3cfvgTdjh0lNi3xJCY/O 3zkA6e5LtqEbS7MsuPCo1AYhTGC5Uzv8QYvTjnchDKb1ySnD+MKfssqvRGd70jbDlR0x VVhV2kXAouzijiVne+OrAMIQQrNoxEl6S9BLx9ZnJojvB8m8BzYItuyOh5I73GZiKuvj eRwg== X-Gm-Message-State: AOAM533U9cWINSHx6gHjmXNP8EZgf5/vM8UK+7kmtYmoKZAUo+74iWCx J9d1XEANCH3Hk0wbfplfS9x60XVj+Y+85Q== X-Google-Smtp-Source: ABdhPJzZLT/o8ts3bWNmHdA03TAmwZ5DN+dyb9nSd0fg0HuDTsiIRoP5AVh6xp+F22bgffGuBHJwZw== X-Received: by 2002:a05:6512:3610:: with SMTP id f16mr265083lfs.8.1596143246479; Thu, 30 Jul 2020 14:07:26 -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 y9sm1257763lji.49.2020.07.30.14.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:25 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Olivier Matz Date: Fri, 31 Jul 2020 00:06:48 +0300 Message-Id: <20200730210652.14568-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Thu Jul 30 21:06:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75084 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 DF1D2A052B; Thu, 30 Jul 2020 23:08:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE6391C0AF; Thu, 30 Jul 2020 23:07:34 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 6647D1C00E for ; Thu, 30 Jul 2020 23:07:28 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id b25so30362332ljp.6 for ; Thu, 30 Jul 2020 14:07:28 -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=e6aBSrUhn/lvL9t4L3t396NYrgm2JEJBD4+yWf55VC8=; b=dhMuoSiK8pcBos8C2P5B9xjiltMmsMmUS0ADqOviHMX9+4ybXO6+vna79+7UM6hTEo R6XYfue66Hv/fvJhML0BlJaaeCe2Wujuuhou1WUj3a9o+pTzeOhXjRgQWXyjSi/DKRHF onN42BZVg7SHXekmdk4dRuAdPNf3MngxDL6gh5UoBS6NQFHBheK8X3Y8GXA8eFpJDYh8 HTbeSZSCZV+ICxzjsuFu+jkpc2LIWAuy62JXBZrrksrZI/HHa6U39m+OIeHsSsoRKRIf m7OsI+1htBdSjD1HKqUkFSse2BKIsZtrf14DE8QprMOZ1nfAMlGfBLdFcOFfert2vVAL Ys0A== 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=e6aBSrUhn/lvL9t4L3t396NYrgm2JEJBD4+yWf55VC8=; b=BohDvPFl/goXHpJWL3ftKo3WQr1kJVvdEwB33sG4dM9rJlyqggBbNLSN5c07NPJkG5 eCxuDpm/CZL3MyVOLas4aIc3KlsmWVR9fjvLZSffysB8z8k6s8uVN0vh1GM0sbK87TQx 1IQlOd27VexfhG/UZ5yLSJ8E0L2F5GpANKfLlLFmN+5JwEF+ofCCPF79cKpTj2PFI4SW F9HjZr1ngeGpbJ7VX+QajyDTrfWshWdykxCiKKjWr/PTSJkTlCI84erdVWZ/eFze0ILp z2nIQLH4w1shVm9vPkjQpKkImJXVU5pKD5E2YdCT5sTLz+zV30kCygK6OBOUGVfv0TxR XDcw== X-Gm-Message-State: AOAM531uh9Volg5PeUbmU5i/wz4dD7s03KKBxMyqG4nJDJqDbz09GZh9 K6z8Z0KhXRGtRo8Ajr3p/CGkP6YAJ/MV0A== X-Google-Smtp-Source: ABdhPJwlOqqIzRdiv6/5AZIo2BkwXA9enOEGXZkib5YGEU5s9cZtLDR+RMqnBNGa0j8njqHa6Ph+Cw== X-Received: by 2002:a05:651c:2dc:: with SMTP id f28mr433114ljo.404.1596143247626; Thu, 30 Jul 2020 14:07:27 -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 y9sm1257763lji.49.2020.07.30.14.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:27 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Ranjit Menon Date: Fri, 31 Jul 2020 00:06:49 +0300 Message-Id: <20200730210652.14568-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 --- lib/librte_eal/windows/include/arpa/inet.h | 30 +++++++++++++++++++++ lib/librte_eal/windows/include/netinet/in.h | 12 +++++++++ lib/librte_eal/windows/include/sys/socket.h | 24 +++++++++++++++++ 3 files changed, 66 insertions(+) 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 2be25c8be..f7c486be6 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 /* Dummy for IP */ #define IPPROTO_HOPOPTS 0 /* IPv6 Hop-by-Hop options */ #define IPPROTO_IPIP 4 /* IPIP tunnels (for compatibility) */ @@ -20,4 +22,14 @@ #define IPPROTO_DSTOPTS 60 /* IPv6 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/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 Thu Jul 30 21:06:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75085 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 BC299A052B; Thu, 30 Jul 2020 23:08:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 651961C0B3; Thu, 30 Jul 2020 23:07:36 +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 CD30E1C027 for ; Thu, 30 Jul 2020 23:07:29 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id s9so15744281lfs.4 for ; Thu, 30 Jul 2020 14:07:29 -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=X9MIz8fc5YkXL8etcuV9wVcv2aHejbtegV9FTqVNA4g=; b=uXXdENYwwjApRbjYw1oLkhJmoSqYAZWkWRB69zsOUZSEzdMhi4QZ1Dp2Bz4TngJbky xsjXnZCOAhsueAyyItKFRpP7MZqtyVfqw/RtAiPLMRkeNZp4ELKTPU+4kc30ZxALxIFg WC/pTZwInZ1Vx7lE5nCODFccRcOkZG2jIfAbyrD5yU5GI8XRkEOLmtjB489kRtPZMxsV 2fEuE0IhuVopjlEwP9KB6k7kzum6ULoneEI2IHA1btq3naCifL40zH2KYDDAWv3cu/PB 4cAxZOFHRK8Pop3t0kHo1oCMaZ54uEqT6352JDo7MFRUZwY4ZqasPbv2SSRbM3wPYgvN vEEw== 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=X9MIz8fc5YkXL8etcuV9wVcv2aHejbtegV9FTqVNA4g=; b=YcqG6128N7EpWR2tWA3f/KTLl0TsbIfY08cqzpZuFsUta171m8qzB5zA1qR97+5ytR 2vQqRXfyu9SBcDgOpuM1kfvj8zzbbhWn2oofePCaDFoI2L2ZNTm+OZSXgXRevhZBkxCf UI3NzO8n6pOzLIO/gYCbRfs8YP2kMgWp26ZlAnDUBU2ZPhLVaY/+wF+zvX2H2W/CtNy0 Hb/ofcTVtH94YZWQOmqGC/Q4iqzvWCk70MO3OxbLNHM3FX2yedJUdg1PEL+BMnwFMd22 vsZY/sAdcTdE6I9sRt2r4l2N55d1O45HUW6MyUvQtnNp/CcmGBg4PMnUCcbeIgymSN5w z01g== X-Gm-Message-State: AOAM530uiV0LPnwjIz+pAKaCVVygkKfjNYloM+yKNNQAn+yfpxCav+PQ 1picbsWEvchJVFgwcYue02KaC0BLCz9jZQ== X-Google-Smtp-Source: ABdhPJwOWa06ksf9bDwZqzdrhv+z5hdw2gYOzQvyBOUPuFVfMhgTzv7sovPcpT5prezljI5Rn57qTw== X-Received: by 2002:a19:a07:: with SMTP id 7mr250957lfk.65.1596143248837; Thu, 30 Jul 2020 14:07:28 -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 y9sm1257763lji.49.2020.07.30.14.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:28 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Thomas Monjalon , Olivier Matz Date: Fri, 31 Jul 2020 00:06:50 +0300 Message-Id: <20200730210652.14568-7-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 cff8b33dd..2d1b6fab2 100644 --- a/config/meson.build +++ b/config/meson.build @@ -270,6 +270,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 6bbaf242a..8430057c6 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -41,6 +41,7 @@ if is_windows 'eal', 'ring', 'mempool', 'mbuf', 'pci', 'net', + 'cmdline', ] # only supported libraries for windows endif From patchwork Thu Jul 30 21:06:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 75086 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 0F7ACA052B; Thu, 30 Jul 2020 23:08:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1CD61C0BE; Thu, 30 Jul 2020 23:07:37 +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 DBAF61C02E for ; Thu, 30 Jul 2020 23:07:30 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id v15so11186976lfg.6 for ; Thu, 30 Jul 2020 14:07:30 -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=CxZvlUmllN7m5FVGrB3HPxfF3i00eylYQhBMfud2LDg=; b=CAp9Ooetl11QAvffRk1wXCv9jdX7Mix/nARcEh8GrSkHQkS+2wGWAgLjOW348k01HE JHTHy2Go17j98IYBeqdP1a1jXa9BNJ2NejokdzVpIjQ5fBcpfj+DRZXRrFrAewJvlZ73 uuqhsBhlgXbaKdyN3PnilAqwmTSDLCogrfqNv0EA3X/kCqzRPkkgQdGVyJhRQEecvfwh M8Wmrf07FFLzDHZdRfcIQSk2csWCU0Dl44+Da6iyK22zCMkAJTcP/rk92l072pGiURqV Wk9yWneHEPNwz8yujcbrRSdmY2t06RIdChf6uJjL1diGPaM78YA9nU2puJrkjZsQxgWG +T3w== 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=CxZvlUmllN7m5FVGrB3HPxfF3i00eylYQhBMfud2LDg=; b=JQCoXQZgIH5oWEJ776HYDNCgpcZwyO+EQMtiYP+31IavZyKdnsvCpp4Y2obUnPj4Ya EzzNzobXq7RfoJDB81RRxYrvvVXnv+uX59aQHE8sXl+5I2JgbnLvnGReYp8dqtUohZn2 nkc4wrumZm8DYjgEe1rCZHoTAA3F2+rLxDnzPJbwNjwrJVbjuizwS1q/aEm4YLGX1+Kk /E7QU3aVWR+G/n5G8vMMMLB4C8ElXqZulg3t4HRGQAmrhlzvBszVSzOQSFX3tLEEzQrh Z6Cw/PpzJ1iMT4Ip6ep+HBwV6lRwl6uqHW0PPaUIA70iIAilqg9fEIdqVlMDw9SqFYq8 wgqQ== X-Gm-Message-State: AOAM531r1tW3PM/XAUhEuqelyf2lAJBB5JpVYv9KGbb7dw5UyjOHykp3 1g5JvByL4Nvt1EoOmuf2svWjzXtp1jW3ZA== X-Google-Smtp-Source: ABdhPJwPqh3FUdikiSvcPjIFMSO07FJ4YyiI9ydMZaSa/1q/coYmDCHFZFmz0wAwMraeQeHbV4gofg== X-Received: by 2002:a19:9149:: with SMTP id y9mr260450lfj.81.1596143250250; Thu, 30 Jul 2020 14:07:30 -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 y9sm1257763lji.49.2020.07.30.14.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 14:07:29 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , "Kadam, Pallavi" , Dmitry Kozlyuk , Olivier Matz Date: Fri, 31 Jul 2020 00:06:51 +0300 Message-Id: <20200730210652.14568-8-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200730210652.14568-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> <20200730210652.14568-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 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 eb13e8210..2b8ebce3b 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -79,9 +79,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)