summaryrefslogtreecommitdiff
path: root/libavutil/internal.h
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2014-04-23 12:19:59 +0200
committerJanne Grunau <janne-libav@jannau.net>2014-04-24 18:28:26 +0200
commita88e1d1c598e641eecd5d43730211d91c82787c6 (patch)
tree97659e4d9e5679c7c8cc2703bec2cc6b08e9765e /libavutil/internal.h
parent152b797cd687e96a582a1cb908dddf3d330d7637 (diff)
downloadffmpeg-a88e1d1c598e641eecd5d43730211d91c82787c6.tar.gz
lavu: add CHK_OFFS as AV_CHECK_OFFSET to check struct member offsets
Diffstat (limited to 'libavutil/internal.h')
-rw-r--r--libavutil/internal.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavutil/internal.h b/libavutil/internal.h
index ecd535b808..210c52437e 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -84,6 +84,13 @@
// to be forced to tokenize __VA_ARGS__
#define E1(x) x
+/* Check if the hard coded offset of a struct member still matches reality.
+ * Induce a compilation failure if not.
+ */
+#define AV_CHECK_OFFSET(s, m, o) struct check_##o { \
+ int x_##o[offsetof(s, m) == o? 1: -1]; \
+ }
+
#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
uint8_t la_##v[sizeof(t s o) + (a)]; \
t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)