Skip to content

Commit

Permalink
include/stddef.h: Move offsetofend() from vfio.h to a generic kernel …
Browse files Browse the repository at this point in the history
…header

Suggested by Andy.

Suggested-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1425912738-559-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Denys Vlasenko authored and Ingo Molnar committed Mar 17, 2015
1 parent 5c39403 commit 3876488
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 9 additions & 0 deletions include/linux/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ enum {
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#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))
13 changes: 0 additions & 13 deletions include/linux/vfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
extern void vfio_unregister_iommu_driver(
const struct vfio_iommu_driver_ops *ops);

/**
* offsetofend(TYPE, MEMBER)
*
* @TYPE: The type of the structure
* @MEMBER: The member within the structure to get the end offset of
*
* Simple helper macro for dealing with variable sized structures passed
* from user space. This allows us to easily determine if the provided
* structure is sized to include various fields.
*/
#define offsetofend(TYPE, MEMBER) \
(offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))

/*
* External user API
*/
Expand Down

0 comments on commit 3876488

Please sign in to comment.