Procházet zdrojové kódy

[build] Use __builtin_offsetof() when available

Some newer versions of gcc (observed with a patched gcc 4.5.1) seem to
treat our offsetof() implementation as not being a compile-time
constant.  Fix by using __builtin_offsetof() when available.  (As with
the original offsetof() macro, this code is copied from the Linux
kernel's stddef.h.)

Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown před 14 roky
rodič
revize
795793b3a4
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 4
    0
      src/include/stddef.h

+ 4
- 0
src/include/stddef.h Zobrazit soubor

@@ -10,7 +10,11 @@ FILE_LICENCE ( GPL2_ONLY );
10 10
 #define NULL ((void *)0)
11 11
 
12 12
 #undef offsetof
13
+#ifdef __compiler_offsetof
14
+#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
15
+#else
13 16
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
17
+#endif
14 18
 
15 19
 #undef container_of
16 20
 #define container_of(ptr, type, member) ({                      \

Načítá se…
Zrušit
Uložit