header: add offsetofend()
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Aug 2017 22:28:10 +0000 (00:28 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 6 Sep 2017 15:04:17 +0000 (17:04 +0200)
offsetofend() was moved from vfio.h to stddef.h in commit
3876488444e7123 ("include/stddef.h: Move offsetofend() from vfio.h to a
generic kernel header") for kernel 4.1. Add it again to stddef.h so it
is available in more include paths.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/linux/stddef.h [new file with mode: 0644]

diff --git a/backport/backport-include/linux/stddef.h b/backport/backport-include/linux/stddef.h
new file mode 100644 (file)
index 0000000..2c836b0
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __BACKPORT_LINUX_STDDEF_H
+#define __BACKPORT_LINUX_STDDEF_H
+#include_next <linux/stddef.h>
+
+#ifndef offsetofend
+/**
+ * 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
+
+#endif /* __BACKPORT_LINUX_STDDEF_H */