History

avutil/mem_internal: define DECLARE_ALIGNED as C11's alignas

alignas is portable than compiler's specific __attribute__. It do have a limitation, that alignas don't support specify aligment on the declarations of struct (it works for specify alignment on struct fields), which only used by avcodec/cavs, and is removed now.

Zhao Zhili committed 2 years ago

Commit 57861911 parent fe2c9741 file · +8 −19Browse files

Unified · Split

libavutil/mem_internal.h+8−19
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include "config.h"
2525
2626 #include <stdint.h>
27+#include <stdalign.h>
2728
2829 #include "attributes.h"
2930 #include "macros.h"
@@ -73,26 +74,14 @@ · 43 unmodified lines
7374 * @param v Name of the variable
7475 */
7576
76−#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
77− #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v
78− #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
79− #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
80−#elif defined(__DJGPP__)
81− #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v
82− #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
83− #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
84−#elif defined(__GNUC__) || defined(__clang__)
85− #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v
86− #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v
87− #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
88−#elif defined(_MSC_VER)
89− #define DECLARE_ALIGNED_T(n,t,v) __declspec(align(n)) t v
90− #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v
91− #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
77+#if defined(__DJGPP__)
78+ #define DECLARE_ALIGNED_T(n,t,v) alignas(FFMIN(n, 16)) t v
79+ #define DECLARE_ASM_ALIGNED(n,t,v) alignas(FFMIN(n, 16)) t av_used v
80+ #define DECLARE_ASM_CONST(n,t,v) alignas(FFMIN(n, 16)) static const t av_used v
9281 #else
93− #define DECLARE_ALIGNED_T(n,t,v) t v
94− #define DECLARE_ASM_ALIGNED(n,t,v) t v
95− #define DECLARE_ASM_CONST(n,t,v) static const t v
82+ #define DECLARE_ALIGNED_T(n,t,v) alignas(n) t v
83+ #define DECLARE_ASM_ALIGNED(n,t,v) alignas(n) t av_used v
84+ #define DECLARE_ASM_CONST(n,t,v) alignas(n) static const t av_used v
9685 #endif
9786
9887 #if HAVE_SIMD_ALIGN_64

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t