Fix a Sparse warning about redefinition of offsetof()
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
72cf2d4f0e
commit
de5071c551
15
configure
vendored
15
configure
vendored
@ -1602,6 +1602,18 @@ if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaries" != yes -a \
|
|||||||
libs_softmmu="-lutil $libs_softmmu"
|
libs_softmmu="-lutil $libs_softmmu"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# check if the compiler defines offsetof
|
||||||
|
|
||||||
|
need_offsetof=yes
|
||||||
|
cat > $TMPC << EOF
|
||||||
|
#include <stddef.h>
|
||||||
|
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
|
# End of CC checks
|
||||||
# After here, no more $cc or $ld runs
|
# After here, no more $cc or $ld runs
|
||||||
|
|
||||||
@ -1901,6 +1913,9 @@ fi
|
|||||||
if test "$fdt" = "yes" ; then
|
if test "$fdt" = "yes" ; then
|
||||||
echo "CONFIG_FDT=y" >> $config_host_mak
|
echo "CONFIG_FDT=y" >> $config_host_mak
|
||||||
fi
|
fi
|
||||||
|
if test "$need_offsetof" = "yes" ; then
|
||||||
|
echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
|
||||||
|
fi
|
||||||
|
|
||||||
# XXX: suppress that
|
# XXX: suppress that
|
||||||
if [ "$bsd" = "yes" ] ; then
|
if [ "$bsd" = "yes" ] ; then
|
||||||
|
3
osdep.h
3
osdep.h
@ -2,6 +2,7 @@
|
|||||||
#define QEMU_OSDEP_H
|
#define QEMU_OSDEP_H
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
@ -27,7 +28,7 @@
|
|||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef offsetof
|
#ifdef CONFIG_NEED_OFFSETOF
|
||||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
|
||||||
#endif
|
#endif
|
||||||
#ifndef container_of
|
#ifndef container_of
|
||||||
|
Loading…
Reference in New Issue
Block a user