vdr: fix unused variable warning
[vlc.git] / include / vlc_cpu.h
blobb2f0f4564ea8176997c119a8005733f6636a1f4a
1 /*****************************************************************************
2 * vlc_cpu.h: CPU capabilities
3 *****************************************************************************
4 * Copyright (C) 1998-2009 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 /**
22 * \file
23 * This file provides CPU features detection.
26 #ifndef VLC_CPU_H
27 # define VLC_CPU_H 1
29 VLC_API unsigned vlc_CPU(void);
31 # if defined (__i386__) || defined (__x86_64__)
32 # define HAVE_FPU 1
33 # define VLC_CPU_MMX 0x00000008
34 # define VLC_CPU_3dNOW 0x00000010
35 # define VLC_CPU_MMXEXT 0x00000020
36 # define VLC_CPU_SSE 0x00000040
37 # define VLC_CPU_SSE2 0x00000080
38 # define VLC_CPU_SSE3 0x00000100
39 # define VLC_CPU_SSSE3 0x00000200
40 # define VLC_CPU_SSE4_1 0x00000400
41 # define VLC_CPU_SSE4_2 0x00000800
42 # define VLC_CPU_SSE4A 0x00001000
43 # define VLC_CPU_AVX 0x00002000
44 # define VLC_CPU_AVX2 0x00004000
45 # define VLC_CPU_XOP 0x00008000
46 # define VLC_CPU_FMA4 0x00010000
48 # if defined (__MMX__)
49 # define vlc_CPU_MMX() (1)
50 # define VLC_MMX
51 # else
52 # define vlc_CPU_MMX() ((vlc_CPU() & VLC_CPU_MMX) != 0)
53 # define VLC_MMX __attribute__ ((__target__ ("mmx")))
54 # endif
56 # if defined (__SSE__)
57 # define vlc_CPU_MMXEXT() (1)
58 # define vlc_CPU_SSE() (1)
59 # define VLC_SSE
60 # else
61 # define vlc_CPU_MMXEXT() ((vlc_CPU() & VLC_CPU_MMXEXT) != 0)
62 # define vlc_CPU_SSE() ((vlc_CPU() & VLC_CPU_SSE) != 0)
63 # define VLC_SSE __attribute__ ((__target__ ("sse")))
64 # endif
66 # ifdef __SSE2__
67 # define vlc_CPU_SSE2() (1)
68 # else
69 # define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
70 # endif
72 # ifdef __SSE3__
73 # define vlc_CPU_SSE3() (1)
74 # else
75 # define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
76 # endif
78 # ifdef __SSSE3__
79 # define vlc_CPU_SSSE3() (1)
80 # else
81 # define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 0)
82 # endif
84 # ifdef __SSE4_1__
85 # define vlc_CPU_SSE4_1() (1)
86 # else
87 # define vlc_CPU_SSE4_1() ((vlc_CPU() & VLC_CPU_SSE4_1) != 0)
88 # endif
90 # ifdef __SSE4_2__
91 # define vlc_CPU_SSE4_2() (1)
92 # else
93 # define vlc_CPU_SSE4_2() ((vlc_CPU() & VLC_CPU_SSE4_2) != 0)
94 # endif
96 # ifdef __SSE4A__
97 # define vlc_CPU_SSE4A() (1)
98 # else
99 # define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
100 # endif
102 # ifdef __AVX__
103 # define vlc_CPU_AVX() (1)
104 # else
105 # define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
106 # endif
108 # ifdef __AVX2__
109 # define vlc_CPU_AVX2() (1)
110 # else
111 # define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
112 # endif
114 # ifdef __3dNOW__
115 # define vlc_CPU_3dNOW() (1)
116 # else
117 # define vlc_CPU_3dNOW() ((vlc_CPU() & VLC_CPU_3dNOW) != 0)
118 # endif
120 # ifdef __XOP__
121 # define vlc_CPU_XOP() (1)
122 # else
123 # define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
124 # endif
126 # ifdef __FMA4__
127 # define vlc_CPU_FMA4() (1)
128 # else
129 # define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
130 # endif
132 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
133 # define HAVE_FPU 1
134 # define VLC_CPU_ALTIVEC 2
136 # ifdef ALTIVEC
137 # define vlc_CPU_ALTIVEC() (1)
138 # else
139 # define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
140 # endif
142 # elif defined (__arm__)
143 # if defined (__VFP_FP__) && !defined (__SOFTFP__)
144 # define HAVE_FPU 1
145 # else
146 # define HAVE_FPU 0
147 # endif
148 # define VLC_CPU_ARMv6 4
149 # define VLC_CPU_ARM_NEON 2
151 # if defined (__ARM_ARCH_7A__)
152 # define VLC_CPU_ARM_ARCH 7
153 # elif defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6T2__)
154 # define VLC_CPU_ARM_ARCH 6
155 # else
156 # define VLC_CPU_ARM_ARCH 4
157 # endif
159 # if (VLC_CPU_ARM_ARCH >= 6)
160 # define vlc_CPU_ARMv6() (1)
161 # else
162 # define vlc_CPU_ARMv6() ((vlc_CPU() & VLC_CPU_ARMv6) != 0)
163 # endif
165 # ifdef __ARM_NEON__
166 # define vlc_CPU_ARM_NEON() (1)
167 # else
168 # define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
169 # endif
171 # elif defined (__aarch64__)
172 # define HAVE_FPU 1
173 // NEON is mandatory for general purpose ARMv8-a CPUs
174 # define vlc_CPU_ARM64_NEON() (1)
176 # elif defined (__sparc__)
177 # define HAVE_FPU 1
179 # elif defined (__mips_hard_float)
180 # define HAVE_FPU 1
182 # else
184 * Are single precision floating point operations "fast"?
185 * If this preprocessor constant is zero, floating point should be avoided
186 * (especially relevant for audio codecs).
188 # define HAVE_FPU 0
190 # endif
192 #endif /* !VLC_CPU_H */