From: Joe Stringer Date: Mon, 21 Dec 2015 23:56:40 +0000 (-0800) Subject: types: Define OVS_*128_MAX statically. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=f3d2a2957b28b7cbd0ce00945e96de1604b49e0b types: Define OVS_*128_MAX statically. The previous definitions of these variables using designated initializers caused a variety of issues when attempting to compile with MSVC, particularly if including these headers from C++ code. By defining them like this, we can appease MSVC and keep the definitions the same on all platforms. VMware-BZ: #1517163 Suggested-by: Yin Lin Signed-off-by: Joe Stringer Acked-by: Ben Pfaff --- diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h index 32b27d033..658fb50b0 100644 --- a/include/openvswitch/types.h +++ b/include/openvswitch/types.h @@ -99,8 +99,13 @@ typedef union { } be64; } ovs_be128; -#define OVS_U128_MAX (ovs_u128) { .u64 = { UINT64_MAX, UINT64_MAX } } -#define OVS_BE128_MAX (ovs_be128) { .be64 = { OVS_BE64_MAX, OVS_BE64_MAX } } +/* MSVC2015 doesn't support designated initializers when compiling C++, + * and doesn't support ternary operators with non-designated initializers. + * So we use these static definitions rather than using initializer macros. */ +static const ovs_u128 OVS_U128_MAX = { { UINT32_MAX, UINT32_MAX, + UINT32_MAX, UINT32_MAX } }; +static const ovs_be128 OVS_BE128_MAX = { { OVS_BE32_MAX, OVS_BE32_MAX, + OVS_BE32_MAX, OVS_BE32_MAX } }; /* A 64-bit value, in network byte order, that is only aligned on a 32-bit * boundary. */ diff --git a/lib/util.h b/lib/util.h index 340ef65f0..248058334 100644 --- a/lib/util.h +++ b/lib/util.h @@ -574,9 +574,7 @@ ovs_u128_is_zero(const ovs_u128 *val) static inline bool ovs_u128_is_ones(const ovs_u128 *val) { - ovs_u128 ones = OVS_U128_MAX; - - return ovs_u128_equals(val, &ones); + return ovs_u128_equals(val, &OVS_U128_MAX); } /* Returns non-zero if the parameters have equal value. */