Skip to content

Commit

Permalink
ovs-atomic-msvc: Disable a compiler warning.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Eitan Eliahu <[email protected]>
  • Loading branch information
shettyg committed Sep 15, 2014
1 parent b7ccaf6 commit b816a95
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ovs-atomic-msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit b816a95

Please sign in to comment.