vp8: armv6: fix non-armv6t2 build
[libav.git] / libavutil / cpu.c
CommitLineData
c6c98d08 1/*
2912e87a 2 * This file is part of Libav.
c6c98d08 3 *
2912e87a 4 * Libav is free software; you can redistribute it and/or
c6c98d08
SS
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
2912e87a 9 * Libav is distributed in the hope that it will be useful,
c6c98d08
SS
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
2912e87a 15 * License along with Libav; if not, write to the Free Software
c6c98d08
SS
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "cpu.h"
20#include "config.h"
21
a9c5b6f6 22static int cpuflags_mask = -1, checked;
4d851f8d 23
c6c98d08
SS
24int av_get_cpu_flags(void)
25{
4d851f8d 26 static int flags;
a3f0d2b9
MR
27
28 if (checked)
29 return flags;
30
d526c533 31 if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
a3f0d2b9
MR
32 if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
33 if (ARCH_X86) flags = ff_get_cpu_flags_x86();
34
4d851f8d 35 flags &= cpuflags_mask;
a3f0d2b9 36 checked = 1;
4d851f8d 37
a3f0d2b9 38 return flags;
c6c98d08 39}
c6c98d08 40
4d851f8d
AK
41void av_set_cpu_flags_mask(int mask)
42{
43 cpuflags_mask = mask;
44 checked = 0;
45}
46
c6c98d08
SS
47#ifdef TEST
48
49#undef printf
ec5f5719 50#include <stdio.h>
c6c98d08 51
c31bc537
MR
52static const struct {
53 int flag;
54 const char *name;
55} cpu_flag_tab[] = {
d526c533
MR
56#if ARCH_ARM
57 { AV_CPU_FLAG_ARMV5TE, "armv5te" },
58 { AV_CPU_FLAG_ARMV6, "armv6" },
59 { AV_CPU_FLAG_ARMV6T2, "armv6t2" },
60 { AV_CPU_FLAG_VFP, "vfp" },
61 { AV_CPU_FLAG_VFPV3, "vfpv3" },
62 { AV_CPU_FLAG_NEON, "neon" },
63#elif ARCH_PPC
c31bc537
MR
64 { AV_CPU_FLAG_ALTIVEC, "altivec" },
65#elif ARCH_X86
66 { AV_CPU_FLAG_MMX, "mmx" },
67 { AV_CPU_FLAG_MMX2, "mmx2" },
68 { AV_CPU_FLAG_SSE, "sse" },
69 { AV_CPU_FLAG_SSE2, "sse2" },
70 { AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" },
71 { AV_CPU_FLAG_SSE3, "sse3" },
72 { AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" },
73 { AV_CPU_FLAG_SSSE3, "ssse3" },
74 { AV_CPU_FLAG_ATOM, "atom" },
75 { AV_CPU_FLAG_SSE4, "sse4.1" },
76 { AV_CPU_FLAG_SSE42, "sse4.2" },
77 { AV_CPU_FLAG_AVX, "avx" },
96a59cf3
JGG
78 { AV_CPU_FLAG_XOP, "xop" },
79 { AV_CPU_FLAG_FMA4, "fma4" },
c31bc537
MR
80 { AV_CPU_FLAG_3DNOW, "3dnow" },
81 { AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
82#endif
83 { 0 }
84};
85
c6c98d08
SS
86int main(void)
87{
88 int cpu_flags = av_get_cpu_flags();
c31bc537 89 int i;
c6c98d08
SS
90
91 printf("cpu_flags = 0x%08X\n", cpu_flags);
c31bc537
MR
92 printf("cpu_flags =");
93 for (i = 0; cpu_flag_tab[i].flag; i++)
94 if (cpu_flags & cpu_flag_tab[i].flag)
95 printf(" %s", cpu_flag_tab[i].name);
96 printf("\n");
97
c6c98d08
SS
98 return 0;
99}
100
101#endif