Revision 82246040

b/configure
2524 2524
fi
2525 2525

  
2526 2526
##########################################
2527
# check if the compiler defines offsetof
2528

  
2529
need_offsetof=yes
2530
cat > $TMPC << EOF
2531
#include <stddef.h>
2532
int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2533
EOF
2534
if compile_prog "" "" ; then
2535
    need_offsetof=no
2536
fi
2537

  
2538 2527
# spice probe
2539 2528
if test "$spice" != "no" ; then
2540 2529
  cat > $TMPC << EOF
......
3199 3188
if test "$tcg_interpreter" = "yes" ; then
3200 3189
  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3201 3190
fi
3202
if test "$need_offsetof" = "yes" ; then
3203
  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
3204
fi
3205 3191
if test "$fdatasync" = "yes" ; then
3206 3192
  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
3207 3193
fi
b/osdep.h
26 26
#define unlikely(x)   __builtin_expect(!!(x), 0)
27 27
#endif
28 28

  
29
#ifdef CONFIG_NEED_OFFSETOF
30
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
31
#endif
32 29
#ifndef container_of
33 30
#define container_of(ptr, type, member) ({                      \
34 31
        const typeof(((type *) 0)->member) *__mptr = (ptr);     \

Also available in: Unified diff