]> granicus.if.org Git - sudo/commitdiff
Add offsetof macro for those without it.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 May 2012 14:01:26 +0000 (10:01 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 May 2012 14:01:26 +0000 (10:01 -0400)
include/missing.h

index 658f399da04f40941203d45c3070d9e3ac656be9..6f00a5760624b93c9d143f0b9988638e2e8be2eb 100644 (file)
 # define MAX(a,b) (((a)>(b))?(a):(b))
 #endif
 
+/*
+ * Older systems may be missing stddef.h and/or offsetof macro
+ */
+#ifndef offsetof
+# ifdef __offsetof
+#  define offsetof(type, field) __offsetof(type, field)
+# else
+#  define offsetof(type, field) ((size_t)(&((type *)0)->field))
+# endif
+#endif
+
 /*
  * Simple isblank() macro and function for systems without it.
  */