diff mbox series

[FFmpeg-devel,1/7] lavu: add macros to help making future-proof structures.

Message ID 20210421122706.9002-2-george@nsup.org
State New
Headers show
Series [FFmpeg-devel,1/7] lavu: add macros to help making future-proof structures.
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Nicolas George April 21, 2021, 12:27 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 libavutil/extendable.h | 59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 libavutil/extendable.h
diff mbox series

Patch

diff --git a/libavutil/extendable.h b/libavutil/extendable.h
new file mode 100644
index 0000000000..79980fa202
--- /dev/null
+++ b/libavutil/extendable.h
@@ -0,0 +1,59 @@ 
+/*
+ * Copyright (c) 2021 The FFmpeg project
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_EXTENDABLE_H
+#define AVUTIL_EXTENDABLE_H
+
+/**
+ * @defgroup ff_extendable FFExtendable
+ *
+ * Types and macros to help designing structures that can be allocated by
+ * the application, including on the stack, but will not break ABI when
+ * extendded.
+ *
+ * This should not be used outside FFmpeg.
+ *
+ * @{
+ */
+
+/**
+ * Define a value of type as a compound literal (hidden local variable)
+ * with the field self_size filled.
+ */
+#define FF_NEW_SZ(type) ((type){ .self_size = sizeof(type) })
+
+/**
+ * Type suitable for paddign at the end of a structure, with maximum
+ * alignment.
+ */
+typedef union FFReservedPadding {
+    union {
+        double d;
+        void *p;
+        void (*f)(void);
+        intmax_t i;
+    } dummy;
+} FFReservedPadding;
+
+/**
+ * @}
+ */
+
+#endif /* AVUTIL_EXTENDABLE_H */