ppc64: fix compilation of when AltiVec is enabled
PATCH v2 1/1 ppc64: fix compilation of when AltiVec is enabled
The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.
This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;
Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.
[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html
--- .../common/include/arch/ppc_64/rte_memcpy.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +11 -0
@@ -37,6 +37,17 @@#include <string.h> /*To include altivec.h, GCC version must >= 4.8 */ #include <altivec.h> +/* +* Compilation workaround for PPC64 targets when AltiVec is fully +* enabled e.g. with std=c11. Otherwise there would be a type conflict +* of "bool" between stdbool and altivec. +*/ +#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__) +#undef bool +/* redefine as in stdbool.h */ +#define bool _Bool +#endif +#ifdef __cplusplusextern "C" {
Signature · 1 line
2.17.1
Quoted 10 lines · Christian Ehrhardt
The definition of almost any newer standard like --stc=c11 will drop
__APPLCE_ALTIVEC__which otherwise would be defined.
If that is the case thenaltivec.hwill redefine bool to a type conflicting with those defined bystdbool.h.This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector__boolint’ {aka ‘__vector(4)__boolint’} from type ‘int’in_port_id_set= false;
Quoted 7 lines
Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.
[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html
Tested-by Takeshi T Yoshimura <[email protected]>Reviewed-by Adrien Mazarguil [email protected]
After more of a decade of submitting patches I should get an email right :-/ Well V3 it will be ...
Quoted 32 lines
Signed-off-by Christian Ehrhardt <[email protected]>--- .../common/include/arch/ppc_64/rte_memcpy.h | 11 +++++++++++ 1 file changed, 11 insertions(+)lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +11
-1@@ -37,6 +37,17 @@#include <string.h> /*To include altivec.h, GCC version must >= 4.8 */ #include <altivec.h> +/* +* Compilation workaround for PPC64 targets when AltiVec is fully +* enabled e.g. with std=c11. Otherwise there would be a type conflict +* of "bool" between stdbool and altivec. +*/ +#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__) +#undef bool +/* redefine as in stdbool.h */ +#define bool _Bool +#endif +#ifdef __cplusplusextern "C" { --2.17.1
Signature · 3 lines
Christian Ehrhardt Software Engineer, Ubuntu Server Canonical Ltd