[dpdk-dev] [PATCH v4] doc: announce API changes for Windows compatibility

Thomas Monjalon thomas at monjalon.net
Mon Aug 2 14:13:13 CEST 2021


21/07/2021 21:55, Dmitry Kozlyuk:
> Windows headers define `s_addr`, `min`, and `max` as macros.
> If DPDK headers are included after Windows ones, DPDK structure
> definitions containing fields with these names get broken (example 1),
> as well as any usage of such fields (example 2). If DPDK headers
> undefined these macros, it could break consumer code (example 3).
> It is proposed to rename structure fields in DPDK, because Win32 headers
> are used more widely than DPDK, as a general-purpose platform compared
> to domain-specific kit, and are harder to fix because of that.
> Exact new names are left for further discussion.
> 
> Example 1:
> 
>     /* in DPDK public header included after windows.h */
>     struct rte_type {
>         int min;    /* ERROR: `min` is a macro */
>     };
> 
> Example 2:
> 
>     #include <rte_ether.h>
>     #include <winsock2.h>
>     struct rte_ether_hdr eh;
>     eh.s_addr.addr_bytes[0] = 0;    /* ERROR: `addr_s` is a macro */
> 
> Example 3:
> 
>     #include <winsock2.h>
>     #include <rte_ether.h>
>     struct in_addr addr;
>     addr.s_addr = 0;      /* ERROR: there is no `s_addr` field,
>                              and `s_addr` macro is undefined by DPDK. */
> 
> Commit 6c068dbd9fea ("net: work around s_addr macro on Windows")
> modified definition of `struct rte_ether_hdr` to avoid the issue.
> However, the workaround assumes `#define s_addr S_addr.S_un`
> in Windows headers, which is not a part of official API.
> It also complicates the definition of `struct rte_ether_hdr`.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
> Acked-by: Khoa To <khot at microsoft.com>
> ---
> +* net: ``s_addr`` and ``d_addr`` fields of ``rte_ether_hdr`` structure
> +  will be renamed in DPDK 21.11 to avoid conflict with Windows Sockets headers.
> +
> +* compressdev: ``min`` and ``max`` fields of ``rte_param_log2_range`` structure
> +  will be renamed in DPDK 21.11 to avoid conflict with Windows Sockets headers.

The struct rte_param_log2_range should also be renamed to include "compress" prefix.
But as we break the struct API, it is not an issue I guess.

> +* cryptodev: ``min`` and ``max`` fields of ``rte_crypto_param_range`` structure
> +  will be renamed in DPDK 21.11 to avoid conflict with Windows Sockets headers.

Acked-by: Thomas Monjalon <thomas at monjalon.net>




More information about the dev mailing list