From: Lennart Poettering Date: Mon, 24 Jun 2024 13:52:00 +0000 (+0200) Subject: macro: move sizeof_field() macro into src/fundamental/ X-Git-Tag: v257-rc1~1041^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72b1809bbc5c2b5e37765ca58be68b745985597c;p=thirdparty%2Fsystemd.git macro: move sizeof_field() macro into src/fundamental/ Let's make this macro available for our EFI code too. --- diff --git a/src/basic/macro.h b/src/basic/macro.h index 19d5039fd3b..72910d9c383 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -218,9 +218,6 @@ 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)) - /* Maximum buffer size needed for formatting an unsigned integer type as hex, including space for '0x' * prefix and trailing NUL suffix. */ #define HEXADECIMAL_STR_MAX(type) (2 + sizeof(type) * 2 + 1) diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index bbfdcdb2187..2595f5501cc 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -546,3 +546,6 @@ static inline uint64_t ALIGN_OFFSET_U64(uint64_t l, uint64_t ali) { #else #define DECLARE_SBAT(text) #endif + +#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))