[V2,1/1] eal: fix build with conflicting libc variable memory_order
Checks
Commit Message
The cited commit introduced functions with 'int memory_order' argument.
The C11 standard section 7.17.1.4 defines 'memory_order' as the
"enumerated type whose enumerators identify memory ordering constraints".
A compilation error occurs:
error: declaration of 'memory_order' shadows a global declaration
[-Werror=shadow]
rte_atomic_thread_fence(int memory_order)
This issue was hit when trying to compile OVS with gcc 4.8.5. This
compiler version does not provide stdatomic.h, so enum memory_order is
redefined in OVS code.
In another case, if the compiler does provide stdatomic.h header,
passing -Wsystem-headers in the CFLAGS will also cause that failure.
Fix it by changing the argument name 'memory_order' to 'memorder'.
Fixes: 672a15056380 ("eal: add wrapper for C11 atomic thread fence")
Signed-off-by: Eli Britstein <elibr@nvidia.com>
---
lib/librte_eal/arm/include/rte_atomic_32.h | 4 ++--
lib/librte_eal/arm/include/rte_atomic_64.h | 4 ++--
lib/librte_eal/include/generic/rte_atomic.h | 2 +-
lib/librte_eal/ppc/include/rte_atomic.h | 4 ++--
lib/librte_eal/x86/include/rte_atomic.h | 6 +++---
5 files changed, 10 insertions(+), 10 deletions(-)
Comments
<snip>
>
> The cited commit introduced functions with 'int memory_order' argument.
> The C11 standard section 7.17.1.4 defines 'memory_order' as the
> "enumerated type whose enumerators identify memory ordering
> constraints".
>
> A compilation error occurs:
> error: declaration of 'memory_order' shadows a global declaration
> [-Werror=shadow]
> rte_atomic_thread_fence(int memory_order)
>
> This issue was hit when trying to compile OVS with gcc 4.8.5. This compiler
> version does not provide stdatomic.h, so enum memory_order is redefined
> in OVS code.
> In another case, if the compiler does provide stdatomic.h header, passing -
> Wsystem-headers in the CFLAGS will also cause that failure.
>
> Fix it by changing the argument name 'memory_order' to 'memorder'.
>
> Fixes: 672a15056380 ("eal: add wrapper for C11 atomic thread fence")
>
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
We are missing the earlier ACKs.
<snip>
On Thu, Oct 15, 2020 at 5:10 PM Eli Britstein <elibr@nvidia.com> wrote:
>
> The cited commit introduced functions with 'int memory_order' argument.
> The C11 standard section 7.17.1.4 defines 'memory_order' as the
> "enumerated type whose enumerators identify memory ordering constraints".
>
> A compilation error occurs:
> error: declaration of 'memory_order' shadows a global declaration
> [-Werror=shadow]
> rte_atomic_thread_fence(int memory_order)
>
> This issue was hit when trying to compile OVS with gcc 4.8.5. This
> compiler version does not provide stdatomic.h, so enum memory_order is
> redefined in OVS code.
> In another case, if the compiler does provide stdatomic.h header,
> passing -Wsystem-headers in the CFLAGS will also cause that failure.
>
> Fix it by changing the argument name 'memory_order' to 'memorder'.
>
> Fixes: 672a15056380 ("eal: add wrapper for C11 atomic thread fence")
>
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
Please, report previous review/acks, and thread replies with original.
Reviewed-by: Asaf Penso <asafp@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Applied, thanks.
@@ -34,9 +34,9 @@ extern "C" {
#define rte_io_rmb() rte_rmb()
static __rte_always_inline void
-rte_atomic_thread_fence(int memory_order)
+rte_atomic_thread_fence(int memorder)
{
- __atomic_thread_fence(memory_order);
+ __atomic_thread_fence(memorder);
}
#ifdef __cplusplus
@@ -38,9 +38,9 @@ extern "C" {
#define rte_io_rmb() rte_rmb()
static __rte_always_inline void
-rte_atomic_thread_fence(int memory_order)
+rte_atomic_thread_fence(int memorder)
{
- __atomic_thread_fence(memory_order);
+ __atomic_thread_fence(memorder);
}
/*------------------------ 128 bit atomic operations -------------------------*/
@@ -122,7 +122,7 @@ static inline void rte_io_rmb(void);
/**
* Synchronization fence between threads based on the specified memory order.
*/
-static inline void rte_atomic_thread_fence(int memory_order);
+static inline void rte_atomic_thread_fence(int memorder);
/*------------------------- 16 bit atomic operations -------------------------*/
@@ -37,9 +37,9 @@ extern "C" {
#define rte_io_rmb() rte_rmb()
static __rte_always_inline void
-rte_atomic_thread_fence(int memory_order)
+rte_atomic_thread_fence(int memorder)
{
- __atomic_thread_fence(memory_order);
+ __atomic_thread_fence(memorder);
}
/*------------------------- 16 bit atomic operations -------------------------*/
@@ -87,12 +87,12 @@ rte_smp_mb(void)
* used instead.
*/
static __rte_always_inline void
-rte_atomic_thread_fence(int memory_order)
+rte_atomic_thread_fence(int memorder)
{
- if (memory_order == __ATOMIC_SEQ_CST)
+ if (memorder == __ATOMIC_SEQ_CST)
rte_smp_mb();
else
- __atomic_thread_fence(memory_order);
+ __atomic_thread_fence(memorder);
}
/*------------------------- 16 bit atomic operations -------------------------*/