From: Denys Vlasenko Date: Mon, 9 Mar 2015 14:52:17 +0000 (+0100) Subject: include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header X-Git-Tag: v3.2.100~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d5100425f88b1280bef8571bf1b4de90d25597d;p=thirdparty%2Fkernel%2Fstable.git include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header commit 3876488444e71238e287459c39d7692b6f718c3e upstream. Suggested by Andy. Suggested-by: Andy Lutomirski Signed-off-by: Denys Vlasenko Acked-by: Linus Torvalds Cc: Alexei Starovoitov Cc: Borislav Petkov Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Kees Cook Cc: Oleg Nesterov Cc: Steven Rostedt Cc: Will Drewry Link: http://lkml.kernel.org/r/1425912738-559-1-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar [bwh: Backported to 3.2: - There is no definition in vfio.h to move - Put the definition inside the #ifdef __KERNEL__ section] Signed-off-by: Ben Hutchings --- diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 6a40c76bdcf1a..ff9bbb6732cba 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -23,6 +23,16 @@ enum { #else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif + +/** + * offsetofend(TYPE, MEMBER) + * + * @TYPE: The type of the structure + * @MEMBER: The member within the structure to get the end offset of + */ +#define offsetofend(TYPE, MEMBER) \ + (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER)) + #endif /* __KERNEL__ */ #endif