]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macro: add macro for determining size of struct with trailing union
authorLennart Poettering <lennart@poettering.net>
Fri, 10 Feb 2023 16:56:30 +0000 (17:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Feb 2023 09:09:30 +0000 (10:09 +0100)
src/basic/macro.h

index 25e42db0b6bfc413fa67cc11b0821992dd8434ba..ddf3032fbc767a976cd2056cc9608917f9d638b5 100644 (file)
@@ -248,6 +248,7 @@ static inline int __coverity_check_and_return__(int condition) {
 #define char_array_0(x) x[sizeof(x)-1] = 0;
 
 #define sizeof_field(struct_type, member) sizeof(((struct_type *) 0)->member)
+#define endoffsetof_field(struct_type, member) (offsetof(struct_type, member) + sizeof_field(struct_type, member))
 
 /* Returns the number of chars needed to format variables of the specified type as a decimal string. Adds in
  * extra space for a negative '-' prefix for signed types. Includes space for the trailing NUL. */