Add a config option to disable use of CPU extensions

This commit is contained in:
Chris Robinson
2012-08-13 10:37:49 -07:00
parent 0a3eba08d8
commit 17dfaa3aae
4 changed files with 52 additions and 10 deletions
+31 -1
View File
@@ -769,6 +769,7 @@ static void alc_init(void)
static void alc_initconfig(void)
{
const char *devs, *str;
ALuint capfilter;
float valf;
int i, n;
@@ -790,7 +791,36 @@ static void alc_initconfig(void)
ReadALConfig();
FillCPUCaps();
capfilter = CPU_CAP_ALL;
if(ConfigValueStr(NULL, "disable-cpu-exts", &str))
{
if(strcasecmp(str, "all") == 0)
capfilter = 0;
else
{
size_t len;
const char *next = str;
i = 0;
do {
str = next;
next = strchr(str, ',');
while(isspace(str[0]))
str++;
if(!str[0] || str[0] == ',')
continue;
len = (next ? ((size_t)(next-str)) : strlen(str));
if(strncasecmp(str, "neon", len) == 0)
capfilter &= ~CPU_CAP_NEON;
else
WARN("Invalid CPU extension \"%s\"\n", str);
} while(next++);
}
}
FillCPUCaps(capfilter);
InitHrtf();
#ifdef _WIN32
+11 -8
View File
@@ -63,8 +63,10 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,
ALuint CPUCapFlags = 0;
void FillCPUCaps(void)
void FillCPUCaps(ALuint capfilter)
{
ALuint caps = 0;
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
/* FIXME: We really should get this for all available CPUs in case different
* CPUs have different caps (is that possible on one machine?). */
@@ -90,11 +92,11 @@ void FillCPUCaps(void)
{
#ifdef bit_MMX
if((cpuinf[0].regs[3]&bit_MMX))
CPUCapFlags |= CPU_CAP_MMX;
caps |= CPU_CAP_MMX;
#endif
#ifdef bit_SSE
if((cpuinf[0].regs[3]&bit_SSE))
CPUCapFlags |= CPU_CAP_SSE;
caps |= CPU_CAP_SSE;
#endif
}
}
@@ -102,13 +104,14 @@ void FillCPUCaps(void)
#endif
#ifdef HAVE_ARM_NEON_H
/* Assume Neon support if compiled with it */
CPUCapFlags |= CPU_CAP_NEON;
caps |= CPU_CAP_NEON;
#endif
TRACE("Got caps:%s%s%s%s\n", ((CPUCapFlags&CPU_CAP_MMX)?" MMX":""),
((CPUCapFlags&CPU_CAP_SSE)?" SSE":""),
((CPUCapFlags&CPU_CAP_NEON)?" Neon":""),
((!CPUCapFlags)?" (none)":""));
TRACE("Got caps:%s%s%s%s\n", ((caps&CPU_CAP_MMX)?((capfilter&CPU_CAP_MMX)?" MMX":" (MMX)"):""),
((caps&CPU_CAP_SSE)?((capfilter&CPU_CAP_SSE)?" SSE":" (SSE)"):""),
((caps&CPU_CAP_NEON)?((capfilter&CPU_CAP_NEON)?" Neon":" (Neon)"):""),
((!caps)?" (none)":""));
CPUCapFlags = caps & capfilter;
}
+3 -1
View File
@@ -768,9 +768,11 @@ enum {
CPU_CAP_MMX = 1<<0,
CPU_CAP_SSE = 1<<1,
CPU_CAP_NEON = 1<<3,
CPU_CAP_ALL = CPU_CAP_MMX|CPU_CAP_SSE|CPU_CAP_NEON
};
void FillCPUCaps(void);
void FillCPUCaps(ALuint capfilter);
/**
+7
View File
@@ -11,6 +11,13 @@
# possible). Note: options that are left unset may default to app- or system-
# specified values. These are the current available settings:
## disable-cpu-exts:
# Disables use of the listed CPU extensions. Certain methods may utilize CPU
# extensions when detected, and this option is useful for preventing those
# extensions from being used. The available extensions are: neon. Specifying
# 'all' disables use of all extensions.
#disable-cpu-exts =
## channels:
# Sets the output channel configuration. If left unspecified, one will try to
# be detected from the system, and defaulting to stereo. The available values