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


 509                 break;
 510         case RDC_POOL_WAIT:
 511                 args->arg0 = (uint32_t)args32.arg0; /* int */
 512                 break;
 513         case RDC_POOL_RUN:
 514                 args->arg0 = (uint32_t)args32.arg0; /* int */
 515                 break;
 516 
 517         default:
 518                 return (EINVAL);
 519         }
 520 
 521         return (0);
 522 }
 523 
 524 
 525 /*
 526  * Yet another standard thing that is not standard ...
 527  */
 528 #ifndef offsetof
 529 #define offsetof(s, m)  ((size_t)(&((s *)0)->m))




 530 #endif
 531 
 532 /*
 533  * Build a 32bit rdc_set structure and copyout to the user level.
 534  */
 535 int
 536 rdc_status_copy32(const void *arg, void *usetp, size_t size, int mode)
 537 {
 538         rdc_u_info_t *urdc = (rdc_u_info_t *)arg;
 539         struct rdc_set32 set32;
 540         size_t tailsize;
 541 #ifdef DEBUG
 542         size_t tailsize32;
 543 #endif
 544 
 545         bzero(&set32, sizeof (set32));
 546 
 547         tailsize = sizeof (struct rdc_addr32) -
 548             offsetof(struct rdc_addr32, intf);
 549 




 509                 break;
 510         case RDC_POOL_WAIT:
 511                 args->arg0 = (uint32_t)args32.arg0; /* int */
 512                 break;
 513         case RDC_POOL_RUN:
 514                 args->arg0 = (uint32_t)args32.arg0; /* int */
 515                 break;
 516 
 517         default:
 518                 return (EINVAL);
 519         }
 520 
 521         return (0);
 522 }
 523 
 524 
 525 /*
 526  * Yet another standard thing that is not standard ...
 527  */
 528 #ifndef offsetof
 529 #if defined(__GNUC__)
 530 #define offsetof(s, m)  __builtin_offsetof(s, m)
 531 #else
 532 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
 533 #endif
 534 #endif
 535 
 536 /*
 537  * Build a 32bit rdc_set structure and copyout to the user level.
 538  */
 539 int
 540 rdc_status_copy32(const void *arg, void *usetp, size_t size, int mode)
 541 {
 542         rdc_u_info_t *urdc = (rdc_u_info_t *)arg;
 543         struct rdc_set32 set32;
 544         size_t tailsize;
 545 #ifdef DEBUG
 546         size_t tailsize32;
 547 #endif
 548 
 549         bzero(&set32, sizeof (set32));
 550 
 551         tailsize = sizeof (struct rdc_addr32) -
 552             offsetof(struct rdc_addr32, intf);
 553