]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macro.h: add sizeof_field() helper
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Sun, 17 May 2020 13:25:14 +0000 (15:25 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 4 Jun 2020 09:16:15 +0000 (11:16 +0200)
Similar to kernel FIELD_SIZE()

src/basic/macro.h

index b48d39909723737ac8c64e8b3283583d20166268..78e4262e41dcf5ffc8d78a7bb479d5de1206ba9f 100644 (file)
@@ -448,6 +448,8 @@ 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)
+
 /* 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 (hence works correctly on signed