[ovs-dev] [PATCH 4/4] ovs-atomic-msvc: Disable a compiler warning.

Gurucharan Shetty shettyg at nicira.com
Mon Sep 15 17:36:14 UTC 2014


MSVC does not support c11 style atomics for the C compiler.
Windows has different InterLocked* functions for different data
sizes.  ovs-atomic-msvc.h maps the api in ovs-atomic.h (which is similar
to c11 atomics) to the available atomic functions in Windows. In some
cases, this causes compiler warnings about mismatched data sizes because
the generated code has 'if else' conditions on different data sizes and
proper casting is not possible.

In current OVS code base, we get one compiler warning through ovs-rcu.h
which says "‘void *’ differs in levels of indirection from LONGLONG."
This comes from the following in ovs-atomic-msvc.h for atomic_read64():
*(DST) = InterlockedOr64((int64_t volatile *) (SRC), 0);
when *DST is a void pointer (because InterLockedOr64 returns LONGLONG).
But this code path is only every hit for 64 bit data. So it should be safe to
disable the warning. (Any real bugs in api calls would hopefully be caught
while compiling on Linux using gcc/clang).

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/ovs-atomic-msvc.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/ovs-atomic-msvc.h b/lib/ovs-atomic-msvc.h
index 11f5ad2..e8e4891 100644
--- a/lib/ovs-atomic-msvc.h
+++ b/lib/ovs-atomic-msvc.h
@@ -154,7 +154,10 @@ atomic_signal_fence(memory_order order)
     if (((size_t) (SRC) & (sizeof *(SRC) - 1)) == 0) {                     \
         *(DST) = *(SRC);                                                   \
     } else {                                                               \
+    __pragma (warning(push))                                               \
+    __pragma (warning(disable:4047))                                       \
        *(DST) = InterlockedOr64((int64_t volatile *) (SRC), 0);            \
+    __pragma (warning(pop))                                                \
     }
 
 #define atomic_read(SRC, DST)                               \
-- 
1.7.9.5




More information about the dev mailing list