diff options
author | Max Reitz <mreitz@redhat.com> | 2019-10-11 17:27:59 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2019-10-28 11:51:07 +0100 |
commit | 5d5b33c08031cfe0e9872bde1f9dcb2215f9b30a (patch) | |
tree | 81d3c7251d852c110533f297e500a5b238547a7e /include/qemu | |
parent | f93c3add3a773e0e3f6277e5517583c4ad3a43c2 (diff) | |
download | qemu-5d5b33c08031cfe0e9872bde1f9dcb2215f9b30a.zip qemu-5d5b33c08031cfe0e9872bde1f9dcb2215f9b30a.tar.gz qemu-5d5b33c08031cfe0e9872bde1f9dcb2215f9b30a.tar.bz2 |
include: Move endof() up from hw/virtio/virtio.h
endof() is a useful macro, we can make use of it outside of virtio.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20191011152814.14791-2-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/compiler.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 7b93c73..85c02c1 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -60,6 +60,13 @@ #define sizeof_field(type, field) sizeof(((type *)0)->field) +/* + * Calculate the number of bytes up to and including the given 'field' of + * 'container'. + */ +#define endof(container, field) \ + (offsetof(container, field) + sizeof_field(container, field)) + /* Convert from a base type to a parent type, with compile time checking. */ #ifdef __GNUC__ #define DO_UPCAST(type, field, dev) ( __extension__ ( { \ |