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


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 #include <meta.h>
  29 #include <assert.h>
  30 #include <ctype.h>
  31 #include <mdiox.h>
  32 #include <meta.h>
  33 #include <stdio.h>
  34 #include <stdlib.h>
  35 #include <strings.h>
  36 #include <sys/lvm/md_mddb.h>
  37 #include <sys/lvm/md_names.h>
  38 #include <sys/lvm/md_crc.h>
  39 #include <sys/lvm/md_convert.h>
  40 
  41 
  42 /*
  43  * Design Notes:
  44  *
  45  * All of the code in this file supports the addition of metastat -c output
  46  * for the verbose option of metaimport.  Some of this code is also used by
  47  * the command metastat for concise output(cmd/lvm/util/metastat.c).


 144         /* pointer to the unit structure for the metadevice, e.g. rb_data[0] */
 145         void                    *record;
 146 } md_im_rec_t;
 147 
 148 /*
 149  * md_im_list is used to group toplevel metadevices by type and to group
 150  * the underlying devices for a particular metadevice.
 151  */
 152 typedef struct md_im_list {
 153         struct md_im_list       *next;
 154         struct md_im_rec        *mdrec;
 155 } md_im_list_t;
 156 
 157 
 158 /*
 159  * MAXSIZEMDRECNAME is the value that has historically been used to allocate
 160  * space for the metadevice name
 161  */
 162 #define MAXSIZEMDRECNAME        20
 163 #define NAMEWIDTH               16



 164 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))

 165 #define NOT_PHYSICAL_DEV        0
 166 #define PHYSICAL_DEV            1
 167 
 168 
 169 /*
 170  * strip_blacks()
 171  *
 172  * Strip blanks from string.  Used for size field in concise output.
 173  */
 174 static char *
 175 strip_blanks(char *s)
 176 {
 177         char *p;
 178 
 179         for (p = s; *p; ) {
 180                 if (*p == ' ') {
 181                         char *t;
 182                         for (t = p; *t; t++) {
 183                                 *t = *(t + 1);
 184                         }




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 


  26 #include <meta.h>
  27 #include <assert.h>
  28 #include <ctype.h>
  29 #include <mdiox.h>
  30 #include <meta.h>
  31 #include <stdio.h>
  32 #include <stdlib.h>
  33 #include <strings.h>
  34 #include <sys/lvm/md_mddb.h>
  35 #include <sys/lvm/md_names.h>
  36 #include <sys/lvm/md_crc.h>
  37 #include <sys/lvm/md_convert.h>
  38 
  39 
  40 /*
  41  * Design Notes:
  42  *
  43  * All of the code in this file supports the addition of metastat -c output
  44  * for the verbose option of metaimport.  Some of this code is also used by
  45  * the command metastat for concise output(cmd/lvm/util/metastat.c).


 142         /* pointer to the unit structure for the metadevice, e.g. rb_data[0] */
 143         void                    *record;
 144 } md_im_rec_t;
 145 
 146 /*
 147  * md_im_list is used to group toplevel metadevices by type and to group
 148  * the underlying devices for a particular metadevice.
 149  */
 150 typedef struct md_im_list {
 151         struct md_im_list       *next;
 152         struct md_im_rec        *mdrec;
 153 } md_im_list_t;
 154 
 155 
 156 /*
 157  * MAXSIZEMDRECNAME is the value that has historically been used to allocate
 158  * space for the metadevice name
 159  */
 160 #define MAXSIZEMDRECNAME        20
 161 #define NAMEWIDTH               16
 162 #if defined(__GNUC__)
 163 #define offsetof(s, m)  __builtin_offsetof(s, m)
 164 #else
 165 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
 166 #endif
 167 #define NOT_PHYSICAL_DEV        0
 168 #define PHYSICAL_DEV            1
 169 
 170 
 171 /*
 172  * strip_blacks()
 173  *
 174  * Strip blanks from string.  Used for size field in concise output.
 175  */
 176 static char *
 177 strip_blanks(char *s)
 178 {
 179         char *p;
 180 
 181         for (p = s; *p; ) {
 182                 if (*p == ' ') {
 183                         char *t;
 184                         for (t = p; *t; t++) {
 185                                 *t = *(t + 1);
 186                         }