(v) = UPDATE_FLAG(v, flag, b)
#define FLAGS_SET(v, flags) \
((~(v) & (flags)) == 0)
+
+/* Declare a flexible array usable in a union.
+ * This is essentially a work-around for a pointless constraint in C99
+ * and might go away in some future version of the standard.
+ *
+ * See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3080ea5553cc909b000d1f1d964a9041962f2c5b
+ */
+#define DECLARE_FLEX_ARRAY(type, name) \
+ struct { \
+ dummy_t __empty__ ## name; \
+ type name[]; \
+ }
struct FieldObject__packed FieldObject__contents _packed_;
assert_cc(sizeof(struct FieldObject) == sizeof(struct FieldObject__packed));
-#define EntryObject__contents { \
- ObjectHeader object; \
- le64_t seqnum; \
- le64_t realtime; \
- le64_t monotonic; \
- sd_id128_t boot_id; \
- le64_t xor_hash; \
- union { \
- struct { \
- le64_t object_offset; \
- le64_t hash; \
- } regular[0]; \
- struct { \
- le32_t object_offset; \
- } compact[0]; \
- } items; \
+#define EntryObject__contents { \
+ ObjectHeader object; \
+ le64_t seqnum; \
+ le64_t realtime; \
+ le64_t monotonic; \
+ sd_id128_t boot_id; \
+ le64_t xor_hash; \
+ union { \
+ struct { \
+ dummy_t __empty__regular; \
+ struct { \
+ le64_t object_offset; \
+ le64_t hash; \
+ } regular[]; \
+ }; \
+ struct { \
+ dummy_t __empty_compact; \
+ struct { \
+ le32_t object_offset; \
+ } compact[]; \
+ }; \
+ } items; \
}
struct EntryObject EntryObject__contents;
ObjectHeader object;
le64_t next_entry_array_offset;
union {
- le64_t regular[0];
- le32_t compact[0];
+ DECLARE_FLEX_ARRAY(le64_t, regular);
+ DECLARE_FLEX_ARRAY(le32_t, compact);
} items;
} _packed_;