Ticket #207: cdefs.h.diff

File cdefs.h.diff, 1.1 KB (added by psmedley, 16 years ago)

cdefs.h diff

  • \include\sys\cdefs.h

    old new  
    251251 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
    252252 * require it.
    253253 */
    254 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
    255 #define __rangeof(type, start, end) \
    256         (__offsetof(type, end) - __offsetof(type, start))
     254#if __GNUC_PREREQ__(4, 1)
     255#define __offsetof(type, field)  __builtin_offsetof(type, field)
     256#else
     257#ifndef __cplusplus
     258#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
     259#else
     260#define __offsetof(type, field)                                 \
     261  (__offsetof__ (reinterpret_cast <size_t>                      \
     262                 (&reinterpret_cast <const volatile char &>     \
     263                  (static_cast<type *> (0)->field))))
     264#endif
     265#endif
     266#define __rangeof(type, start, end) \
     267         (__offsetof(type, end) - __offsetof(type, start))
     268
    257269
    258270/*
    259271 * Compiler-dependent macros to declare that functions take printf-like