From: Todd C. Miller Date: Thu, 10 May 2012 19:22:20 +0000 (-0400) Subject: Add offsetof macro for those without it. X-Git-Tag: SUDO_1_7_9p1~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd00c2d71ad26a1b93361a61600ee8ceb8a5927a;p=sudo Add offsetof macro for those without it. --HG-- branch : 1.7 --- diff --git a/missing.h b/missing.h index cc7075fdb..7ddbaad2d 100644 --- a/missing.h +++ b/missing.h @@ -148,6 +148,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. */