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
24#include "config.h"24#include "config.h"
25 25
26#include <stdint.h>26#include <stdint.h>
27#include <stdalign.h>
27 28
28#include "attributes.h"29#include "attributes.h"
29#include "macros.h"30#include "macros.h"
@@ -73,26 +74,14 @@ · 43 unmodified lines
73 * @param v Name of the variable74 * @param v Name of the variable
74 */75 */
75 76
76#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)77#if defined(__DJGPP__)
77 #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v78 #define DECLARE_ALIGNED_T(n,t,v) alignas(FFMIN(n, 16)) t v
78 #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v79 #define DECLARE_ASM_ALIGNED(n,t,v) alignas(FFMIN(n, 16)) t av_used v
79 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v80 #define DECLARE_ASM_CONST(n,t,v) alignas(FFMIN(n, 16)) static const t av_used 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
92#else81#else
93 #define DECLARE_ALIGNED_T(n,t,v) t v82 #define DECLARE_ALIGNED_T(n,t,v) alignas(n) t v
94 #define DECLARE_ASM_ALIGNED(n,t,v) t v83 #define DECLARE_ASM_ALIGNED(n,t,v) alignas(n) t av_used v
95 #define DECLARE_ASM_CONST(n,t,v) static const t v84 #define DECLARE_ASM_CONST(n,t,v) alignas(n) static const t av_used v
96#endif85#endif
97 86
98#if HAVE_SIMD_ALIGN_6487#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