From: Blue Swirl Date: Sat, 12 Sep 2009 09:58:46 +0000 (+0000) Subject: Fix a Sparse warning about redefinition of offsetof() X-Git-Tag: TizenStudio_2.0_p2.3~7500 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4085885616ac2613abac5c2316c488d5a12c3d0d;p=sdk%2Femulator%2Fqemu.git Fix a Sparse warning about redefinition of offsetof() Signed-off-by: Blue Swirl --- diff --git a/configure b/configure index 5232172..5570005 100755 --- a/configure +++ b/configure @@ -1602,6 +1602,18 @@ if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaries" != yes -a \ libs_softmmu="-lutil $libs_softmmu" fi +########################################## +# check if the compiler defines offsetof + +need_offsetof=yes +cat > $TMPC << EOF +#include +int main(void) { struct s { int f; }; return offsetof(struct s, f); } +EOF +if compile_prog "" "" ; then + need_offsetof=no +fi + # End of CC checks # After here, no more $cc or $ld runs @@ -1901,6 +1913,9 @@ fi if test "$fdt" = "yes" ; then echo "CONFIG_FDT=y" >> $config_host_mak fi +if test "$need_offsetof" = "yes" ; then + echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak +fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then diff --git a/osdep.h b/osdep.h index 32ee94b..4b4aad4 100644 --- a/osdep.h +++ b/osdep.h @@ -2,6 +2,7 @@ #define QEMU_OSDEP_H #include +#include #ifdef __OpenBSD__ #include #include @@ -27,7 +28,7 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif -#ifndef offsetof +#ifdef CONFIG_NEED_OFFSETOF #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) #endif #ifndef container_of