Print this page
3373 gcc >= 4.5 concerns about offsetof()

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/stat/common/acquire_iodevs.c
          +++ new/usr/src/cmd/stat/common/acquire_iodevs.c
↓ open down ↓ 140 lines elided ↑ open up ↑
 141  141  
 142  142          return (NULL);
 143  143  }
 144  144  
 145  145  /*
 146  146   * Introduce an index into the list to speed up insert_into looking for the
 147  147   * right position in the list. This index is an AVL tree of all the
 148  148   * iodev_snapshot in the list.
 149  149   */
 150  150  
 151      -#define offsetof(s, m)  (size_t)(&(((s *)0)->m))        /* for avl_create */
      151 +#if defined(__GNUC__)
      152 +#define offsetof(s, m)  __builtin_offsetof(s, m)
      153 +#else
      154 +#define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))      /* for avl_create */
      155 +#endif
 152  156  
 153  157  static int
 154  158  avl_iodev_cmp(const void* is1, const void* is2)
 155  159  {
 156  160          int c = iodev_cmp((struct iodev_snapshot *)is1,
 157  161              (struct iodev_snapshot *)is2);
 158  162  
 159  163          if (c > 0)
 160  164                  return (1);
 161  165  
↓ open down ↓ 965 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX