opt-test: Add missing braces to silence compiler warnings.
[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
c6c98d08
SS
22int av_get_cpu_flags(void)
23{
a3f0d2b9
MR
24 static int flags, checked;
25
26 if (checked)
27 return flags;
28
29 if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
30 if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
31 if (ARCH_X86) flags = ff_get_cpu_flags_x86();
32
33 checked = 1;
34 return flags;
c6c98d08 35}
c6c98d08
SS
36
37#ifdef TEST
38
39#undef printf
ec5f5719 40#include <stdio.h>
c6c98d08
SS
41
42int main(void)
43{
44 int cpu_flags = av_get_cpu_flags();
45
46 printf("cpu_flags = 0x%08X\n", cpu_flags);
87f1355f 47 printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
c6c98d08
SS
48#if ARCH_ARM
49 cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "",
50#elif ARCH_PPC
51 cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "",
52#elif ARCH_X86
53 cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "",
54 cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "",
55 cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "",
56 cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "",
57 cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
58 cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "",
59 cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
60 cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "",
eba586b0 61 cpu_flags & AV_CPU_FLAG_ATOM ? "Atom " : "",
c6c98d08
SS
62 cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "",
63 cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "",
87f1355f 64 cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "",
c6c98d08
SS
65 cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "",
66 cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : "");
67#endif
68 return 0;
69}
70
71#endif