1 /* libFLAC - Free Lossless Audio Codec library 2 * Copyright (C) 2001-2009 Josh Coalson 3 * Copyright (C) 2011-2013 Xiph.Org Foundation 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * - Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * - Neither the name of the Xiph.org Foundation nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef FLAC__PRIVATE__CPU_H 34 #define FLAC__PRIVATE__CPU_H 35 36 #include "FLAC/ordinals.h" 37 38 #ifdef HAVE_CONFIG_H 39 #include <config.h> 40 #endif 41 42 /* SSE intrinsics support by ICC/MSVC/GCC */ 43 #if defined __INTEL_COMPILER 44 #define FLAC__SSE_TARGET(x) 45 #define FLAC__SSE_SUPPORTED 1 46 #define FLAC__SSE2_SUPPORTED 1 47 #if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */ 48 #define FLAC__SSSE3_SUPPORTED 1 49 #define FLAC__SSE4_1_SUPPORTED 1 50 #endif 51 #elif defined _MSC_VER 52 #define FLAC__SSE_TARGET(x) 53 #define FLAC__SSE_SUPPORTED 1 54 #define FLAC__SSE2_SUPPORTED 1 55 #if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */ 56 #define FLAC__SSSE3_SUPPORTED 1 57 #define FLAC__SSE4_1_SUPPORTED 1 58 #endif 59 #elif defined __GNUC__ 60 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* since GCC 4.9 -msse.. compiler options aren't necessary */ 61 #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) 62 #define FLAC__SSE_SUPPORTED 1 63 #define FLAC__SSE2_SUPPORTED 1 64 #define FLAC__SSSE3_SUPPORTED 1 65 #define FLAC__SSE4_1_SUPPORTED 1 66 #else /* for GCC older than 4.9 */ 67 #define FLAC__SSE_TARGET(x) 68 #ifdef __SSE__ 69 #define FLAC__SSE_SUPPORTED 1 70 #endif 71 #ifdef __SSE2__ 72 #define FLAC__SSE2_SUPPORTED 1 73 #endif 74 #ifdef __SSSE3__ 75 #define FLAC__SSSE3_SUPPORTED 1 76 #endif 77 #ifdef __SSE4_1__ 78 #define FLAC__SSE4_1_SUPPORTED 1 79 #endif 80 #endif /* GCC version */ 81 #endif /* compiler version */ 82 83 typedef enum { 84 FLAC__CPUINFO_TYPE_IA32, 85 FLAC__CPUINFO_TYPE_X86_64, 86 FLAC__CPUINFO_TYPE_PPC, 87 FLAC__CPUINFO_TYPE_UNKNOWN 88 } FLAC__CPUInfo_Type; 89 90 #if defined FLAC__CPU_IA32 91 typedef struct { 92 FLAC__bool cpuid; 93 FLAC__bool bswap; 94 FLAC__bool cmov; 95 FLAC__bool mmx; 96 FLAC__bool fxsr; 97 FLAC__bool sse; 98 FLAC__bool sse2; 99 FLAC__bool sse3; 100 FLAC__bool ssse3; 101 FLAC__bool sse41; 102 FLAC__bool sse42; 103 FLAC__bool _3dnow; 104 FLAC__bool ext3dnow; 105 FLAC__bool extmmx; 106 } FLAC__CPUInfo_IA32; 107 #elif defined FLAC__CPU_X86_64 108 typedef struct { 109 FLAC__bool sse3; 110 FLAC__bool ssse3; 111 FLAC__bool sse41; 112 FLAC__bool sse42; 113 } FLAC__CPUInfo_x86_64; 114 #elif defined FLAC__CPU_PPC 115 typedef struct { 116 FLAC__bool altivec; 117 FLAC__bool ppc64; 118 } FLAC__CPUInfo_PPC; 119 #endif 120 121 typedef struct { 122 FLAC__bool use_asm; 123 FLAC__CPUInfo_Type type; 124 #if defined FLAC__CPU_IA32 125 FLAC__CPUInfo_IA32 ia32; 126 #elif defined FLAC__CPU_X86_64 127 FLAC__CPUInfo_x86_64 x86_64; 128 #elif defined FLAC__CPU_PPC 129 FLAC__CPUInfo_PPC ppc; 130 #endif 131 } FLAC__CPUInfo; 132 133 void FLAC__cpu_info(FLAC__CPUInfo *info); 134 135 #ifndef FLAC__NO_ASM 136 137 #if defined FLAC__CPU_IA32 && defined FLAC__HAS_NASM 138 FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void); 139 void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx); 140 FLAC__uint32 FLAC__cpu_info_extended_amd_asm_ia32(void); 141 #endif 142 143 #if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN 144 FLAC__uint32 FLAC__cpu_have_cpuid_x86(void); 145 void FLAC__cpu_info_x86(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx); 146 #endif 147 148 #endif 149 150 #endif 151