summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-09-20 09:12:29 +0000
committerjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-09-20 09:12:29 +0000
commitaf22e5a6ae056fce608b4743f41e14e2a1930454 (patch)
tree68a3a39332124770c1e6b9a0b871f982c0b695ca /loader
parent88cb39f859386fad11d81192301f416be28960a3 (diff)
downloadmpv-af22e5a6ae056fce608b4743f41e14e2a1930454.tar.bz2
mpv-af22e5a6ae056fce608b4743f41e14e2a1930454.tar.xz
do_cpuid stored the results of the cpuid instruction in the wrong place
(overwriting stack memory) To work around the buggy do_cpuid, localcount_stub was using a bogus test to test for the availability of the TSC register. Both problems fixed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1924 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/win32.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/loader/win32.c b/loader/win32.c
index ca6549f554..01e45fdd7b 100644
--- a/loader/win32.c
+++ b/loader/win32.c
@@ -48,10 +48,8 @@ long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
char* def_path=WIN32_PATH;
-static void do_cpuid(unsigned int *regs)
+static void do_cpuid(unsigned int ax, unsigned int *regs)
{
- unsigned int ax;
- ax=1;
__asm__ __volatile__(
"pushl %%ebx; pushl %%ecx; pushl %%edx; "
".byte 0x0f, 0xa2;"
@@ -61,7 +59,7 @@ static void do_cpuid(unsigned int *regs)
"movl %%edx, 12(%2);"
"popl %%edx; popl %%ecx; popl %%ebx; "
: "=a" (ax)
- : "0" (ax), "S" (&regs));
+ : "0" (ax), "S" (regs));
}
static unsigned int c_localcount_tsc()
{
@@ -113,8 +111,8 @@ static void (*longcount)(long long*)=longcount_stub;
static unsigned int localcount_stub(void)
{
unsigned int regs[4];
- do_cpuid(regs);
- if ((regs[3] & 0x00000010) == 0)
+ do_cpuid(1, regs);
+ if ((regs[3] & 0x00000010) != 0)
{
localcount=c_localcount_tsc;
longcount=c_longcount_tsc;
@@ -129,8 +127,8 @@ static unsigned int localcount_stub(void)
static void longcount_stub(long long* z)
{
unsigned int regs[4];
- do_cpuid(regs);
- if ((regs[3] & 0x00000010) == 0)
+ do_cpuid(1, regs);
+ if ((regs[3] & 0x00000010) != 0)
{
localcount=c_localcount_tsc;
longcount=c_longcount_tsc;
@@ -705,7 +703,7 @@ void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
cachedsi.wProcessorRevision = 0x0101;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__)
- do_cpuid(regs);
+ do_cpuid(1, regs);
switch ((regs[0] >> 8) & 0xf) { // cpu family
case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
cachedsi.wProcessorLevel= 3;