]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: rework OFFSETOF() based on __builtin_offsetof()
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 15:10:42 +0000 (17:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 17:01:54 +0000 (19:01 +0200)
Since both LLVM and gcc supported this for a long time, we are not
adding a fallback compat kludge. And even if there's some relevant
compiler that doesn't know this concept, it'll fail with a compiler
error, and we'll fix it then.

As suggested by @keszybz:

https://github.com/systemd/systemd/pull/10174#discussion_r226266540

src/boot/efi/util.h

index 40ede66d4a90264cb5ba4c9ccf6763bd17fbb957..daa386b7696a45bcd98675daa586ff976f9d3399 100644 (file)
@@ -5,7 +5,7 @@
 #include <efilib.h>
 
 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
-#define OFFSETOF(x,y) ((UINTN) &(((x*)0)->y))
+#define OFFSETOF(x,y) __builtin_offsetof(x,y)
 
 static inline const CHAR16 *yes_no(BOOLEAN b) {
         return b ? L"yes" : L"no";