diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-27 14:54:38 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-01-01 14:14:57 +0100 |
commit | e15371061d23457554d241a80dc471515ac13ad4 (patch) | |
tree | 02400adf5d8667fed6f416c954ea41c055f8ef5c /libavutil | |
parent | c8c2dfbc378e54aee7e8181ff532483096dc4bc7 (diff) | |
download | ffmpeg-e15371061d23457554d241a80dc471515ac13ad4.tar.gz |
lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/aes_internal.h | 2 | ||||
-rw-r--r-- | libavutil/internal.h | 1 | ||||
-rw-r--r-- | libavutil/lls.h | 2 | ||||
-rw-r--r-- | libavutil/mem.h | 6 | ||||
-rw-r--r-- | libavutil/mem_internal.h | 70 | ||||
-rw-r--r-- | libavutil/tests/aes_ctr.c | 1 | ||||
-rw-r--r-- | libavutil/tests/des.c | 1 | ||||
-rw-r--r-- | libavutil/tx_priv.h | 1 | ||||
-rw-r--r-- | libavutil/version.h | 3 |
9 files changed, 84 insertions, 3 deletions
diff --git a/libavutil/aes_internal.h b/libavutil/aes_internal.h index 494425878d..beee626831 100644 --- a/libavutil/aes_internal.h +++ b/libavutil/aes_internal.h @@ -21,7 +21,7 @@ #ifndef AVUTIL_AES_INTERNAL_H #define AVUTIL_AES_INTERNAL_H -#include "mem.h" +#include "mem_internal.h" #include <stdint.h> typedef union { diff --git a/libavutil/internal.h b/libavutil/internal.h index 80c5d06326..93ea57c324 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -43,7 +43,6 @@ #include "cpu.h" #include "dict.h" #include "macros.h" -#include "mem.h" #include "pixfmt.h" #include "version.h" diff --git a/libavutil/lls.h b/libavutil/lls.h index 1a276d537d..5f849206f7 100644 --- a/libavutil/lls.h +++ b/libavutil/lls.h @@ -24,7 +24,7 @@ #define AVUTIL_LLS_H #include "macros.h" -#include "mem.h" +#include "mem_internal.h" #include "version.h" #define MAX_VARS 32 diff --git a/libavutil/mem.h b/libavutil/mem.h index 5fb1a02dd9..e21a1feaae 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -33,6 +33,7 @@ #include "attributes.h" #include "error.h" #include "avutil.h" +#include "version.h" /** * @addtogroup lavu_mem @@ -49,6 +50,10 @@ * dealing with memory consistently possible on all platforms. * * @{ + */ + +#if FF_API_DECLARE_ALIGNED +/** * * @defgroup lavu_mem_macros Alignment Macros * Helper macros for declaring aligned variables. @@ -125,6 +130,7 @@ /** * @} */ +#endif /** * @defgroup lavu_mem_attrs Function Attributes diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h index 14f45c657f..ee2575c85f 100644 --- a/libavutil/mem_internal.h +++ b/libavutil/mem_internal.h @@ -27,6 +27,76 @@ #include "avassert.h" #include "mem.h" +#include "version.h" + +#if !FF_API_DECLARE_ALIGNED +/** + * @def DECLARE_ALIGNED(n,t,v) + * Declare a variable that is aligned in memory. + * + * @code{.c} + * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42; + * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128]; + * + * // The default-alignment equivalent would be + * uint16_t aligned_int = 42; + * uint8_t aligned_array[128]; + * @endcode + * + * @param n Minimum alignment in bytes + * @param t Type of the variable (or array element) + * @param v Name of the variable + */ + +/** + * @def DECLARE_ASM_ALIGNED(n,t,v) + * Declare an aligned variable appropriate for use in inline assembly code. + * + * @code{.c} + * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); + * @endcode + * + * @param n Minimum alignment in bytes + * @param t Type of the variable (or array element) + * @param v Name of the variable + */ + +/** + * @def DECLARE_ASM_CONST(n,t,v) + * Declare a static constant aligned variable appropriate for use in inline + * assembly code. + * + * @code{.c} + * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); + * @endcode + * + * @param n Minimum alignment in bytes + * @param t Type of the variable (or array element) + * @param v Name of the variable + */ + +#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v +#elif defined(__DJGPP__) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v +#elif defined(__GNUC__) || defined(__clang__) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v +#elif defined(_MSC_VER) + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v +#else + #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v +#endif +#endif // Some broken preprocessors need a second expansion // to be forced to tokenize __VA_ARGS__ diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c index 00fdb05d13..53d0e4a244 100644 --- a/libavutil/tests/aes_ctr.c +++ b/libavutil/tests/aes_ctr.c @@ -18,6 +18,7 @@ #include "libavutil/log.h" #include "libavutil/mem.h" +#include "libavutil/mem_internal.h" #include "libavutil/aes_ctr.h" static const DECLARE_ALIGNED(8, uint8_t, plain)[] = { diff --git a/libavutil/tests/des.c b/libavutil/tests/des.c index f2a5c34f1a..8fa88df684 100644 --- a/libavutil/tests/des.c +++ b/libavutil/tests/des.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mem_internal.h" #include "libavutil/timer.h" #include "libavutil/des.c" diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index e0d980abfb..a3738f68bd 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -23,6 +23,7 @@ #include <stddef.h> #include "thread.h" #include "mem.h" +#include "mem_internal.h" #include "avassert.h" #include "attributes.h" diff --git a/libavutil/version.h b/libavutil/version.h index 9b311b5b27..085c4e30f9 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -135,6 +135,9 @@ #ifndef FF_API_D2STR #define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58) #endif +#ifndef FF_API_DECLARE_ALIGNED +#define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58) +#endif /** * @} |