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

@@ -25,12 +25,10 @@
  */
 
 #ifndef _MISC_H
 #define _MISC_H
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <sys/types.h>
 #include <sys/time.h>
 #include <thread.h>
 #include <pthread.h>
 #include <stdarg.h>

@@ -48,11 +46,15 @@
  * various utility functions
  * These are globally implemented.
  */
 
 #undef  offsetof
+#if defined(__GNUC__)
+#define offsetof(s, m)  __builtin_offsetof(s, m)
+#else
 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
+#endif
 
 /*
  * a safe printf  -- do not use for error messages.
  */
 void debug_printf(const char *format, ...);