]> git.sesse.net Git - vlc/blob - include/vlc_cpu.h
Check for AltiVec at build-time if possible (untested)
[vlc] / include / vlc_cpu.h
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 VLC_API unsigned vlc_CPU(void);
30
31 # if defined (__i386__) || defined (__x86_64__)
32 #  define HAVE_FPU 1
33 #  define CPU_CAPABILITY_MMX     (1<<3)
34 #  define CPU_CAPABILITY_3DNOW   (1<<4)
35 #  define CPU_CAPABILITY_MMXEXT  (1<<5)
36 #  define CPU_CAPABILITY_SSE     (1<<6)
37 #  define CPU_CAPABILITY_SSE2    (1<<7)
38 #  define CPU_CAPABILITY_SSE3    (1<<8)
39 #  define CPU_CAPABILITY_SSSE3   (1<<9)
40 #  define CPU_CAPABILITY_SSE4_1  (1<<10)
41 #  define CPU_CAPABILITY_SSE4_2  (1<<11)
42 #  define CPU_CAPABILITY_SSE4A   (1<<12)
43
44 # if defined (__MMX__)
45 #  define VLC_MMX
46 # elif VLC_GCC_VERSION(4, 4)
47 #  define VLC_MMX __attribute__ ((__target__ ("mmx")))
48 # else
49 #  define VLC_MMX VLC_MMX_is_not_implemented_on_this_compiler
50 # endif
51
52 # if defined (__SSE__)
53 #  define VLC_SSE
54 # elif VLC_GCC_VERSION(4, 4)
55 #  define VLC_SSE __attribute__ ((__target__ ("sse")))
56 # else
57 #  define VLC_SSE VLC_SSE_is_not_implemented_on_this_compiler
58 # endif
59
60 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
61 #  define HAVE_FPU 1
62 #  define VLC_CPU_ALTIVEC 2
63
64 #  ifdef ALTIVEC
65 #   define vlc_CPU_ALTIVEC() (1)
66 #  else
67 #   define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
68 #  endif
69
70 # elif defined (__arm__)
71 #  if defined (__VFP_FP__) && !defined (__SOFTFP__)
72 #   define HAVE_FPU 1
73 #  else
74 #   define HAVE_FPU 0
75 #  endif
76 #  define VLC_CPU_ARM_NEON 2
77
78 #  ifdef __ARM_NEON__
79 #   define vlc_CPU_ARM_NEON() (1)
80 #  else
81 #   define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
82 #  endif
83
84 # elif defined (__sparc__)
85 #  define HAVE_FPU 1
86
87 # else
88 /**
89  * Are single precision floating point operations "fast"?
90  * If this preprocessor constant is zero, floating point should be avoided
91  * (especially relevant for audio codecs).
92  */
93 #  define HAVE_FPU 0
94
95 # endif
96
97 #endif /* !VLC_CPU_H */