Print this page
3373 gcc >= 4.5 concerns about offsetof()
Portions contributed by: Igor Pashev <pashev.igor@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/sysmacros.h
          +++ new/usr/src/uts/common/sys/sysmacros.h
↓ open down ↓ 362 lines elided ↑ open up ↑
 363  363  #define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h)  \
 364  364          uint8_t _h, _g, _f, _e, _d, _c, _b, _a
 365  365  #else
 366  366  #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
 367  367  #endif  /* _BIT_FIELDS_LTOH */
 368  368  
 369  369  /* avoid any possibility of clashing with <stddef.h> version */
 370  370  #if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_KMEMUSER)
 371  371  
 372  372  #if !defined(offsetof)
      373 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
      374 +#define offsetof(s, m) __builtin_offsetof(s, m)
      375 +#else
 373  376  #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
      377 +#endif
 374  378  #endif /* !offsetof */
 375  379  
 376  380  #define container_of(m, s, name)                        \
 377  381          (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
 378  382  
 379  383  #define ARRAY_SIZE(x)   (sizeof (x) / sizeof (x[0]))
 380  384  #endif /* _KERNEL, !_KMEMUSER */
 381  385  
 382  386  #ifdef  __cplusplus
 383  387  }
 384  388  #endif
 385  389  
 386  390  #endif  /* _SYS_SYSMACROS_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX