From: Todd C. Miller Date: Thu, 10 May 2012 14:01:26 +0000 (-0400) Subject: Add offsetof macro for those without it. X-Git-Tag: SUDO_1_8_5~1^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e0ffceacb29516da52064898cc8b1b09f6bf7ae;p=sudo Add offsetof macro for those without it. --- diff --git a/include/missing.h b/include/missing.h index 658f399da..6f00a5760 100644 --- a/include/missing.h +++ b/include/missing.h @@ -122,6 +122,17 @@ # 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. */