|
| 1 | +/* |
| 2 | + * This file is part of MPlayer. |
| 3 | + * |
| 4 | + * MPlayer is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * MPlayer is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with MPlayer; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | + */ |
| 18 | + |
| 19 | +#ifndef MPLAYER_MPMEM_H |
| 20 | +#define MPLAYER_MPMEM_H |
| 21 | + |
| 22 | +// copy of libavutil/mem_internal.h code for the |
| 23 | +// benefit of compiling against shared FFmpeg libs |
| 24 | + |
| 25 | +#include "config.h" |
| 26 | + |
| 27 | +#ifndef DECLARE_ALIGNED |
| 28 | +#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) |
| 29 | + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v |
| 30 | + #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v |
| 31 | + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v |
| 32 | +#elif defined(__DJGPP__) |
| 33 | + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v |
| 34 | + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v |
| 35 | + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v |
| 36 | +#elif defined(__GNUC__) || defined(__clang__) |
| 37 | + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v |
| 38 | + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v |
| 39 | + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v |
| 40 | +#elif defined(_MSC_VER) |
| 41 | + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v |
| 42 | + #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v |
| 43 | + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v |
| 44 | +#else |
| 45 | + #define DECLARE_ALIGNED(n,t,v) t v |
| 46 | + #define DECLARE_ASM_ALIGNED(n,t,v) t v |
| 47 | + #define DECLARE_ASM_CONST(n,t,v) static const t v |
| 48 | +#endif |
| 49 | +#endif |
| 50 | + |
| 51 | +// Some broken preprocessors need a second expansion |
| 52 | +// to be forced to tokenize __VA_ARGS__ |
| 53 | +#define E1(x) x |
| 54 | + |
| 55 | +#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \ |
| 56 | + uint8_t la_##v[sizeof(t s o) + (a)]; \ |
| 57 | + t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a) |
| 58 | + |
| 59 | +#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \ |
| 60 | + DECLARE_ALIGNED(a, t, la_##v) s o; \ |
| 61 | + t (*v) o = la_##v |
| 62 | + |
| 63 | +#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__) |
| 64 | + |
| 65 | +#if HAVE_LOCAL_ALIGNED |
| 66 | +# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,)) |
| 67 | +#else |
| 68 | +# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,)) |
| 69 | +#endif |
| 70 | + |
| 71 | +#if HAVE_LOCAL_ALIGNED |
| 72 | +# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)) |
| 73 | +#else |
| 74 | +# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,)) |
| 75 | +#endif |
| 76 | + |
| 77 | +#if HAVE_LOCAL_ALIGNED |
| 78 | +# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)) |
| 79 | +#else |
| 80 | +# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,)) |
| 81 | +#endif |
| 82 | + |
| 83 | +#if HAVE_LOCAL_ALIGNED |
| 84 | +# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,)) |
| 85 | +#else |
| 86 | +# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,)) |
| 87 | +#endif |
| 88 | + |
| 89 | +#endif /* MPLAYER_MPMEM_H */ |
0 commit comments