From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, grive@u256.net, ranjit.menon@intel.com, navasile@linux.microsoft.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, anatoly.burakov@intel.com, fady@mellanox.com, bruce.richardson@intel.com, Tal Shnaiderman <talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v10 02/10] eal: move OS common options functions Date: Mon, 29 Jun 2020 15:37:33 +0300 Message-ID: <20200629123741.20716-3-talshn@mellanox.com> (raw) In-Reply-To: <20200629123741.20716-1-talshn@mellanox.com> From: Tal Shnaiderman <talshn@mellanox.com> Move common functions between Unix and Windows to eal_common_options.c. Those functions are getter functions for rte_application_usage_hook. Signed-off-by: Tal Shnaiderman <talshn@mellanox.com> --- lib/librte_eal/common/eal_common_options.c | 23 +++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 9 +++++++++ lib/librte_eal/freebsd/eal.c | 21 ++++----------------- lib/librte_eal/linux/eal.c | 22 ++++------------------ lib/librte_eal/windows/eal.c | 9 ++++----- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 6b909ce914..24b223ebfd 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -146,6 +146,29 @@ static int master_lcore_parsed; static int mem_parsed; static int core_parsed; +/* Allow the application to print its usage message too if set */ +static rte_usage_hook_t rte_application_usage_hook; + +/* Returns rte_usage_hook_t */ +rte_usage_hook_t +eal_get_application_usage_hook(void) +{ + return rte_application_usage_hook; +} + +/* Set a per-application usage message */ +rte_usage_hook_t +rte_set_application_usage_hook(rte_usage_hook_t usage_func) +{ + rte_usage_hook_t old_func; + + /* Will be NULL on the first call to denote the last usage routine. */ + old_func = rte_application_usage_hook; + rte_application_usage_hook = usage_func; + + return old_func; +} + #ifndef RTE_EXEC_ENV_WINDOWS static char **eal_args; static char **eal_app_args; diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index be4d0a8dbc..46bcae9305 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -690,4 +690,13 @@ eal_set_runtime_dir(char *run_dir, size_t size); struct internal_config * eal_get_internal_configuration(void); +/** + * Get the current value of the rte_application_usage pointer + * + * @return + * Pointer to the current value of rte_application_usage . + */ +rte_usage_hook_t +eal_get_application_usage_hook(void); + #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 766a52b76c..9326c8270a 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -56,8 +56,6 @@ #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) -/* Allow the application to print its usage message too if set */ -static rte_usage_hook_t rte_application_usage_hook = NULL; /* define fd variable here, because file needs to be kept open for the * duration of the program, as we hold a write lock on it in the primary proc */ static int mem_cfg_fd = -1; @@ -418,28 +416,17 @@ rte_config_init(void) static void eal_usage(const char *prgname) { + rte_usage_hook_t hook = eal_get_application_usage_hook(); + printf("\nUsage: %s ", prgname); eal_common_usage(); /* Allow the application to print its usage message too if hook is set */ - if ( rte_application_usage_hook ) { + if (hook) { printf("===== Application Usage =====\n\n"); - rte_application_usage_hook(prgname); + (hook)(prgname); } } -/* Set a per-application usage message */ -rte_usage_hook_t -rte_set_application_usage_hook( rte_usage_hook_t usage_func ) -{ - rte_usage_hook_t old_func; - - /* Will be NULL on the first call to denote the last usage routine. */ - old_func = rte_application_usage_hook; - rte_application_usage_hook = usage_func; - - return old_func; -} - static inline size_t eal_get_hugepage_mem_size(void) { diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index e7068f198b..3b56d14da1 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -69,9 +69,6 @@ #define KERNEL_IOMMU_GROUPS_PATH "/sys/kernel/iommu_groups" -/* Allow the application to print its usage message too if set */ -static rte_usage_hook_t rte_application_usage_hook = NULL; - /* define fd variable here, because file needs to be kept open for the * duration of the program, as we hold a write lock on it in the primary proc */ static int mem_cfg_fd = -1; @@ -532,6 +529,8 @@ eal_hugedirs_unlock(void) static void eal_usage(const char *prgname) { + rte_usage_hook_t hook = eal_get_application_usage_hook(); + printf("\nUsage: %s ", prgname); eal_common_usage(); printf("EAL Linux options:\n" @@ -546,25 +545,12 @@ eal_usage(const char *prgname) " --"OPT_MATCH_ALLOCATIONS" Free hugepages exactly as allocated\n" "\n"); /* Allow the application to print its usage message too if hook is set */ - if ( rte_application_usage_hook ) { + if (hook) { printf("===== Application Usage =====\n\n"); - rte_application_usage_hook(prgname); + (hook)(prgname); } } -/* Set a per-application usage message */ -rte_usage_hook_t -rte_set_application_usage_hook( rte_usage_hook_t usage_func ) -{ - rte_usage_hook_t old_func; - - /* Will be NULL on the first call to denote the last usage routine. */ - old_func = rte_application_usage_hook; - rte_application_usage_hook = usage_func; - - return old_func; -} - static int eal_parse_socket_arg(char *strval, volatile uint64_t *socket_arg) { diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 11801e6093..8333d5977e 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -24,9 +24,6 @@ #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) - /* Allow the application to print its usage message too if set */ -static rte_usage_hook_t rte_application_usage_hook; - /* define fd variable here, because file needs to be kept open for the * duration of the program, as we hold a write lock on it in the primary proc */ @@ -72,14 +69,16 @@ eal_proc_type_detect(void) static void eal_usage(const char *prgname) { + rte_usage_hook_t hook = eal_get_application_usage_hook(); + printf("\nUsage: %s ", prgname); eal_common_usage(); /* Allow the application to print its usage message too * if hook is set */ - if (rte_application_usage_hook) { + if (hook) { printf("===== Application Usage =====\n\n"); - rte_application_usage_hook(prgname); + (hook)(prgname); } } -- 2.16.1.windows.4
next prev parent reply other threads:[~2020-06-29 12:38 UTC|newest] Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-09 10:31 [dpdk-dev] [PATCH v5 0/8] Windows bus/pci support talshn 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 1/8] eal: move OS common functions to single file talshn 2020-06-16 8:46 ` David Marchand 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 0/9] Windows bus/pci support talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 1/9] eal: move OS common functions to single file talshn 2020-06-20 19:01 ` Dmitry Kozlyuk 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 0/9] Windows bus/pci support talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 1/9] eal: move OS common functions to single file talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 0/9] Windows bus/pci support talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 1/9] eal: move OS common functions to single file talshn 2020-06-22 14:54 ` Thomas Monjalon 2020-06-23 6:45 ` Tal Shnaiderman 2020-06-23 7:16 ` Thomas Monjalon 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 00/10] Windows bus/pci support talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 01/10] eal: move OS common config objects talshn 2020-06-25 14:18 ` Thomas Monjalon 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 02/10] eal: move OS common options functions talshn 2020-06-25 14:29 ` Thomas Monjalon 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 03/10] pci: use OS generic memory mapping functions talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 04/10] pci: build on Windows talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 05/10] pci: fix format warning " talshn 2020-06-25 12:54 ` Thomas Monjalon 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 06/10] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 07/10] drivers: fix incorrect meson import folder " talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 08/10] bus/pci: introduce Windows support with stubs talshn 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 09/10] bus/pci: support Windows with bifurcated drivers talshn 2020-06-27 1:46 ` Narcisa Ana Maria Vasile 2020-06-28 12:10 ` Tal Shnaiderman 2020-06-24 8:28 ` [dpdk-dev] [PATCH v9 10/10] build: generate version.map file for MinGW on Windows talshn 2020-06-27 1:54 ` [dpdk-dev] [PATCH v9 00/10] Windows bus/pci support Narcisa Ana Maria Vasile 2020-06-28 12:32 ` Tal Shnaiderman 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 " talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 01/10] eal: move OS common config objects talshn 2020-06-29 15:36 ` Tal Shnaiderman 2020-06-29 12:37 ` talshn [this message] 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 03/10] pci: use OS generic memory mapping functions talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 04/10] pci: build on Windows talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 05/10] pci: fix format warning " talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 06/10] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 07/10] drivers: fix incorrect meson import folder " talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 08/10] bus/pci: introduce Windows support with stubs talshn 2020-06-29 20:40 ` Thomas Monjalon 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 09/10] bus/pci: support Windows with bifurcated drivers talshn 2020-06-29 12:37 ` [dpdk-dev] [PATCH v10 10/10] build: generate version.map file for MinGW on Windows talshn 2020-06-29 22:07 ` [dpdk-dev] [PATCH v10 00/10] Windows bus/pci support Thomas Monjalon 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 2/9] pci: use OS generic memory mapping functions talshn 2020-06-22 21:54 ` Dmitry Kozlyuk 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 3/9] pci: build on Windows talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 4/9] pci: fix format warning " talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 5/9] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 6/9] drivers: fix incorrect meson import folder " talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 7/9] bus/pci: introduce Windows support with stubs talshn 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 8/9] bus/pci: support Windows with bifurcated drivers talshn 2020-06-23 23:28 ` Dmitry Kozlyuk 2020-06-24 8:02 ` Tal Shnaiderman 2020-06-22 7:55 ` [dpdk-dev] [PATCH v8 9/9] build: generate version.map file for MinGW on Windows talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 2/9] pci: use OS generic memory mapping functions talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 3/9] pci: build on Windows talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 4/9] pci: fix format warning " talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 5/9] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 6/9] drivers: fix incorrect meson import folder " talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 7/9] bus/pci: introduce Windows support with stubs talshn 2020-06-21 11:23 ` Fady Bader 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 8/9] bus/pci: support Windows with bifurcated drivers talshn 2020-06-21 10:26 ` [dpdk-dev] [PATCH v7 9/9] build: generate version.map file for MinGW on Windows talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 2/9] pci: use OS generic memory mapping functions talshn 2020-06-18 22:44 ` Dmitry Kozlyuk 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 3/9] pci: build on Windows talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 4/9] pci: fix format warning " talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 5/9] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 6/9] drivers: fix incorrect meson import folder " talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 7/9] bus/pci: introduce Windows support with stubs talshn 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 8/9] bus/pci: support Windows with bifurcated drivers talshn 2020-06-18 22:40 ` Dmitry Kozlyuk 2020-06-18 21:15 ` [dpdk-dev] [PATCH v6 9/9] build: generate version.map file for MingW on Windows talshn 2020-06-18 23:13 ` Dmitry Kozlyuk 2020-06-21 6:36 ` Tal Shnaiderman 2020-06-20 18:54 ` Dmitry Kozlyuk 2020-06-21 5:49 ` Tal Shnaiderman 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 2/8] pci: use OS generic memory mapping functions talshn 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 3/8] pci: build on Windows talshn 2020-06-16 8:22 ` Thomas Monjalon 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 4/8] pci: fix format warning " talshn 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 5/8] drivers: ignore pmdinfogen generation for Windows talshn 2020-06-17 20:39 ` Dmitry Kozlyuk 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 6/8] drivers: fix incorrect meson import folder " talshn 2020-06-16 8:29 ` Thomas Monjalon 2020-06-16 9:17 ` Bruce Richardson 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 7/8] bus/pci: introduce Windows support with stubs talshn 2020-06-17 20:29 ` Dmitry Kozlyuk 2020-06-09 10:31 ` [dpdk-dev] [PATCH v5 8/8] bus/pci: support Windows with bifurcated drivers talshn 2020-06-17 20:28 ` Dmitry Kozlyuk
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200629123741.20716-3-talshn@mellanox.com \ --to=talshn@mellanox.com \ --cc=anatoly.burakov@intel.com \ --cc=bruce.richardson@intel.com \ --cc=david.marchand@redhat.com \ --cc=dev@dpdk.org \ --cc=dmitry.kozliuk@gmail.com \ --cc=fady@mellanox.com \ --cc=grive@u256.net \ --cc=harini.ramakrishnan@microsoft.com \ --cc=navasile@linux.microsoft.com \ --cc=ocardona@microsoft.com \ --cc=pallavi.kadam@intel.com \ --cc=ranjit.menon@intel.com \ --cc=thomas@monjalon.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git