* [dpdk-stable] [PATCH] eal/windows: use bundled getopt with MinGW
@ 2020-09-24 23:17 Dmitry Kozlyuk
2020-09-26 1:23 ` [dpdk-stable] [EXTERNAL] " Khoa To
2020-09-28 19:53 ` [dpdk-stable] " Kadam, Pallavi
0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Kozlyuk @ 2020-09-24 23:17 UTC (permalink / raw)
To: dev
Cc: Dmitry Kozlyuk, stable, Khoa To, Tal Shnaiderman,
Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam
Clang builds use getopt.c in librte_eal while MinGW provides
implementation as part of the toolchain. Statically linking librte_eal
to an application that depends on getopt results in undefined reference
errors with MinGW. There are no such errors with Clang, because with
Clang librte_eal actually defines getopt functions.
Use getopt.c in EAL with Clang and MinGW to get identical behavior.
Adjust code for MinGW. Incidentally, this removes a bug when free() is
called on uninitialized memory.
Fixes: 5e373e456e6 ("eal/windows: add getopt implementation")
Cc: stable@dpdk.org
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reported-by: Khoa To <khot@microsoft.com>
Reported-by: Tal Shnaiderman <talshn@nvidia.com>
---
This patch probably supesedes http://patchwork.dpdk.org/patch/78574/.
lib/librte_eal/meson.build | 3 ---
lib/librte_eal/windows/getopt.c | 9 ++++-----
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 8d492897d..7d6222e78 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -25,6 +25,3 @@ endif
if cc.has_function('getentropy', prefix : '#include <unistd.h>')
cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
endif
-if cc.has_header('getopt.h')
- cflags += ['-DHAVE_GETOPT_H', '-DHAVE_GETOPT', '-DHAVE_GETOPT_LONG']
-endif
diff --git a/lib/librte_eal/windows/getopt.c b/lib/librte_eal/windows/getopt.c
index a08f7c109..a1f51c6c2 100644
--- a/lib/librte_eal/windows/getopt.c
+++ b/lib/librte_eal/windows/getopt.c
@@ -242,7 +242,6 @@ getopt_internal(int nargc, char **nargv, const char *options,
char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
- char *buf;
size_t len;
int optreset = 0;
@@ -253,16 +252,16 @@ getopt_internal(int nargc, char **nargv, const char *options,
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*/
- if (posixly_correct == -1)
- posixly_correct = _dupenv_s(&buf, &len, "POSIXLY_CORRECT");
+ if (posixly_correct == -1) {
+ errno_t err = _wgetenv_s(&len, NULL, 0, L"POSIXLY_CORRECT");
+ posixly_correct = (err == 0) && (len > 0);
+ }
if (!posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
else if (*options == '-')
flags |= FLAG_ALLARGS;
if (*options == '+' || *options == '-')
options++;
- if (!posixly_correct)
- free(buf);
/*
* reset if requested
*/
--
2.25.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [EXTERNAL] [PATCH] eal/windows: use bundled getopt with MinGW
2020-09-24 23:17 [dpdk-stable] [PATCH] eal/windows: use bundled getopt with MinGW Dmitry Kozlyuk
@ 2020-09-26 1:23 ` Khoa To
2020-10-05 7:23 ` Thomas Monjalon
2020-09-28 19:53 ` [dpdk-stable] " Kadam, Pallavi
1 sibling, 1 reply; 4+ messages in thread
From: Khoa To @ 2020-09-26 1:23 UTC (permalink / raw)
To: Dmitry Kozlyuk, dev
Cc: stable, Tal Shnaiderman, Narcisa Ana Maria Vasile,
Dmitry Malloy (MESHCHANINOV),
Pallavi Kadam
> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Thursday, September 24, 2020 4:17 PM
> To: dev@dpdk.org
> Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>; stable@dpdk.org; Khoa To
> <khot@microsoft.com>; Tal Shnaiderman <talshn@nvidia.com>; Narcisa Ana
> Maria Vasile <navasile@linux.microsoft.com>; Dmitry Malloy
> (MESHCHANINOV) <dmitrym@microsoft.com>; Pallavi Kadam
> <pallavi.kadam@intel.com>
> Subject: [EXTERNAL] [PATCH] eal/windows: use bundled getopt with MinGW
>
> Clang builds use getopt.c in librte_eal while MinGW provides
> implementation as part of the toolchain. Statically linking librte_eal
> to an application that depends on getopt results in undefined reference
> errors with MinGW. There are no such errors with Clang, because with
> Clang librte_eal actually defines getopt functions.
>
> Use getopt.c in EAL with Clang and MinGW to get identical behavior.
> Adjust code for MinGW. Incidentally, this removes a bug when free() is
> called on uninitialized memory.
>
> Fixes: 5e373e456e6 ("eal/windows: add getopt implementation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Reported-by: Khoa To <khot@microsoft.com>
> Reported-by: Tal Shnaiderman <talshn@nvidia.com>
> ---
>
> This patch probably supesedes
> https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
> work.dpdk.org%2Fpatch%2F78574%2F&data=02%7C01%7Ckhot%40micr
> osoft.com%7C7f6e47a7db0945b2c93708d860dffaa3%7C72f988bf86f141af91a
> b2d7cd011db47%7C1%7C0%7C637365862839491238&sdata=%2BQPJ2US
> hknxQLV97rQRVc0sT55TpTNjNTq1m9oj9eFs%3D&reserved=0.
>
Acked-by: Khoa To <khot@microsoft.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [EXTERNAL] [PATCH] eal/windows: use bundled getopt with MinGW
2020-09-26 1:23 ` [dpdk-stable] [EXTERNAL] " Khoa To
@ 2020-10-05 7:23 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2020-10-05 7:23 UTC (permalink / raw)
To: Dmitry Kozlyuk
Cc: dev, stable, Tal Shnaiderman, Narcisa Ana Maria Vasile,
Dmitry Malloy (MESHCHANINOV),
Pallavi Kadam, Khoa To
> > Clang builds use getopt.c in librte_eal while MinGW provides
> > implementation as part of the toolchain. Statically linking librte_eal
> > to an application that depends on getopt results in undefined reference
> > errors with MinGW. There are no such errors with Clang, because with
> > Clang librte_eal actually defines getopt functions.
> >
> > Use getopt.c in EAL with Clang and MinGW to get identical behavior.
> > Adjust code for MinGW. Incidentally, this removes a bug when free() is
> > called on uninitialized memory.
> >
> > Fixes: 5e373e456e6 ("eal/windows: add getopt implementation")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > Reported-by: Khoa To <khot@microsoft.com>
> > Reported-by: Tal Shnaiderman <talshn@nvidia.com>
> > ---
> >
> > This patch probably supesedes
> > https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
> > work.dpdk.org%2Fpatch%2F78574%2F&data=02%7C01%7Ckhot%40micr
> > osoft.com%7C7f6e47a7db0945b2c93708d860dffaa3%7C72f988bf86f141af91a
> > b2d7cd011db47%7C1%7C0%7C637365862839491238&sdata=%2BQPJ2US
> > hknxQLV97rQRVc0sT55TpTNjNTq1m9oj9eFs%3D&reserved=0.
>
> Acked-by: Khoa To <khot@microsoft.com>
Applied, thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [PATCH] eal/windows: use bundled getopt with MinGW
2020-09-24 23:17 [dpdk-stable] [PATCH] eal/windows: use bundled getopt with MinGW Dmitry Kozlyuk
2020-09-26 1:23 ` [dpdk-stable] [EXTERNAL] " Khoa To
@ 2020-09-28 19:53 ` Kadam, Pallavi
1 sibling, 0 replies; 4+ messages in thread
From: Kadam, Pallavi @ 2020-09-28 19:53 UTC (permalink / raw)
To: Dmitry Kozlyuk, dev
Cc: stable, Khoa To, Tal Shnaiderman, Narcisa Ana Maria Vasile,
Dmitry Malloy
On 9/24/2020 4:17 PM, Dmitry Kozlyuk wrote:
> Clang builds use getopt.c in librte_eal while MinGW provides
> implementation as part of the toolchain. Statically linking librte_eal
> to an application that depends on getopt results in undefined reference
> errors with MinGW. There are no such errors with Clang, because with
> Clang librte_eal actually defines getopt functions.
>
> Use getopt.c in EAL with Clang and MinGW to get identical behavior.
> Adjust code for MinGW. Incidentally, this removes a bug when free() is
> called on uninitialized memory.
>
> Fixes: 5e373e456e6 ("eal/windows: add getopt implementation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Reported-by: Khoa To <khot@microsoft.com>
> Reported-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Pallavi Kadam <pallavi.kadam@intel.com
<mailto:pallavi.kadam@intel.com>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-05 7:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 23:17 [dpdk-stable] [PATCH] eal/windows: use bundled getopt with MinGW Dmitry Kozlyuk
2020-09-26 1:23 ` [dpdk-stable] [EXTERNAL] " Khoa To
2020-10-05 7:23 ` Thomas Monjalon
2020-09-28 19:53 ` [dpdk-stable] " Kadam, Pallavi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).