VLC
4.0.0-dev
include
vlc_cpu.h
Go to the documentation of this file.
1
/*****************************************************************************
2
* vlc_cpu.h: CPU capabilities
3
*****************************************************************************
4
* Copyright (C) 1998-2009 VLC authors and VideoLAN
5
*
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.
10
*
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.
15
*
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
*****************************************************************************/
20
21
/**
22
* \file
23
* This file provides CPU features detection.
24
*/
25
26
#ifndef VLC_CPU_H
27
# define VLC_CPU_H 1
28
29
/**
30
* Retrieves CPU capability flags.
31
*/
32
VLC_API
unsigned
vlc_CPU
(
void
);
33
34
/**
35
* Computes CPU capability flags.
36
*
37
* Do not call this function directly.
38
* Call vlc_CPU() instead, which caches the correct value.
39
*/
40
unsigned
vlc_CPU_raw
(
void
);
41
42
# if defined (__i386__) || defined (__x86_64__)
43
# define HAVE_FPU 1
44
# define VLC_CPU_MMX 0x00000008
45
# define VLC_CPU_3dNOW 0x00000010
46
# define VLC_CPU_MMXEXT 0x00000020
47
# define VLC_CPU_SSE 0x00000040
48
# define VLC_CPU_SSE2 0x00000080
49
# define VLC_CPU_SSE3 0x00000100
50
# define VLC_CPU_SSSE3 0x00000200
51
# define VLC_CPU_SSE4_1 0x00000400
52
# define VLC_CPU_SSE4_2 0x00000800
53
# define VLC_CPU_SSE4A 0x00001000
54
# define VLC_CPU_AVX 0x00002000
55
# define VLC_CPU_AVX2 0x00004000
56
# define VLC_CPU_XOP 0x00008000
57
# define VLC_CPU_FMA4 0x00010000
58
59
# if defined (__MMX__)
60
# define vlc_CPU_MMX() (1)
61
# define VLC_MMX
62
# else
63
# define vlc_CPU_MMX() ((vlc_CPU() & VLC_CPU_MMX) != 0)
64
# define VLC_MMX __attribute__ ((__target__ ("mmx")))
65
# endif
66
67
# if defined (__SSE__)
68
# define vlc_CPU_MMXEXT() (1)
69
# define vlc_CPU_SSE() (1)
70
# define VLC_SSE
71
# else
72
# define vlc_CPU_MMXEXT() ((vlc_CPU() & VLC_CPU_MMXEXT) != 0)
73
# define vlc_CPU_SSE() ((vlc_CPU() & VLC_CPU_SSE) != 0)
74
# define VLC_SSE __attribute__ ((__target__ ("sse")))
75
# endif
76
77
# ifdef __SSE2__
78
# define vlc_CPU_SSE2() (1)
79
# else
80
# define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
81
# endif
82
83
# ifdef __SSE3__
84
# define vlc_CPU_SSE3() (1)
85
# else
86
# define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
87
# endif
88
89
# ifdef __SSSE3__
90
# define vlc_CPU_SSSE3() (1)
91
# else
92
# define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 0)
93
# endif
94
95
# ifdef __SSE4_1__
96
# define vlc_CPU_SSE4_1() (1)
97
# else
98
# define vlc_CPU_SSE4_1() ((vlc_CPU() & VLC_CPU_SSE4_1) != 0)
99
# endif
100
101
# ifdef __SSE4_2__
102
# define vlc_CPU_SSE4_2() (1)
103
# else
104
# define vlc_CPU_SSE4_2() ((vlc_CPU() & VLC_CPU_SSE4_2) != 0)
105
# endif
106
107
# ifdef __SSE4A__
108
# define vlc_CPU_SSE4A() (1)
109
# else
110
# define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
111
# endif
112
113
# ifdef __AVX__
114
# define vlc_CPU_AVX() (1)
115
# define VLC_AVX
116
# else
117
# define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
118
# define VLC_AVX __attribute__ ((__target__ ("avx")))
119
# endif
120
121
# ifdef __AVX2__
122
# define vlc_CPU_AVX2() (1)
123
# else
124
# define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
125
# endif
126
127
# ifdef __3dNOW__
128
# define vlc_CPU_3dNOW() (1)
129
# else
130
# define vlc_CPU_3dNOW() ((vlc_CPU() & VLC_CPU_3dNOW) != 0)
131
# endif
132
133
# ifdef __XOP__
134
# define vlc_CPU_XOP() (1)
135
# else
136
# define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
137
# endif
138
139
# ifdef __FMA4__
140
# define vlc_CPU_FMA4() (1)
141
# else
142
# define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
143
# endif
144
145
# elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
146
# define HAVE_FPU 1
147
# define VLC_CPU_ALTIVEC 2
148
149
# ifdef ALTIVEC
150
# define vlc_CPU_ALTIVEC() (1)
151
# else
152
# define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
153
# endif
154
155
# elif defined (__arm__)
156
# if defined (__VFP_FP__) && !defined (__SOFTFP__)
157
# define HAVE_FPU 1
158
# else
159
# define HAVE_FPU 0
160
# endif
161
# define VLC_CPU_ARMv6 4
162
# define VLC_CPU_ARM_NEON 2
163
164
# if defined (__ARM_ARCH_7A__)
165
# define VLC_CPU_ARM_ARCH 7
166
# elif defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6T2__)
167
# define VLC_CPU_ARM_ARCH 6
168
# else
169
# define VLC_CPU_ARM_ARCH 4
170
# endif
171
172
# if (VLC_CPU_ARM_ARCH >= 6)
173
# define vlc_CPU_ARMv6() (1)
174
# else
175
# define vlc_CPU_ARMv6() ((vlc_CPU() & VLC_CPU_ARMv6) != 0)
176
# endif
177
178
# ifdef __ARM_NEON__
179
# define vlc_CPU_ARM_NEON() (1)
180
# else
181
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
182
# endif
183
184
# elif defined (__aarch64__)
185
# define HAVE_FPU 1
186
# define VLC_CPU_ARM_NEON 0x1
187
# define VLC_CPU_ARM_SVE 0x2
188
189
# ifdef __ARM_NEON
190
# define vlc_CPU_ARM_NEON() (1)
191
# else
192
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
193
# endif
194
195
# ifdef __ARM_FEATURE_SVE
196
# define vlc_CPU_ARM_SVE() (1)
197
# else
198
# define vlc_CPU_ARM_SVE() ((vlc_CPU() & VLC_CPU_ARM_SVE) != 0)
199
# endif
200
201
# elif defined (__sparc__)
202
# define HAVE_FPU 1
203
204
# elif defined (__mips_hard_float)
205
# define HAVE_FPU 1
206
207
# else
208
/**
209
* Are single precision floating point operations "fast"?
210
* If this preprocessor constant is zero, floating point should be avoided
211
* (especially relevant for audio codecs).
212
*/
213
# define HAVE_FPU 0
214
215
# endif
216
217
#endif
/* !VLC_CPU_H */
VLC_API
#define VLC_API
Definition:
fourcc_gen.c:31
vlc_common.h
vlc_CPU_raw
unsigned vlc_CPU_raw(void)
Computes CPU capability flags.
Definition:
cpu.c:118
vlc_CPU
VLC_EXPORT unsigned vlc_CPU(void)
Retrieves CPU capability flags.
Definition:
cpu.c:252
Generated by
1.8.17