eal/windows: fix memory management macros usage
PATCH 1/1 eal/windows: fix memory management macros usage
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.
--- lib/eal/windows/eal_memory.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/eal/windows/eal_memory.c +8 -0
@@ -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 )
Signature · 1 line
2.39.2
Quoted 15 lines · Gregory Etelson
Windows compilation with cross-mingw on Fedora 39 failed because
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERwere 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 definitioneal_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 definitionThe patch masks
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERmacros if they were pre-defined by compiler.
Quoted 8 lines
The patch also masks
MEM_COALESCE_PLACEHOLDERSandMEM_PRESERVE_PLACEHOLDERto prevent similar errors.Fixes 2a5d547a4a9b ("eal/windows: implement basic memory management")Signed-off-by Gregory Etelson <[email protected]>---
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
#elsestatic_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...") #endif
either way, this is straight forward.
Hello Tyler,
Quoted 5 lines
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
Quoted 12 lines
#ifndef
MEM_COALESCE_PLACEHOLDERS
#defineMEM_COALESCE_PLACEHOLDERS0x00000001
#elsestatic_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")#endifeither way, this is straight forward.
Acked-by Tyler Retzlaff <[email protected]>
Quoted 12 lines · Gregory
Hello Tyler,
Quoted 5 lines
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_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERare defined in Win32 API.
Quoted 6 lines
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.
Quoted 17 lines
Regards,
GregoryQuoted 12 lines
#ifndef
MEM_COALESCE_PLACEHOLDERS
#defineMEM_COALESCE_PLACEHOLDERS0x00000001
#elsestatic_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")#endifeither way, this is straight forward.
Acked-by Tyler Retzlaff <[email protected]>
Hello Tyler,
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines
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_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERare 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.
Quoted 9 lines
Quoted 1 line
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:
Quoted 18 lines · Gregory
Quoted 17 lines
Hello Tyler,
Quoted 5 lines
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_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERare 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.
Quoted 8 lines
Quoted 1 line
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:
Quoted 15 lines
Windows compilation with cross-mingw on Fedora 39 failed because
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERwere 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 definitioneal_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 definitionThe patch masks
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERmacros if they were pre-defined by compiler.
Quoted 7 lines
The patch also masks
MEM_COALESCE_PLACEHOLDERSandMEM_PRESERVE_PLACEHOLDERto prevent similar errors.Fixes 2a5d547a4a9b ("eal/windows: implement basic memory management")Signed-off-by Gregory Etelson <[email protected]>
Thomas Monjalon
Acked-by14/11/2023 20:19, Dmitry Kozlyuk:
Quoted 19 lines
2023-11-14 19:05 (UTC+0200), Gregory Etelson:
Quoted 18 lines
Windows compilation with cross-mingw on Fedora 39 failed because
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERwere 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 definitioneal_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 definitionThe patch masks
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERmacros if they were pre-defined by compiler.The patch also masks
MEM_COALESCE_PLACEHOLDERSandMEM_PRESERVE_PLACEHOLDERto prevent similar errors.
Quoted 6 lines
Quoted 4 lines
Fixes 2a5d547a4a9b ("eal/windows: implement basic memory management")Signed-off-by Gregory Etelson <[email protected]>Acked-by Dmitry Kozlyuk <[email protected]>
David Marchand
Acked-by Tyler Retzlaff Acked-by Dmitry Kozlyuk Acked-by Thomas Monjalon on v1 1/1 AppliedQuoted 16 lines · Gregory Etelson
Windows compilation with cross-mingw on Fedora 39 failed because
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERwere 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 definitioneal_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 definitionThe patch masks
MEM_REPLACE_PLACEHOLDERandMEM_RESERVE_PLACEHOLDERmacros if they were pre-defined by compiler.
Quoted 7 lines
The patch also masks
MEM_COALESCE_PLACEHOLDERSandMEM_PRESERVE_PLACEHOLDERto prevent similar errors.Fixes 2a5d547a4a9b ("eal/windows: implement basic memory management")Signed-off-by Gregory Etelson <[email protected]>
For the record, the same issue has been reported with Ubuntu 23.10.
Applied, thanks.
Signature · 1 line
David Marchand