1 /*****************************************************************************
2  * Copyright (C) 2013 x265 project
3  *
4  * Authors: Loren Merritt <lorenm@u.washington.edu>
5  *          Steve Borho <steve@borho.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
20  *
21  * This program is also available under a commercial proprietary license.
22  * For more information, contact us at license @ x265.com.
23  *****************************************************************************/
24 
25 #ifndef X265_CPU_H
26 #define X265_CPU_H
27 
28 #include "common.h"
29 
30 /* All assembly functions are prefixed with X265_NS (macro expanded) */
31 #define PFX3(prefix, name) prefix ## _ ## name
32 #define PFX2(prefix, name) PFX3(prefix, name)
33 #define PFX(name)          PFX2(X265_NS, name)
34 
35 // from cpu-a.asm, if ASM primitives are compiled, else primitives.cpp
36 extern "C" void PFX(cpu_emms)(void);
37 extern "C" void PFX(safe_intel_cpu_indicator_init)(void);
38 
39 #if _MSC_VER && _WIN64
40 #define x265_emms() PFX(cpu_emms)()
41 #elif _MSC_VER
42 #include <mmintrin.h>
43 #define x265_emms() _mm_empty()
44 #elif __GNUC__
45 // Cannot use _mm_empty() directly without compiling all the source with
46 // a fixed CPU arch, which we would like to avoid at the moment
47 #define x265_emms() PFX(cpu_emms)()
48 #else
49 #define x265_emms() PFX(cpu_emms)()
50 #endif
51 
52 namespace X265_NS {
53 uint32_t cpu_detect(void);
54 
55 struct cpu_name_t
56 {
57     char name[16];
58     uint32_t flags;
59 };
60 
61 extern const cpu_name_t cpu_names[];
62 }
63 
64 #endif // ifndef X265_CPU_H
65