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.
Unified · Split
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "config.h" |
| 25 | 25 | |
| 26 | 26 | #include <stdint.h> |
| 27 | +#include <stdalign.h> | |
| 27 | 28 | |
| 28 | 29 | #include "attributes.h" |
| 29 | 30 | #include "macros.h" |
| @@ -73,26 +74,14 @@ · 43 unmodified lines | ||
| 73 | 74 | * @param v Name of the variable |
| 74 | 75 | */ |
| 75 | 76 | |
| 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 | |
| 92 | 81 | #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 | |
| 96 | 85 | #endif |
| 97 | 86 | |
| 98 | 87 | #if HAVE_SIMD_ALIGN_64 |