uint8_t PAD_ID[ROUND_UP(sizeof(struct { MEMBERS }), UNIT)]; \
}
#else
-#define PADDED_MEMBERS_CACHELINE_MARKER(UNIT, CACHELINE, MEMBERS) \
- union { \
- OVS_CACHE_LINE_MARKER CACHELINE; \
- struct { MEMBERS }; \
- struct { MEMBERS } named_member__; \
- uint8_t PAD_ID[ROUND_UP(sizeof named_member__, UNIT)]; \
+#define PADDED_MEMBERS_CACHELINE_MARKER(UNIT, CACHELINE, MEMBERS) \
+ union { \
+ OVS_CACHE_LINE_MARKER CACHELINE; \
+ struct { MEMBERS }; \
+ struct { MEMBERS } named_member_##CACHELINE; \
+ uint8_t PAD_ID[ROUND_UP(sizeof named_member_##CACHELINE, UNIT)]; \
}
#endif
static inline struct in6_addr
in6_addr_mapped_ipv4(ovs_be32 ip4)
{
- struct in6_addr ip6 = { .s6_addr = { [10] = 0xff, [11] = 0xff } };
+ struct in6_addr ip6;
+ memset(&ip6, 0, sizeof(ip6));
+ ip6.s6_addr[10] = 0xff, ip6.s6_addr[11] = 0xff;
memcpy(&ip6.s6_addr[12], &ip4, 4);
return ip6;
}
extern char *program_name;
#define __ARRAY_SIZE_NOCHECK(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0]))
-#ifdef __GNUC__
+#if __GNUC__ && !defined(__cplusplus)
/* return 0 for array types, 1 otherwise */
#define __ARRAY_CHECK(ARRAY) \
!__builtin_types_compatible_p(typeof(ARRAY), typeof(&ARRAY[0]))
#define __ARRAY_SIZE(ARRAY) \
__builtin_choose_expr(__ARRAY_CHECK(ARRAY), \
__ARRAY_SIZE_NOCHECK(ARRAY), __ARRAY_FAIL(ARRAY))
+#elif defined(__cplusplus)
+#define __ARRAY_SIZE(ARRAY) ( \
+ 0 * sizeof(reinterpret_cast<const ::Bad_arg_to_ARRAY_SIZE *>(ARRAY)) + \
+ 0 * sizeof(::Bad_arg_to_ARRAY_SIZE::check_type((ARRAY), &(ARRAY))) + \
+ sizeof(ARRAY) / sizeof((ARRAY)[0]) )
+
+struct Bad_arg_to_ARRAY_SIZE {
+ class Is_pointer;
+ class Is_array {};
+ template <typename T>
+ static Is_pointer check_type(const T *, const T * const *);
+ static Is_array check_type(const void *, const void *);
+};
#else
#define __ARRAY_SIZE(ARRAY) __ARRAY_SIZE_NOCHECK(ARRAY)
#endif