mirror of https://github.com/xiph/flac
libFLAC/cpu.c: Fixes for MSVC
MSVC is strange and perverse.
This commit is contained in:
parent
162a44923c
commit
a08e90c425
|
@ -35,6 +35,7 @@
|
|||
#endif
|
||||
|
||||
#include "private/cpu.h"
|
||||
#include "share/compat.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
|
@ -453,6 +454,21 @@ void FLAC__cpu_info (FLAC__CPUInfo *info)
|
|||
|
||||
#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN
|
||||
|
||||
#if defined _MSC_VER || defined __INTEL_COMPILER
|
||||
static inline void
|
||||
cpu_id_ex (int *cpuinfo, int result)
|
||||
{
|
||||
// Stupid MSVC doesn't know how to optimise out:
|
||||
// if (FLAC_AVC_SUPPORTER)
|
||||
// __cpuidex(cpuinfo, level, 0); /* for AVX2 detection */
|
||||
#if FLAC__AVX_SUPPORTED
|
||||
__cpuidex(cpuinfo, result, 0); /* for AVX2 detection */
|
||||
#else
|
||||
__cpuid(cpuinfo, result); /* some old compilers don't support __cpuidex */
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx)
|
||||
{
|
||||
#if defined _MSC_VER || defined __INTEL_COMPILER
|
||||
|
@ -463,10 +479,8 @@ void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx
|
|||
*eax = *ebx = *ecx = *edx = 0;
|
||||
return;
|
||||
}
|
||||
if (FLAC__AVX_SUPPORTED)
|
||||
__cpuidex(cpuinfo, level, 0); /* for AVX2 detection */
|
||||
else
|
||||
__cpuid(cpuinfo, level); /* some old compilers don't support __cpuidex */
|
||||
|
||||
cpu_id_ex (cpuinfo, ext);
|
||||
|
||||
*eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3];
|
||||
#elif defined __GNUC__ && defined HAVE_CPUID_H
|
||||
|
|
Loading…
Reference in New Issue