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


  40 #include <sys/sdt.h>
  41 #include <sys/cred.h>
  42 #include <sys/list.h>
  43 #include <sys/vscan.h>
  44 
  45 #define VS_REQ_MAGIC            0x52515354 /* 'RQST' */
  46 
  47 #define VS_REQS_DEFAULT         20000   /* pending scan requests - reql */
  48 #define VS_NODES_DEFAULT        128     /* concurrent file scans */
  49 #define VS_WORKERS_DEFAULT      32      /* worker threads */
  50 #define VS_SCANWAIT_DEFAULT     15*60   /* seconds to wait for scan result */
  51 #define VS_REQL_HANDLER_TIMEOUT 30
  52 #define VS_EXT_RECURSE_DEPTH    8
  53 
  54 /* access derived from scan result (VS_STATUS_XXX) and file attributes */
  55 #define VS_ACCESS_UNDEFINED     0
  56 #define VS_ACCESS_ALLOW         1       /* return 0 */
  57 #define VS_ACCESS_DENY          2       /* return EACCES */
  58 
  59 #define tolower(C)      (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
  60 #define offsetof(s, m)  (size_t)(&(((s *)0)->m))




  61 
  62 /* global variables - tunable via /etc/system */
  63 uint32_t vs_reqs_max = VS_REQS_DEFAULT; /* max scan requests */
  64 uint32_t vs_nodes_max = VS_NODES_DEFAULT; /* max in-progress scan requests */
  65 uint32_t vs_workers = VS_WORKERS_DEFAULT; /* max workers send reqs to vscand */
  66 uint32_t vs_scan_wait = VS_SCANWAIT_DEFAULT; /* secs to wait for scan result */
  67 
  68 
  69 /*
  70  * vscan_svc_state
  71  *
  72  *   +-----------------+
  73  *   | VS_SVC_UNCONFIG |
  74  *   +-----------------+
  75  *      |           ^
  76  *      | svc_init  | svc_fini
  77  *      v           |
  78  *   +-----------------+
  79  *   | VS_SVC_IDLE     |<----|
  80  *   +-----------------+         |




  40 #include <sys/sdt.h>
  41 #include <sys/cred.h>
  42 #include <sys/list.h>
  43 #include <sys/vscan.h>
  44 
  45 #define VS_REQ_MAGIC            0x52515354 /* 'RQST' */
  46 
  47 #define VS_REQS_DEFAULT         20000   /* pending scan requests - reql */
  48 #define VS_NODES_DEFAULT        128     /* concurrent file scans */
  49 #define VS_WORKERS_DEFAULT      32      /* worker threads */
  50 #define VS_SCANWAIT_DEFAULT     15*60   /* seconds to wait for scan result */
  51 #define VS_REQL_HANDLER_TIMEOUT 30
  52 #define VS_EXT_RECURSE_DEPTH    8
  53 
  54 /* access derived from scan result (VS_STATUS_XXX) and file attributes */
  55 #define VS_ACCESS_UNDEFINED     0
  56 #define VS_ACCESS_ALLOW         1       /* return 0 */
  57 #define VS_ACCESS_DENY          2       /* return EACCES */
  58 
  59 #define tolower(C)      (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
  60 #if defined(__GNUC__)
  61 #define offsetof(s, m)  __builtin_offsetof(s, m)
  62 #else
  63 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
  64 #endif
  65 
  66 /* global variables - tunable via /etc/system */
  67 uint32_t vs_reqs_max = VS_REQS_DEFAULT; /* max scan requests */
  68 uint32_t vs_nodes_max = VS_NODES_DEFAULT; /* max in-progress scan requests */
  69 uint32_t vs_workers = VS_WORKERS_DEFAULT; /* max workers send reqs to vscand */
  70 uint32_t vs_scan_wait = VS_SCANWAIT_DEFAULT; /* secs to wait for scan result */
  71 
  72 
  73 /*
  74  * vscan_svc_state
  75  *
  76  *   +-----------------+
  77  *   | VS_SVC_UNCONFIG |
  78  *   +-----------------+
  79  *      |           ^
  80  *      | svc_init  | svc_fini
  81  *      v           |
  82  *   +-----------------+
  83  *   | VS_SVC_IDLE     |<----|
  84  *   +-----------------+         |