eal/windows: fix memory management macros usage
Checks
Commit Message
Windows compilation with cross-mingw on Fedora 39 failed
because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
already defined in the compiler environment:
eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
this is the location of the previous definition
eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
this is the location of the previous definition
The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
macros if they were pre-defined by compiler.
The patch also masks MEM_COALESCE_PLACEHOLDERS and
MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
lib/eal/windows/eal_memory.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
On Tue, Nov 14, 2023 at 07:05:29PM +0200, Gregory Etelson wrote:
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
>
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
>
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
>
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
>
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
>
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
>
> Cc: stable@dpdk.org
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
since we are duplicating something that comes from something else that
has been duplicated out of windows WDK here it might be a reasonable
safety check to verify that our duplicated values match our
expectations?
#ifndef MEM_COALESCE_PLACEHOLDERS
#define MEM_COALESCE_PLACEHOLDERS 0x00000001
#else
static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
#endif
either way, this is straight forward.
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Hello Tyler,
>
> since we are duplicating something that comes from something else that
> has been duplicated out of windows WDK here it might be a reasonable
> safety check to verify that our duplicated values match our
> expectations?
MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
are defined in Win32 API.
DPDK has no expectations about these values. DPDK needs them as parameters
to the VirtualX function calls.
It looks like the macros were added to EAL because they were missing in
mingw.
Once compiler environment was fixed, the proper order was restored.
Regards,
Gregory
>
> #ifndef MEM_COALESCE_PLACEHOLDERS
> #define MEM_COALESCE_PLACEHOLDERS 0x00000001
> #else
> static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
> #endif
>
> either way, this is straight forward.
>
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
>
>
On Tue, Nov 14, 2023 at 08:16:22PM +0200, Etelson, Gregory wrote:
> Hello Tyler,
>
> >
> >since we are duplicating something that comes from something else that
> >has been duplicated out of windows WDK here it might be a reasonable
> >safety check to verify that our duplicated values match our
> >expectations?
>
> MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
> MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> are defined in Win32 API.
>
> DPDK has no expectations about these values. DPDK needs them as
> parameters to the VirtualX function calls.
> It looks like the macros were added to EAL because they were missing
> in mingw.
>
> Once compiler environment was fixed, the proper order was restored.
yes, there is a lag between when names appear in the actual WDK and when
mingw takes a the snapshot of the headers. so long as the copy they take
is only from released WDK versions that align with an OS we shouldn't
expect the values to change but if the duplicated names in dpdk were
based upon an insider (preview version of SDK) value that later got changed
there could be a misalignment. unlikely but possible.
>
> Regards,
> Gregory
>
>
> >
> >#ifndef MEM_COALESCE_PLACEHOLDERS
> >#define MEM_COALESCE_PLACEHOLDERS 0x00000001
> >#else
> >static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
> >#endif
> >
> >either way, this is straight forward.
> >
> >Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> >
> >
Hello Tyler,
>>>
>>> since we are duplicating something that comes from something else that
>>> has been duplicated out of windows WDK here it might be a reasonable
>>> safety check to verify that our duplicated values match our
>>> expectations?
>>
>> MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
>> MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
>> are defined in Win32 API.
>>
>> DPDK has no expectations about these values. DPDK needs them as
>> parameters to the VirtualX function calls.
>> It looks like the macros were added to EAL because they were missing
>> in mingw.
>>
>> Once compiler environment was fixed, the proper order was restored.
>
> yes, there is a lag between when names appear in the actual WDK and when
> mingw takes a the snapshot of the headers. so long as the copy they take
> is only from released WDK versions that align with an OS we shouldn't
> expect the values to change but if the duplicated names in dpdk were
> based upon an insider (preview version of SDK) value that later got changed
> there could be a misalignment. unlikely but possible.
>
DPDK matrix works with official OS compiler versions.
Such compilers will not provide bad API.
As for non-official compilers or releases, they come without any warranty.
Regards,
Gregory
2023-11-14 10:22 (UTC-0800), Tyler Retzlaff:
> On Tue, Nov 14, 2023 at 08:16:22PM +0200, Etelson, Gregory wrote:
> > Hello Tyler,
> >
> > >
> > >since we are duplicating something that comes from something else that
> > >has been duplicated out of windows WDK here it might be a reasonable
> > >safety check to verify that our duplicated values match our
> > >expectations?
> >
> > MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
> > MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> > are defined in Win32 API.
> >
> > DPDK has no expectations about these values. DPDK needs them as
> > parameters to the VirtualX function calls.
> > It looks like the macros were added to EAL because they were missing
> > in mingw.
> >
> > Once compiler environment was fixed, the proper order was restored.
>
> yes, there is a lag between when names appear in the actual WDK and when
> mingw takes a the snapshot of the headers. so long as the copy they take
> is only from released WDK versions that align with an OS we shouldn't
> expect the values to change but if the duplicated names in dpdk were
> based upon an insider (preview version of SDK) value that later got changed
> there could be a misalignment. unlikely but possible.
I think we should trust the toolchain unless there is an known bug,
i.e. the patch is good as-is.
2023-11-14 19:05 (UTC+0200), Gregory Etelson:
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
>
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
>
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
>
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
>
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
>
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
>
> Cc: stable@dpdk.org
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
14/11/2023 20:19, Dmitry Kozlyuk:
> 2023-11-14 19:05 (UTC+0200), Gregory Etelson:
> > Windows compilation with cross-mingw on Fedora 39 failed
> > because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> > already defined in the compiler environment:
> >
> > eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> > /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> > this is the location of the previous definition
> >
> > eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> > /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> > this is the location of the previous definition
> >
> > The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> > macros if they were pre-defined by compiler.
> >
> > The patch also masks MEM_COALESCE_PLACEHOLDERS and
> > MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
> >
> > Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> >
> > Cc: stable@dpdk.org
> > Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
On Tue, Nov 14, 2023 at 6:06 PM Gregory Etelson <getelson@nvidia.com> wrote:
>
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
>
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
>
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
>
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
>
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
>
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> Cc: stable@dpdk.org
>
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
For the record, the same issue has been reported with Ubuntu 23.10.
Applied, thanks.
@@ -72,10 +72,18 @@ static VirtualAlloc2_type VirtualAlloc2_ptr;
#ifdef RTE_TOOLCHAIN_GCC
+#ifndef MEM_COALESCE_PLACEHOLDERS
#define MEM_COALESCE_PLACEHOLDERS 0x00000001
+#endif
+#ifndef MEM_PRESERVE_PLACEHOLDER
#define MEM_PRESERVE_PLACEHOLDER 0x00000002
+#endif
+#ifndef MEM_REPLACE_PLACEHOLDER
#define MEM_REPLACE_PLACEHOLDER 0x00004000
+#endif
+#ifndef MEM_RESERVE_PLACEHOLDER
#define MEM_RESERVE_PLACEHOLDER 0x00040000
+#endif
int
eal_mem_win32api_init(void)